From ee5edf6b9a6b15b9cc80f5ea644ae56d622fad68 Mon Sep 17 00:00:00 2001 From: agrgr Date: Sun, 21 Jul 2024 17:24:15 +0300 Subject: [PATCH] add timeout --- .../data/aerospike/util/InfoCommandUtils.java | 3 ++- .../org/springframework/data/aerospike/util/IndexUtils.java | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/springframework/data/aerospike/util/InfoCommandUtils.java b/src/main/java/org/springframework/data/aerospike/util/InfoCommandUtils.java index 23a6f860..03b7fb05 100644 --- a/src/main/java/org/springframework/data/aerospike/util/InfoCommandUtils.java +++ b/src/main/java/org/springframework/data/aerospike/util/InfoCommandUtils.java @@ -11,6 +11,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionException; +import java.util.concurrent.TimeUnit; @Slf4j @UtilityClass @@ -48,7 +49,7 @@ public void onFailure(AerospikeException ae) { String value = null; try { - value = listener.getValueFuture().join(); + value = listener.getValueFuture().orTimeout(infoPolicy.timeout, TimeUnit.MILLISECONDS).join(); } catch (CompletionException ce) { fail(command, ce.getCause()); } diff --git a/src/test/java/org/springframework/data/aerospike/util/IndexUtils.java b/src/test/java/org/springframework/data/aerospike/util/IndexUtils.java index 8eedfb14..23719652 100644 --- a/src/test/java/org/springframework/data/aerospike/util/IndexUtils.java +++ b/src/test/java/org/springframework/data/aerospike/util/IndexUtils.java @@ -44,8 +44,7 @@ static void createIndex(IAerospikeClient client, ServerVersionSupport serverVers public static List getIndexes(IAerospikeClient client, String namespace, IndexInfoParser indexInfoParser) { Node node = client.getCluster().getRandomNode(); - String response = InfoCommandUtils.request(client, node, "sindex-list:ns=" + namespace + ";b64=true" - ); + String response = InfoCommandUtils.request(client, node, "sindex-list:ns=" + namespace + ";b64=true"); return Arrays.stream(response.split(";")) .map(indexInfoParser::parse) .collect(Collectors.toList()); @@ -57,8 +56,7 @@ public static List getIndexes(IAerospikeClient client, String namespace, */ public static boolean indexExists(IAerospikeClient client, String namespace, String indexName) { Node node = client.getCluster().getRandomNode(); - String response = InfoCommandUtils.request(client, node, "sindex/" + namespace + '/' + indexName - ); + String response = InfoCommandUtils.request(client, node, "sindex/" + namespace + '/' + indexName); return !response.startsWith("FAIL:201"); }