diff --git a/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java b/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java index 19cdfb431..ac3a5e347 100644 --- a/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java +++ b/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java @@ -674,10 +674,10 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { addedSlots.andNot(currentPartition.slots()); currentPartition.addSlots(addedSlots); - for (Integer slot : (Iterable) addedSlots.stream()::iterator) { + addedSlots.stream().forEach(slot -> { addEntry(slot, entry); lastPartitions.put(slot, currentPartition); - } + }); if (!addedSlots.isEmpty()) { log.info("{} slots added to {}", addedSlots.cardinality(), currentPartition.getMasterAddress()); } @@ -686,12 +686,11 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { removedSlots.andNot(newPartition.slots()); currentPartition.removeSlots(removedSlots); - for (Integer removeSlot : (Iterable) removedSlots.stream()::iterator) { + removedSlots.stream().forEach(removeSlot -> { if (lastPartitions.remove(removeSlot, currentPartition)) { removeEntry(removeSlot); } - } - + }); if (!removedSlots.isEmpty()) { log.info("{} slots removed from {}", removedSlots.cardinality(), currentPartition.getMasterAddress()); }