diff --git a/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java b/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java index 02711a45..b900c4b2 100644 --- a/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java @@ -1308,6 +1308,7 @@ public boolean indexExists(String indexName) { try { Node[] nodes = client.getNodes(); for (Node node : nodes) { + if (!node.isActive()) continue; String response = InfoCommandUtils.request(client, node, "sindex-exists:ns=" + namespace + ";indexname=" + indexName); if (response == null) throw new AerospikeException("Null node response"); diff --git a/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java b/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java index 256c6d0a..9e011194 100644 --- a/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java @@ -1199,6 +1199,7 @@ public Mono indexExists(String indexName) { try { Node[] nodes = reactorClient.getAerospikeClient().getNodes(); for (Node node : nodes) { + if (!node.isActive()) continue; String response = InfoCommandUtils.request(reactorClient.getAerospikeClient(), node, "sindex-exists:ns=" + namespace + ";indexname=" + indexName); if (response == null) throw new AerospikeException("Null node response"); diff --git a/src/main/java/org/springframework/data/aerospike/util/Utils.java b/src/main/java/org/springframework/data/aerospike/util/Utils.java index cd97b713..64cb5eaa 100644 --- a/src/main/java/org/springframework/data/aerospike/util/Utils.java +++ b/src/main/java/org/springframework/data/aerospike/util/Utils.java @@ -76,14 +76,11 @@ public class Utils { * @return An "Info" value for the given variable from all the nodes in the cluster. */ @SuppressWarnings("UnusedReturnValue") - public static String[] infoAll(IAerospikeClient client, - String infoString) { - String[] messages = new String[client.getNodes().length]; - int index = 0; - for (Node node : client.getNodes()) { - messages[index] = Info.request(client.getInfoPolicyDefault(), node, infoString); - } - return messages; + public static String[] infoAll(IAerospikeClient client, String infoString) { + return Arrays.stream(client.getNodes()) + .filter(Node::isActive) + .map(node -> Info.request(client.getInfoPolicyDefault(), node, infoString)) + .toArray(String[]::new); } public static int getReplicationFactor(IAerospikeClient client, Node[] nodes, String namespace) {