From cada9b72f69bab26b3c09f663a2649bfbb275867 Mon Sep 17 00:00:00 2001 From: Andrew Carbonetto Date: Thu, 11 Jan 2024 13:38:04 -0800 Subject: [PATCH] Clean up merge changes Signed-off-by: Andrew Carbonetto --- .../src/main/java/glide/api/RedisClient.java | 118 +----------------- .../java/glide/handlers/ReadHandlerTest.java | 21 ++-- .../glide/managers/ConnectionManagerTest.java | 1 - 3 files changed, 17 insertions(+), 123 deletions(-) diff --git a/java/client/src/main/java/glide/api/RedisClient.java b/java/client/src/main/java/glide/api/RedisClient.java index bbf70f5515..68cf90fb33 100644 --- a/java/client/src/main/java/glide/api/RedisClient.java +++ b/java/client/src/main/java/glide/api/RedisClient.java @@ -24,7 +24,7 @@ * Async (non-blocking) client for Redis in Standalone mode. Use {@link * #CreateClient(RedisClientConfiguration)} to request a client to Redis. */ -public class RedisClient extends BaseClient { +public class RedisClient extends BaseClient implements BaseCommands, VoidCommands, StringCommands { /** * Request an async (non-blocking) Redis client in Standalone mode. @@ -68,7 +68,8 @@ protected RedisClient(ConnectionManager connectionManager, CommandManager comman * @param Response value type */ protected CompletableFuture exec( - Command command, RedisExceptionCheckedFunction responseHandler) { + Command command, + RedisExceptionCheckedFunction responseHandler) { return commandManager.submitNewCommand(command, responseHandler); } @@ -79,7 +80,6 @@ protected CompletableFuture exec( * @param transaction with commands to be executed * @return A CompletableFuture completed with the results from Redis */ - @Override public CompletableFuture> exec(Transaction transaction) { // TODO: call commandManager.submitNewTransaction() return exec(transaction, BaseCommands::handleTransactionResponse); @@ -94,116 +94,8 @@ public CompletableFuture> exec(Transaction transaction) { * @return A CompletableFuture completed with the results from Redis */ protected CompletableFuture> exec( - Transaction transaction, Function> responseHandler) { - // TODO: call commandManager.submitNewTransaction() - return new CompletableFuture<>(); - } - - /** - * Executes a single custom command, without checking inputs. Every part of the command, including - * subcommands, should be added as a separate value in args. - * - * @param args command and arguments for the custom command call - * @return CompletableFuture with the response - */ - public CompletableFuture customCommand(String[] args) { - Command command = - Command.builder().requestType(Command.RequestType.CUSTOM_COMMAND).arguments(args).build(); - return exec(command, BaseCommands::handleObjectResponse); - } - - /** - * Get the value associated with the given key, or null if no such value exists. See - * https://redis.io/commands/set/ for details. - * - * @param key - The key to retrieve from the database. - * @return If `key` exists, returns the value of `key` as a string. Otherwise, return null - */ - public CompletableFuture get(String key) { - Command command = - Command.builder() - .requestType(Command.RequestType.GET_STRING) - .arguments(new String[] {key}) - .build(); - return exec(command, StringCommands::handleStringResponse); - } - - /** - * Set the given key with the given value. Return value is dependent on the passed options. See - * https://redis.io/commands/set/ for details. - * - * @param key - The key to store. - * @param value - The value to store with the given key. - * @return null - */ - public CompletableFuture set(String key, String value) { - Command command = - Command.builder() - .requestType(Command.RequestType.SET_STRING) - .arguments(new String[] {key, value}) - .build(); - return exec(command, VoidCommands::handleVoidResponse); - } - - /** - * Set the given key with the given value. Return value is dependent on the passed options. See - * https://redis.io/commands/set/ for details. - * - * @param key - The key to store. - * @param value - The value to store with the given key. - * @param options - The Set options - * @return string or null If value isn't set because of `onlyIfExists` or `onlyIfDoesNotExist` - * conditions, return null. If `returnOldValue` is set, return the old value as a string. - */ - public CompletableFuture set(String key, String value, SetOptions options) { - LinkedList args = new LinkedList<>(); - args.add(key); - args.add(value); - args.addAll(SetOptions.createSetOptions(options)); - Command command = - Command.builder() - .requestType(Command.RequestType.SET_STRING) - .arguments(args.toArray(new String[0])) - .build(); - return exec(command, StringCommands::handleStringResponse); - } - - /** - * Execute a single command against Redis.
- * - * @param command to be executed - * @param responseHandler handler responsible for assigning type to the response - * @return A CompletableFuture completed with the result from Redis - * @param Response value type - */ - protected CompletableFuture exec( - Command command, RedisExceptionCheckedFunction responseHandler) { - return commandManager.submitNewCommand(command, responseHandler); - } - - /** - * Execute a transaction by processing the queued commands.
- * See https://redis.io/topics/Transactions/ for details on Redis Transactions.
- * - * @param transaction with commands to be executed - * @return A CompletableFuture completed with the results from Redis - */ - @Override - public CompletableFuture> exec(Transaction transaction) { - // TODO: call commandManager.submitNewTransaction() - return exec(transaction, BaseCommands::handleTransactionResponse); - } - - /** - * Execute a transaction by processing the queued commands.
- * See https://redis.io/topics/Transactions/ for details on Redis Transactions.
- * - * @param transaction with commands to be executed - * @param responseHandler handler responsible for assigning type to the list of response objects - * @return A CompletableFuture completed with the results from Redis - */ - protected CompletableFuture> exec( - Transaction transaction, Function> responseHandler) { + Transaction transaction, + Function> responseHandler) { // TODO: call commandManager.submitNewTransaction() return new CompletableFuture<>(); } diff --git a/java/client/src/test/java/glide/handlers/ReadHandlerTest.java b/java/client/src/test/java/glide/handlers/ReadHandlerTest.java index 88885755e1..198f9e2d7d 100644 --- a/java/client/src/test/java/glide/handlers/ReadHandlerTest.java +++ b/java/client/src/test/java/glide/handlers/ReadHandlerTest.java @@ -36,9 +36,10 @@ public void teardown() { @Test public void readHandlerRead_testInboundProtobufMessages() { - ResponseOuterClass.Response msg = ResponseOuterClass.Response.newBuilder() - .setConstantResponse(ResponseOuterClass.ConstantResponse.OK) - .build(); + ResponseOuterClass.Response msg = + ResponseOuterClass.Response.newBuilder() + .setConstantResponse(ResponseOuterClass.ConstantResponse.OK) + .build(); assertTrue(embeddedChannel.writeInbound(msg, msg, msg)); assertTrue(embeddedChannel.finish()); @@ -51,19 +52,21 @@ public void readHandlerRead_testInboundProtobufMessages_invalidMessage() { String invalidMsg = "Invalid"; - Exception e = assertThrows(Exception.class, () -> embeddedChannel.writeInbound(invalidMsg, invalidMsg, invalidMsg)); + Exception e = + assertThrows( + Exception.class, + () -> embeddedChannel.writeInbound(invalidMsg, invalidMsg, invalidMsg)); assertEquals("Unexpected message in socket", e.getMessage()); verify(dispatcher, times(0)).completeRequest(any()); - ResponseOuterClass.Response msg = ResponseOuterClass.Response.newBuilder() - .setConstantResponse(ResponseOuterClass.ConstantResponse.OK) - .build(); + ResponseOuterClass.Response msg = + ResponseOuterClass.Response.newBuilder() + .setConstantResponse(ResponseOuterClass.ConstantResponse.OK) + .build(); assertTrue(embeddedChannel.writeInbound(msg)); assertTrue(embeddedChannel.finish()); verify(dispatcher, times(1)).completeRequest(msg); } - - } diff --git a/java/client/src/test/java/glide/managers/ConnectionManagerTest.java b/java/client/src/test/java/glide/managers/ConnectionManagerTest.java index 743c89d300..f86b26589e 100644 --- a/java/client/src/test/java/glide/managers/ConnectionManagerTest.java +++ b/java/client/src/test/java/glide/managers/ConnectionManagerTest.java @@ -259,7 +259,6 @@ public void CheckRedisResponse_ClosingError_throwsRuntimeException() { assertTrue(exception.getCause() instanceof RuntimeException); } - @SneakyThrows @Test public void CloseConnection_closesChannels() {