diff --git a/pom.xml b/pom.xml
index c3b30527e5..3213d4d7e2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-redis
- 3.2.0-SNAPSHOT
+ 3.2.0-GH-2748-SNAPSHOT
Spring Data Redis
Spring Data module for Redis
diff --git a/src/main/java/org/springframework/data/redis/cache/DefaultRedisCacheWriter.java b/src/main/java/org/springframework/data/redis/cache/DefaultRedisCacheWriter.java
index d80fd6335f..5d997bee42 100644
--- a/src/main/java/org/springframework/data/redis/cache/DefaultRedisCacheWriter.java
+++ b/src/main/java/org/springframework/data/redis/cache/DefaultRedisCacheWriter.java
@@ -377,13 +377,14 @@ private void checkAndPotentiallyWaitUntilUnlocked(String name, RedisConnection c
while (doCheckLock(name, connection)) {
Thread.sleep(this.sleepTime.toMillis());
}
- } catch (InterruptedException cause) {
+ } catch (InterruptedException ex) {
// Re-interrupt current Thread to allow other participants to react.
Thread.currentThread().interrupt();
- throw new PessimisticLockingFailureException(String.format("Interrupted while waiting to unlock cache %s", name),
- cause);
+ String message = String.format("Interrupted while waiting to unlock cache %s", name);
+
+ throw new PessimisticLockingFailureException(message, ex);
} finally {
this.statistics.incLockTime(name, System.nanoTime() - lockWaitTimeNs);
}
diff --git a/src/main/java/org/springframework/data/redis/cache/RedisCache.java b/src/main/java/org/springframework/data/redis/cache/RedisCache.java
index 2df721c0a4..11debd8710 100644
--- a/src/main/java/org/springframework/data/redis/cache/RedisCache.java
+++ b/src/main/java/org/springframework/data/redis/cache/RedisCache.java
@@ -189,8 +189,8 @@ protected T loadCacheValue(Object key, Callable valueLoader) {
try {
value = valueLoader.call();
- } catch (Exception cause) {
- throw new ValueRetrievalException(key, valueLoader, cause);
+ } catch (Exception ex) {
+ throw new ValueRetrievalException(key, valueLoader, ex);
}
put(key, value);
@@ -425,14 +425,14 @@ protected String convertKey(Object key) {
if (conversionService.canConvert(source, TypeDescriptor.valueOf(String.class))) {
try {
return conversionService.convert(key, String.class);
- } catch (ConversionFailedException cause) {
+ } catch (ConversionFailedException ex) {
// May fail if the given key is a collection
if (isCollectionLikeOrMap(source)) {
return convertCollectionLikeOrMapKey(key, source);
}
- throw cause;
+ throw ex;
}
}
diff --git a/src/main/java/org/springframework/data/redis/connection/AbstractRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/AbstractRedisConnection.java
index 71c2e0050a..fcdffc4a38 100644
--- a/src/main/java/org/springframework/data/redis/connection/AbstractRedisConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/AbstractRedisConnection.java
@@ -114,8 +114,8 @@ public void close() throws DataAccessException {
try {
connection.close();
- } catch (IOException e) {
- LOGGER.info("Failed to close sentinel connection", e);
+ } catch (IOException ex) {
+ LOGGER.info("Failed to close sentinel connection", ex);
}
}
}
diff --git a/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java b/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java
index 849f9e14b0..0b28fbd05c 100644
--- a/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java
+++ b/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java
@@ -131,10 +131,11 @@ private NodeResult executeCommandOnSingleNode(ClusterCommandCallback this.maxRedirects) {
- throw new TooManyClusterRedirectionsException(String.format(
- "Cannot follow Cluster Redirects over more than %s legs; "
- + "Consider increasing the number of redirects to follow; Current value is: %s.",
- redirectCount, this.maxRedirects));
+ String message = String.format("Cannot follow Cluster Redirects over more than %s legs; "
+ + "Consider increasing the number of redirects to follow; Current value is: %s.",
+ redirectCount, this.maxRedirects);
+
+ throw new TooManyClusterRedirectionsException(message);
}
RedisClusterNode nodeToUse = lookupNode(node);
@@ -145,15 +146,19 @@ private NodeResult executeCommandOnSingleNode(ClusterCommandCallback(node, commandCallback.doInCluster(client));
- } catch (RuntimeException cause) {
+ } catch (RuntimeException ex) {
- RuntimeException translatedException = convertToDataAccessException(cause);
+ RuntimeException translatedException = convertToDataAccessException(ex);
if (translatedException instanceof ClusterRedirectException clusterRedirectException) {
- return executeCommandOnSingleNode(commandCallback, topologyProvider.getTopology().lookup(
- clusterRedirectException.getTargetHost(), clusterRedirectException.getTargetPort()), redirectCount + 1);
+
+ String targetHost = clusterRedirectException.getTargetHost();
+ int targetPort = clusterRedirectException.getTargetPort();
+ RedisClusterNode clusterNode = topologyProvider.getTopology().lookup(targetHost, targetPort);
+
+ return executeCommandOnSingleNode(commandCallback, clusterNode, redirectCount + 1);
} else {
- throw translatedException != null ? translatedException : cause;
+ throw translatedException != null ? translatedException : ex;
}
} finally {
this.resourceProvider.returnResourceForSpecificNode(nodeToUse, client);
@@ -172,8 +177,8 @@ private RedisClusterNode lookupNode(RedisClusterNode node) {
try {
return topologyProvider.getTopology().lookup(node);
- } catch (ClusterStateFailureException cause) {
- throw new IllegalArgumentException(String.format("Node %s is unknown to cluster", node), cause);
+ } catch (ClusterStateFailureException ex) {
+ throw new IllegalArgumentException(String.format("Node %s is unknown to cluster", node), ex);
}
}
@@ -209,8 +214,8 @@ public MultiNodeResult executeCommandAsyncOnNodes(ClusterCommandCallba
for (RedisClusterNode node : nodes) {
try {
resolvedRedisClusterNodes.add(topology.lookup(node));
- } catch (ClusterStateFailureException cause) {
- throw new IllegalArgumentException(String.format("Node %s is unknown to cluster", node), cause);
+ } catch (ClusterStateFailureException ex) {
+ throw new IllegalArgumentException(String.format("Node %s is unknown to cluster", node), ex);
}
}
@@ -249,13 +254,13 @@ MultiNodeResult collectResults(Map>>
}
entryIterator.remove();
- } catch (ExecutionException exception) {
+ } catch (ExecutionException ex) {
entryIterator.remove();
- exceptionCollector.addException(nodeExecution, exception.getCause());
+ exceptionCollector.addException(nodeExecution, ex.getCause());
} catch (TimeoutException ignore) {
- } catch (InterruptedException exception) {
+ } catch (InterruptedException ex) {
Thread.currentThread().interrupt();
- exceptionCollector.addException(nodeExecution, exception);
+ exceptionCollector.addException(nodeExecution, ex);
break OUT;
}
}
@@ -316,11 +321,11 @@ private NodeResult executeMultiKeyCommandOnSingleNode(MultiKeyClusterC
try {
return new NodeResult<>(node, commandCallback.doInCluster(client, key), key);
- } catch (RuntimeException cause) {
+ } catch (RuntimeException ex) {
- RuntimeException translatedException = convertToDataAccessException(cause);
+ RuntimeException translatedException = convertToDataAccessException(ex);
- throw translatedException != null ? translatedException : cause;
+ throw translatedException != null ? translatedException : ex;
} finally {
this.resourceProvider.returnResourceForSpecificNode(node, client);
}
diff --git a/src/main/java/org/springframework/data/redis/connection/RedisNode.java b/src/main/java/org/springframework/data/redis/connection/RedisNode.java
index 490e58eaaf..7c66f5a1e9 100644
--- a/src/main/java/org/springframework/data/redis/connection/RedisNode.java
+++ b/src/main/java/org/springframework/data/redis/connection/RedisNode.java
@@ -101,7 +101,7 @@ public static RedisNode fromString(String hostPortString) {
int port = -1;
try {
port = Integer.parseInt(portString);
- } catch (RuntimeException e) {
+ } catch (RuntimeException ignore) {
throw new IllegalArgumentException(String.format("Unparseable port number: %s", hostPortString));
}
diff --git a/src/main/java/org/springframework/data/redis/connection/convert/Converters.java b/src/main/java/org/springframework/data/redis/connection/convert/Converters.java
index 7956f03bb7..94dbc9087d 100644
--- a/src/main/java/org/springframework/data/redis/connection/convert/Converters.java
+++ b/src/main/java/org/springframework/data/redis/connection/convert/Converters.java
@@ -109,8 +109,8 @@ public static Properties toProperties(String source) {
try (StringReader stringReader = new StringReader(source)) {
info.load(stringReader);
- } catch (Exception cause) {
- throw new RedisSystemException("Cannot read Redis info", cause);
+ } catch (Exception ex) {
+ throw new RedisSystemException("Cannot read Redis info", ex);
}
return info;
diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java
index d02bea66a5..16cec8f85a 100644
--- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java
@@ -123,8 +123,8 @@ public JedisClusterConnection(JedisCluster cluster) {
Object custerCommandExecutor = executorDfa.getPropertyValue("executor");
DirectFieldAccessor dfa = new DirectFieldAccessor(custerCommandExecutor);
clusterCommandExecutor.setMaxRedirects((Integer) dfa.getPropertyValue("maxRedirects"));
- } catch (Exception e) {
- // ignore it and work with the executor default
+ } catch (Exception ignore) {
+ // ignore and work with the executor default
}
}
@@ -381,8 +381,8 @@ public void subscribe(MessageListener listener, byte[]... channels) {
JedisMessageListener jedisPubSub = new JedisMessageListener(listener);
subscription = new JedisSubscription(listener, jedisPubSub, channels, null);
cluster.subscribe(jedisPubSub, channels);
- } catch (Exception cause) {
- throw convertJedisAccessException(cause);
+ } catch (Exception ex) {
+ throw convertJedisAccessException(ex);
}
}
@@ -398,8 +398,8 @@ public void pSubscribe(MessageListener listener, byte[]... patterns) {
JedisMessageListener jedisPubSub = new JedisMessageListener(listener);
subscription = new JedisSubscription(listener, jedisPubSub, null, patterns);
cluster.psubscribe(jedisPubSub, patterns);
- } catch (Exception cause) {
- throw convertJedisAccessException(cause);
+ } catch (Exception ex) {
+ throw convertJedisAccessException(ex);
}
}
@@ -643,8 +643,8 @@ public void close() throws DataAccessException {
if (!closed && disposeClusterCommandExecutorOnClose) {
try {
clusterCommandExecutor.destroy();
- } catch (Exception cause) {
- log.warn("Cannot properly close cluster command executor", cause);
+ } catch (Exception ex) {
+ log.warn("Cannot properly close cluster command executor", ex);
}
}
@@ -864,8 +864,8 @@ public ClusterTopology getTopology() {
return cached;
- } catch (Exception cause) {
- errors.put(entry.getKey(), cause);
+ } catch (Exception ex) {
+ errors.put(entry.getKey(), ex);
}
}
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..83acd8d07a 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
@@ -193,9 +193,9 @@ protected JedisConnection(Jedis jedis, @Nullable Pool pool, JedisClientCo
if (nodeConfig.getDatabase() != jedis.getDB()) {
try {
select(nodeConfig.getDatabase());
- } catch (DataAccessException cause) {
+ } catch (DataAccessException ex) {
close();
- throw cause;
+ throw ex;
}
}
}
@@ -413,17 +413,17 @@ private List