diff --git a/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java b/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java index cc5703ce3..56425310a 100644 --- a/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java +++ b/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java @@ -661,10 +661,8 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { Set clusterLastPartitions = getLastPartitions(); // https://github.com/redisson/redisson/issues/3635 - Map nodeEntry = new HashMap<>(); - clusterLastPartitions.forEach(partition -> { - nodeEntry.put(partition.getNodeId(), getEntry(partition.slots().nextSetBit(0))); - }); + Map nodeEntries = clusterLastPartitions.stream().collect(Collectors.toMap(p -> p.getNodeId(), + p -> getEntry(p.slots().nextSetBit(0)))); Set changedSlots = new HashSet<>(); for (ClusterPartition currentPartition : clusterLastPartitions) { @@ -674,7 +672,7 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { continue; } - MasterSlaveEntry entry = nodeEntry.get(nodeId); + MasterSlaveEntry entry = nodeEntries.get(nodeId); BitSet addedSlots = newPartition.copySlots(); addedSlots.andNot(currentPartition.slots()); currentPartition.addSlots(addedSlots);