Skip to content

Commit

Permalink
fix(redis#2341): Initialize slots with empty BitSet in RedisClusterNo…
Browse files Browse the repository at this point in the history
…de's constructors
  • Loading branch information
zeze1004 authored and tishun committed Jul 12, 2024
1 parent 83f459a commit 4db2cf7
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ public RedisClusterNode(RedisURI uri, String nodeId, boolean connected, String s
this.configEpoch = configEpoch;
this.replOffset = -1;

this.slots = new BitSet(slots.length());
this.slots.or(slots);
this.slots = slots != null ? slots : new BitSet(0);

setFlags(flags);
}
Expand All @@ -123,8 +122,9 @@ public RedisClusterNode(RedisClusterNode redisClusterNode) {
this.replOffset = redisClusterNode.replOffset;
this.aliases.addAll(redisClusterNode.aliases);

if (redisClusterNode.slots != null && !redisClusterNode.slots.isEmpty()) {
this.slots = new BitSet(SlotHash.SLOT_COUNT);
this.slots = redisClusterNode.slots != null ? new BitSet(SlotHash.SLOT_COUNT) : new BitSet(0);

if (redisClusterNode.slots != null) {
this.slots.or(redisClusterNode.slots);
}

Expand Down

0 comments on commit 4db2cf7

Please sign in to comment.