Skip to content

Commit ec121d9

Browse files
committed
Adapt to API changes in the Jedis 5.0 driver.
Closes spring-projects#2612
1 parent cf4f3bb commit ec121d9

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@
5959
import org.springframework.util.Assert;
6060
import org.springframework.util.CollectionUtils;
6161

62-
import org.apache.commons.logging.Log;
63-
import org.apache.commons.logging.LogFactory;
64-
6562
import redis.clients.jedis.BuilderFactory;
6663
import redis.clients.jedis.CommandArguments;
6764
import redis.clients.jedis.CommandObject;
@@ -130,6 +127,7 @@ public class JedisConnection extends AbstractRedisConnection {
130127

131128
private final Log LOGGER = LogFactory.getLog(getClass());
132129

130+
@SuppressWarnings("rawtypes")
133131
private List<JedisResult> pipelinedResults = new ArrayList<>();
134132

135133
private final @Nullable Pool<Jedis> pool;
@@ -348,7 +346,6 @@ public void close() throws DataAccessException {
348346
jedis.close();
349347
}
350348
else {
351-
doExceptionThrowingOperationSafely(jedis::quit, "Failed to quit during close");
352349
doExceptionThrowingOperationSafely(jedis::disconnect, "Failed to disconnect during close");
353350
}
354351
}
@@ -480,6 +477,7 @@ public void discard() {
480477
public List<Object> exec() {
481478

482479
try {
480+
483481
if (transaction == null) {
484482
throw new InvalidDataAccessApiUsageException("No ongoing transaction; Did you forget to call multi");
485483
}
@@ -489,6 +487,7 @@ public List<Object> exec() {
489487
return !CollectionUtils.isEmpty(results)
490488
? new TransactionResultConverter<>(txResults, JedisExceptionConverter.INSTANCE).convert(results)
491489
: results;
490+
492491
} catch (Exception cause) {
493492
throw convertJedisAccessException(cause);
494493
} finally {

src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -584,18 +584,14 @@ static ZAddParams toZAddParams(ZAddArgs source) {
584584
return new ZAddParams();
585585
}
586586

587-
ZAddParams target = new ZAddParams() {
588-
589-
{
590-
if (source.contains(ZAddArgs.Flag.GT)) {
591-
addParam("gt");
592-
}
593-
if (source.contains(ZAddArgs.Flag.LT)) {
594-
addParam("lt");
595-
}
596-
}
597-
};
587+
ZAddParams target = new ZAddParams();
598588

589+
if (source.contains(ZAddArgs.Flag.GT)) {
590+
target.gt();
591+
}
592+
if (source.contains(ZAddArgs.Flag.LT)) {
593+
target.lt();
594+
}
599595
if (source.contains(ZAddArgs.Flag.XX)) {
600596
target.xx();
601597
}
@@ -605,6 +601,7 @@ static ZAddParams toZAddParams(ZAddArgs source) {
605601
if (source.contains(ZAddArgs.Flag.CH)) {
606602
target.ch();
607603
}
604+
608605
return target;
609606
}
610607

src/main/java/org/springframework/data/redis/connection/jedis/JedisInvoker.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import redis.clients.jedis.Jedis;
1919
import redis.clients.jedis.Pipeline;
20-
import redis.clients.jedis.Queable;
2120
import redis.clients.jedis.Response;
2221
import redis.clients.jedis.Transaction;
2322
import redis.clients.jedis.commands.DatabasePipelineCommands;
@@ -47,7 +46,7 @@
4746
* composing a functional pipeline to transform the result using a {@link Converter}.
4847
* <p>
4948
* Usage example:
50-
*
49+
* <p>
5150
* <pre class="code">
5251
* JedisInvoker invoker = …;
5352
*
@@ -62,6 +61,7 @@
6261
*
6362
* @author Mark Paluch
6463
* @author Christoph Strobl
64+
* @author John Blum
6565
* @since 2.5
6666
*/
6767
class JedisInvoker {
@@ -1046,11 +1046,8 @@ interface ResponseCommands extends PipelineBinaryCommands, DatabasePipelineComma
10461046
/**
10471047
* Create a proxy to invoke methods dynamically on {@link Pipeline} or {@link Transaction} as those share many
10481048
* commands that are not defined on a common super-type.
1049-
*
1050-
* @param pipelineOrTransaction
1051-
* @return
10521049
*/
1053-
static ResponseCommands createCommands(Queable pipelineOrTransaction) {
1050+
static ResponseCommands createCommands(Object pipelineOrTransaction) {
10541051

10551052
ProxyFactory proxyFactory = new ProxyFactory(pipelineOrTransaction);
10561053
proxyFactory.addInterface(ResponseCommands.class);

0 commit comments

Comments
 (0)