From fe6e65f4fe4f2b8ac2d078f45eecd098a397b906 Mon Sep 17 00:00:00 2001 From: John Blum Date: Wed, 20 Sep 2023 13:36:54 -0700 Subject: [PATCH] Rename Lambda parameters by type in JedisConnection and JedisInvoker. Refactor, organize source and fix compiler warnings. --- .../connection/jedis/JedisConnection.java | 20 ++++--- .../redis/connection/jedis/JedisInvoker.java | 56 +++++++++++-------- 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java index a474bbb8fe..32ee6f6df4 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java @@ -209,7 +209,7 @@ private Object doInvoke(boolean status, Function directFunction, Function> pipelineFunction, Converter converter, Supplier nullDefault) { - return doWithJedis(it -> { + return doWithJedis(jedis -> { if (isQueueing()) { @@ -225,7 +225,7 @@ private Object doInvoke(boolean status, Function directFunction, return null; } - Object result = directFunction.apply(getJedis()); + Object result = directFunction.apply(jedis); if (result == null) { return nullDefault.get(); @@ -378,7 +378,7 @@ public void openPipeline() { } if (pipeline == null) { - pipeline = jedis.pipelined(); + pipeline = getJedis().pipelined(); } } @@ -411,7 +411,8 @@ private List convertPipelineResults() { Object data = result.get(); if (!result.isStatus()) { - results.add(result.conversionRequired() ? result.convert(data) : data); + Object resolvedData = result.conversionRequired() ? result.convert(data) : data; + results.add(resolvedData); } } catch (JedisDataException e) { DataAccessException dataAccessException = convertJedisAccessException(e); @@ -550,17 +551,20 @@ JedisInvoker invokeStatus() { } JedisResult newJedisResult(Response response) { - return JedisResultBuilder. forResponse(response).build(); + return JedisResultBuilder.forResponse(response).build(); } JedisResult newJedisResult(Response response, Converter converter, Supplier defaultValue) { - return JedisResultBuilder. forResponse(response).mappedWith(converter) - .convertPipelineAndTxResults(convertPipelineAndTxResults).mapNullTo(defaultValue).build(); + return JedisResultBuilder.forResponse(response) + .convertPipelineAndTxResults(this.convertPipelineAndTxResults) + .mapNullTo(defaultValue) + .mappedWith(converter) + .build(); } JedisStatusResult newStatusResult(Response response) { - return JedisResultBuilder. forResponse(response).buildStatusResult(); + return JedisResultBuilder.forResponse(response).buildStatusResult(); } @Override diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisInvoker.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisInvoker.java index ef1771969d..b049274240 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisInvoker.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisInvoker.java @@ -82,7 +82,7 @@ R just(ConnectionFunction0 function) { Assert.notNull(function, "ConnectionFunction must not be null"); - return synchronizer.invoke(function::apply, it -> { + return synchronizer.invoke(function::apply, responseCommands -> { throw new InvalidDataAccessApiUsageException("Operation not supported by Jedis in pipelining/transaction mode"); }, Converters.identityConverter(), () -> null); } @@ -115,7 +115,8 @@ R just(ConnectionFunction1 function, PipelineFunction1 pip Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return synchronizer.invoke(it -> function.apply(it, t1), it -> pipelineFunction.apply(it, t1)); + return synchronizer.invoke(jedis -> function.apply(jedis, t1), + responseCommands -> pipelineFunction.apply(responseCommands, t1)); } /** @@ -133,7 +134,8 @@ R just(ConnectionFunction2 function, PipelineFunction2 function.apply(it, t1, t2), it -> pipelineFunction.apply(it, t1, t2)); + return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2)); } /** @@ -152,7 +154,8 @@ R just(ConnectionFunction3 function, PipelineFunc Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return synchronizer.invoke(it -> function.apply(it, t1, t2, t3), it -> pipelineFunction.apply(it, t1, t2, t3)); + return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2, t3), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3)); } /** @@ -172,7 +175,7 @@ R just(ConnectionFunction4 function, Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return synchronizer.invoke(it -> function.apply(it, t1, t2, t3, t4), + return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2, t3, t4), it -> pipelineFunction.apply(it, t1, t2, t3, t4)); } @@ -194,7 +197,7 @@ R just(ConnectionFunction5 functi Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return synchronizer.invoke(it -> function.apply(it, t1, t2, t3, t4, t5), + return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2, t3, t4, t5), it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5)); } @@ -217,8 +220,8 @@ R just(ConnectionFunction6 function.apply(it, t1, t2, t3, t4, t5, t6), - it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5, t6)); + return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2, t3, t4, t5, t6), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5, t6)); } /** @@ -265,7 +268,7 @@ SingleInvocationSpec from(ConnectionFunction1 function, Pipeli Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return from(it -> function.apply(it, t1), it -> pipelineFunction.apply(it, t1)); + return from(jedis -> function.apply(jedis, t1), responseCommands -> pipelineFunction.apply(responseCommands, t1)); } /** @@ -283,7 +286,8 @@ SingleInvocationSpec from(ConnectionFunction2 function Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return from(it -> function.apply(it, t1, t2), it -> pipelineFunction.apply(it, t1, t2)); + return from(jedis -> function.apply(jedis, t1, t2), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2)); } /** @@ -302,7 +306,8 @@ SingleInvocationSpec from(ConnectionFunction3 Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return from(it -> function.apply(it, t1, t2, t3), it -> pipelineFunction.apply(it, t1, t2, t3)); + return from(jedis -> function.apply(jedis, t1, t2, t3), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3)); } /** @@ -322,7 +327,8 @@ SingleInvocationSpec from(ConnectionFunction4 function.apply(it, t1, t2, t3, t4), it -> pipelineFunction.apply(it, t1, t2, t3, t4)); + return from(jedis -> function.apply(jedis, t1, t2, t3, t4), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4)); } /** @@ -343,7 +349,8 @@ SingleInvocationSpec from(ConnectionFunction5 function.apply(it, t1, t2, t3, t4, t5), it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5)); + return from(jedis -> function.apply(jedis, t1, t2, t3, t4, t5), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5)); } /** @@ -365,8 +372,8 @@ SingleInvocationSpec from(ConnectionFunction6 function.apply(it, t1, t2, t3, t4, t5, t6), - it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5, t6)); + return from(jedis -> function.apply(jedis, t1, t2, t3, t4, t5, t6), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5, t6)); } /** @@ -414,7 +421,8 @@ , E, T1> ManyInvocationSpec fromMany(ConnectionFuncti Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return fromMany(it -> function.apply(it, t1), it -> pipelineFunction.apply(it, t1)); + return fromMany(jedis -> function.apply(jedis, t1), + responseCommands -> pipelineFunction.apply(responseCommands, t1)); } /** @@ -432,7 +440,8 @@ , E, T1, T2> ManyInvocationSpec fromMany(ConnectionFu Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return fromMany(it -> function.apply(it, t1, t2), it -> pipelineFunction.apply(it, t1, t2)); + return fromMany(jedis -> function.apply(jedis, t1, t2), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2)); } /** @@ -451,7 +460,8 @@ , E, T1, T2, T3> ManyInvocationSpec fromMany(Connecti Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return fromMany(it -> function.apply(it, t1, t2, t3), it -> pipelineFunction.apply(it, t1, t2, t3)); + return fromMany(jedis -> function.apply(jedis, t1, t2, t3), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3)); } /** @@ -472,7 +482,8 @@ , E, T1, T2, T3, T4> ManyInvocationSpec fromMany( Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return fromMany(it -> function.apply(it, t1, t2, t3, t4), it -> pipelineFunction.apply(it, t1, t2, t3, t4)); + return fromMany(jedis -> function.apply(jedis, t1, t2, t3, t4), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4)); } /** @@ -494,7 +505,8 @@ , E, T1, T2, T3, T4, T5> ManyInvocationSpec fromMany( Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return fromMany(it -> function.apply(it, t1, t2, t3, t4, t5), it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5)); + return fromMany(jedis -> function.apply(jedis, t1, t2, t3, t4, t5), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5)); } /** @@ -517,8 +529,8 @@ , E, T1, T2, T3, T4, T5, T6> ManyInvocationSpec fromM Assert.notNull(function, "ConnectionFunction must not be null"); Assert.notNull(pipelineFunction, "PipelineFunction must not be null"); - return fromMany(it -> function.apply(it, t1, t2, t3, t4, t5, t6), - it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5, t6)); + return fromMany(jedis -> function.apply(jedis, t1, t2, t3, t4, t5, t6), + responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5, t6)); } /**