From f0cc49d06c4051cc253cc6bfcce90c0609ebc94c Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Tue, 19 Mar 2024 08:29:47 +0800 Subject: [PATCH] fix bug. --- .../xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java b/src/main/java/xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java index 7ed3888..424739c 100644 --- a/src/main/java/xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java +++ b/src/main/java/xyz/zhouxy/plusone/commons/util/SnowflakeIdGenerator.java @@ -64,9 +64,9 @@ public class SnowflakeIdGenerator { * @param datacenterId 数据中心ID (0~31) */ public SnowflakeIdGenerator(final long workerId, final long datacenterId) { - Preconditions.checkArgument((workerId <= MAX_WORKER_ID || workerId >= 0), + Preconditions.checkArgument((workerId <= MAX_WORKER_ID && workerId >= 0), "WorkerId can't be greater than %s or less than 0.", MAX_WORKER_ID); - Preconditions.checkArgument((datacenterId <= MAX_DATACENTER_ID || datacenterId >= 0), + Preconditions.checkArgument((datacenterId <= MAX_DATACENTER_ID && datacenterId >= 0), "DatacenterId can't be greater than %s or less than 0.", MAX_DATACENTER_ID); this.datacenterIdAndWorkerId = (datacenterId << DATACENTER_ID_SHIFT) | (workerId << WORKER_ID_SHIFT);