diff --git a/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java b/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java index 5f2f8146e..194c831ef 100644 --- a/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java +++ b/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java @@ -152,8 +152,8 @@ public class ClusterCommandExecutor implements DisposableBean { /** * Lookup node from the topology. * - * @param node - * @return + * @param node must not be {@literal null}. + * @return never {@literal null}. * @throws IllegalArgumentException in case the node could not be resolved to a topology-known node */ private RedisClusterNode lookupNode(RedisClusterNode node) { @@ -167,8 +167,8 @@ public class ClusterCommandExecutor implements DisposableBean { /** * Run {@link ClusterCommandCallback} on all reachable master nodes. * - * @param cmd - * @return + * @param cmd must not be {@literal null}. + * @return never {@literal null}. * @throws ClusterCommandExecutionFailureException */ public MultiNodeResult executeCommandOnAllNodes(final ClusterCommandCallback cmd) { @@ -176,9 +176,9 @@ public class ClusterCommandExecutor implements DisposableBean { } /** - * @param callback - * @param nodes - * @return + * @param callback must not be {@literal null}. + * @param nodes must not be {@literal null}. + * @return never {@literal null}. * @throws ClusterCommandExecutionFailureException * @throws IllegalArgumentException in case the node could not be resolved to a topology-known node */ @@ -263,8 +263,8 @@ public class ClusterCommandExecutor implements DisposableBean { /** * Run {@link MultiKeyClusterCommandCallback} with on a curated set of nodes serving one or more keys. * - * @param cmd - * @return + * @param cmd must not be {@literal null}. + * @return never {@literal null}. * @throws ClusterCommandExecutionFailureException */ public MultiNodeResult executeMultiKeyCommand(MultiKeyClusterCommandCallback cmd, @@ -390,7 +390,7 @@ public class ClusterCommandExecutor implements DisposableBean { private RedisClusterNode node; private Object[] args; - public NodeExecution(RedisClusterNode node, Object... args) { + NodeExecution(RedisClusterNode node, Object... args) { this.node = node; this.args = args; @@ -399,7 +399,7 @@ public class ClusterCommandExecutor implements DisposableBean { /** * Get the {@link RedisClusterNode} the execution happens on. */ - public RedisClusterNode getNode() { + RedisClusterNode getNode() { return node; } @@ -556,7 +556,7 @@ public class ClusterCommandExecutor implements DisposableBean { } /** - * @param returnValue + * @param returnValue can be {@literal null}. * @return */ public T getFirstNonNullNotEmptyOrDefault(T returnValue) { diff --git a/src/main/java/org/springframework/data/redis/connection/ClusterTopology.java b/src/main/java/org/springframework/data/redis/connection/ClusterTopology.java index 92cf61c93..be689a997 100644 --- a/src/main/java/org/springframework/data/redis/connection/ClusterTopology.java +++ b/src/main/java/org/springframework/data/redis/connection/ClusterTopology.java @@ -40,7 +40,7 @@ public class ClusterTopology { * @param nodes can be {@literal null}. */ public ClusterTopology(Set nodes) { - this.nodes = nodes != null ? nodes : Collections. emptySet(); + this.nodes = nodes != null ? nodes : Collections.emptySet(); } /** @@ -123,7 +123,7 @@ public class ClusterTopology { * Get the {@link RedisClusterNode} that is the current master serving the given key. * * @param key must not be {@literal null}. - * @return + * @return never {@literal null}. * @throws ClusterStateFailureException */ public RedisClusterNode getKeyServingMasterNode(byte[] key) { @@ -131,13 +131,15 @@ public class ClusterTopology { Assert.notNull(key, "Key for node lookup must not be null!"); int slot = ClusterSlotHashUtil.calculateSlot(key); + for (RedisClusterNode node : nodes) { if (node.isMaster() && node.servesSlot(slot)) { return node; } } - throw new ClusterStateFailureException(String.format("Could not find master node serving slot %s for key '%s',", - slot, key)); + + throw new ClusterStateFailureException( + String.format("Could not find master node serving slot %s for key '%s',", slot, key)); } /** @@ -145,7 +147,7 @@ public class ClusterTopology { * * @param host must not be {@literal null}. * @param port - * @return + * @return never {@literal null}. * @throws ClusterStateFailureException */ public RedisClusterNode lookup(String host, int port) { @@ -155,15 +157,16 @@ public class ClusterTopology { return node; } } - throw new ClusterStateFailureException(String.format( - "Could not find node at %s:%s. Is your cluster info up to date?", host, port)); + + throw new ClusterStateFailureException( + String.format("Could not find node at %s:%s. Is your cluster info up to date?", host, port)); } /** * Get the {@link RedisClusterNode} matching given {@literal nodeId}. * * @param nodeId must not be {@literal null}. - * @return + * @return never {@literal null}. * @throws ClusterStateFailureException */ public RedisClusterNode lookup(String nodeId) { @@ -175,23 +178,24 @@ public class ClusterTopology { return node; } } - throw new ClusterStateFailureException(String.format( - "Could not find node at %s. Is your cluster info up to date?", nodeId)); + + throw new ClusterStateFailureException( + String.format("Could not find node at %s. Is your cluster info up to date?", nodeId)); } /** - * Get the {@link RedisClusterNode} matching matching either {@link RedisClusterNode#getHost() host} and {@link RedisClusterNode#getPort() port} - * or {@link RedisClusterNode#getId() nodeId} + * Get the {@link RedisClusterNode} matching matching either {@link RedisClusterNode#getHost() host} and + * {@link RedisClusterNode#getPort() port} or {@link RedisClusterNode#getId() nodeId} * * @param node must not be {@literal null} - * @return - * @throws ClusterStateFailureException + * @return never {@literal null}. + * @throws ClusterStateFailureException */ public RedisClusterNode lookup(RedisClusterNode node) { Assert.notNull(node, "RedisClusterNode must not be null!"); - if(nodes.contains(node) && StringUtils.hasText(node.getHost()) && StringUtils.hasText(node.getId())){ + if (nodes.contains(node) && StringUtils.hasText(node.getHost()) && StringUtils.hasText(node.getId())) { return node; } diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisZSetCommands.java index 8fe879a54..38cb617a4 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisZSetCommands.java @@ -38,7 +38,7 @@ class JedisZSetCommands implements RedisZSetCommands { private final JedisConnection connection; - public JedisZSetCommands(JedisConnection connection) { + JedisZSetCommands(JedisConnection connection) { this.connection = connection; }