Skip to content

Commit

Permalink
Adapt to API changes in the Jedis 5.0 driver.
Browse files Browse the repository at this point in the history
  • Loading branch information
jxblum committed Sep 15, 2023
1 parent cf4f3bb commit ec121d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import redis.clients.jedis.BuilderFactory;
import redis.clients.jedis.CommandArguments;
import redis.clients.jedis.CommandObject;
Expand Down Expand Up @@ -130,6 +127,7 @@ public class JedisConnection extends AbstractRedisConnection {

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

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

private final @Nullable Pool<Jedis> pool;
Expand Down Expand Up @@ -348,7 +346,6 @@ public void close() throws DataAccessException {
jedis.close();
}
else {
doExceptionThrowingOperationSafely(jedis::quit, "Failed to quit during close");
doExceptionThrowingOperationSafely(jedis::disconnect, "Failed to disconnect during close");
}
}
Expand Down Expand Up @@ -480,6 +477,7 @@ public void discard() {
public List<Object> exec() {

try {

if (transaction == null) {
throw new InvalidDataAccessApiUsageException("No ongoing transaction; Did you forget to call multi");
}
Expand All @@ -489,6 +487,7 @@ public List<Object> exec() {
return !CollectionUtils.isEmpty(results)
? new TransactionResultConverter<>(txResults, JedisExceptionConverter.INSTANCE).convert(results)
: results;

} catch (Exception cause) {
throw convertJedisAccessException(cause);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,18 +584,14 @@ static ZAddParams toZAddParams(ZAddArgs source) {
return new ZAddParams();
}

ZAddParams target = new ZAddParams() {

{
if (source.contains(ZAddArgs.Flag.GT)) {
addParam("gt");
}
if (source.contains(ZAddArgs.Flag.LT)) {
addParam("lt");
}
}
};
ZAddParams target = new ZAddParams();

if (source.contains(ZAddArgs.Flag.GT)) {
target.gt();
}
if (source.contains(ZAddArgs.Flag.LT)) {
target.lt();
}
if (source.contains(ZAddArgs.Flag.XX)) {
target.xx();
}
Expand All @@ -605,6 +601,7 @@ static ZAddParams toZAddParams(ZAddArgs source) {
if (source.contains(ZAddArgs.Flag.CH)) {
target.ch();
}

return target;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import redis.clients.jedis.Jedis;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.Queable;
import redis.clients.jedis.Response;
import redis.clients.jedis.Transaction;
import redis.clients.jedis.commands.DatabasePipelineCommands;
Expand Down Expand Up @@ -47,7 +46,7 @@
* composing a functional pipeline to transform the result using a {@link Converter}.
* <p>
* Usage example:
*
* <p>
* <pre class="code">
* JedisInvoker invoker = …;
*
Expand All @@ -62,6 +61,7 @@
*
* @author Mark Paluch
* @author Christoph Strobl
* @author John Blum
* @since 2.5
*/
class JedisInvoker {
Expand Down Expand Up @@ -1046,11 +1046,8 @@ interface ResponseCommands extends PipelineBinaryCommands, DatabasePipelineComma
/**
* Create a proxy to invoke methods dynamically on {@link Pipeline} or {@link Transaction} as those share many
* commands that are not defined on a common super-type.
*
* @param pipelineOrTransaction
* @return
*/
static ResponseCommands createCommands(Queable pipelineOrTransaction) {
static ResponseCommands createCommands(Object pipelineOrTransaction) {

ProxyFactory proxyFactory = new ProxyFactory(pipelineOrTransaction);
proxyFactory.addInterface(ResponseCommands.class);
Expand Down

0 comments on commit ec121d9

Please sign in to comment.