diff --git a/java/client/src/main/java/glide/connectors/handlers/ChannelHandler.java b/java/client/src/main/java/glide/connectors/handlers/ChannelHandler.java index c12cc15411..bc38510105 100644 --- a/java/client/src/main/java/glide/connectors/handlers/ChannelHandler.java +++ b/java/client/src/main/java/glide/connectors/handlers/ChannelHandler.java @@ -24,10 +24,12 @@ public class ChannelHandler { /** Open a new channel for a new client. */ public ChannelHandler(CallbackDispatcher callbackDispatcher, String socketPath) { + // TODO: add the ability to pass in group and channel from user channel = new Bootstrap() // TODO let user specify the thread pool or pool size as an option - .group(ThreadPoolAllocator.createNettyThreadPool(THREAD_POOL_NAME, Optional.empty())) + .group( + ThreadPoolAllocator.createOrGetNettyThreadPool(THREAD_POOL_NAME, Optional.empty())) .channel(Platform.getClientUdsNettyChannelType()) .handler(new ProtobufSocketChannelInitializer(callbackDispatcher)) .connect(new DomainSocketAddress(socketPath)) diff --git a/java/client/src/main/java/glide/connectors/resources/ThreadPoolAllocator.java b/java/client/src/main/java/glide/connectors/resources/ThreadPoolAllocator.java index 064b280c94..26a30537cf 100644 --- a/java/client/src/main/java/glide/connectors/resources/ThreadPoolAllocator.java +++ b/java/client/src/main/java/glide/connectors/resources/ThreadPoolAllocator.java @@ -24,7 +24,8 @@ public class ThreadPoolAllocator { * * @return A new thread pool. */ - public static EventLoopGroup createNettyThreadPool(String prefix, Optional threadLimit) { + public static EventLoopGroup createOrGetNettyThreadPool( + String prefix, Optional threadLimit) { int threadCount = threadLimit.orElse(Runtime.getRuntime().availableProcessors()); if (Platform.getCapabilities().isKQueueAvailable()) { String name = prefix + "-kqueue-elg"; diff --git a/java/client/src/main/java/glide/managers/CommandManager.java b/java/client/src/main/java/glide/managers/CommandManager.java index 134373a081..8b460bf2df 100644 --- a/java/client/src/main/java/glide/managers/CommandManager.java +++ b/java/client/src/main/java/glide/managers/CommandManager.java @@ -61,12 +61,13 @@ private CompletableFuture submitNewRequest(RequestType command, List connectToRedis( /** Check a response received from Glide. */ private Void checkGlideRsResponse(Response response) { if (response.hasRequestError()) { - // TODO do we need to support different types of exceptions and distinguish them by type? + // TODO unexpected when establishing a connection throw new RuntimeException( String.format( "%s: %s",