diff --git a/java/client/src/main/java/glide/connectors/handlers/CallbackDispatcher.java b/java/client/src/main/java/glide/connectors/handlers/CallbackDispatcher.java index 7ed5b344b2..ec2711b03f 100644 --- a/java/client/src/main/java/glide/connectors/handlers/CallbackDispatcher.java +++ b/java/client/src/main/java/glide/connectors/handlers/CallbackDispatcher.java @@ -50,9 +50,9 @@ public Pair> registerRequest() { var future = new CompletableFuture(); Integer callbackId = freeRequestIds.poll(); if (callbackId == null) { - // on null, we have no available request ids available - // we can add - callbackId = nextAvailableRequestId.incrementAndGet(); + // on null, we have no available request ids available in freeRequestIds + // instead, get the next available request from counter + callbackId = nextAvailableRequestId.getAndIncrement(); } responses.put(callbackId, future); return Pair.of(callbackId, future); diff --git a/java/client/src/main/java/glide/managers/CommandManager.java b/java/client/src/main/java/glide/managers/CommandManager.java index 31f7bafafc..0b4b60dfe2 100644 --- a/java/client/src/main/java/glide/managers/CommandManager.java +++ b/java/client/src/main/java/glide/managers/CommandManager.java @@ -9,6 +9,10 @@ import redis_request.RedisRequestOuterClass.RequestType; import response.ResponseOuterClass.Response; +/** + * Service responsible for submitting command requests to a socket channel handler + * and unpack responses from the same socket channel handler. + */ @RequiredArgsConstructor public class CommandManager { @@ -53,7 +57,7 @@ private CompletableFuture submitNewRequest(RequestType command, List