@@ -131,10 +131,11 @@ private <S, T> NodeResult<T> executeCommandOnSingleNode(ClusterCommandCallback<S
131
131
132
132
if (redirectCount > this .maxRedirects ) {
133
133
134
- throw new TooManyClusterRedirectionsException (String .format (
135
- "Cannot follow Cluster Redirects over more than %s legs; "
136
- + "Consider increasing the number of redirects to follow; Current value is: %s." ,
137
- redirectCount , this .maxRedirects ));
134
+ String message = String .format ("Cannot follow Cluster Redirects over more than %s legs; "
135
+ + "Consider increasing the number of redirects to follow; Current value is: %s." ,
136
+ redirectCount , this .maxRedirects );
137
+
138
+ throw new TooManyClusterRedirectionsException (message );
138
139
}
139
140
140
141
RedisClusterNode nodeToUse = lookupNode (node );
@@ -145,15 +146,19 @@ private <S, T> NodeResult<T> executeCommandOnSingleNode(ClusterCommandCallback<S
145
146
146
147
try {
147
148
return new NodeResult <>(node , commandCallback .doInCluster (client ));
148
- } catch (RuntimeException cause ) {
149
+ } catch (RuntimeException ex ) {
149
150
150
- RuntimeException translatedException = convertToDataAccessException (cause );
151
+ RuntimeException translatedException = convertToDataAccessException (ex );
151
152
152
153
if (translatedException instanceof ClusterRedirectException clusterRedirectException ) {
153
- return executeCommandOnSingleNode (commandCallback , topologyProvider .getTopology ().lookup (
154
- clusterRedirectException .getTargetHost (), clusterRedirectException .getTargetPort ()), redirectCount + 1 );
154
+
155
+ String targetHost = clusterRedirectException .getTargetHost ();
156
+ int targetPort = clusterRedirectException .getTargetPort ();
157
+ RedisClusterNode clusterNode = topologyProvider .getTopology ().lookup (targetHost , targetPort );
158
+
159
+ return executeCommandOnSingleNode (commandCallback , clusterNode , redirectCount + 1 );
155
160
} else {
156
- throw translatedException != null ? translatedException : cause ;
161
+ throw translatedException != null ? translatedException : ex ;
157
162
}
158
163
} finally {
159
164
this .resourceProvider .returnResourceForSpecificNode (nodeToUse , client );
@@ -172,8 +177,8 @@ private RedisClusterNode lookupNode(RedisClusterNode node) {
172
177
173
178
try {
174
179
return topologyProvider .getTopology ().lookup (node );
175
- } catch (ClusterStateFailureException cause ) {
176
- throw new IllegalArgumentException (String .format ("Node %s is unknown to cluster" , node ), cause );
180
+ } catch (ClusterStateFailureException ex ) {
181
+ throw new IllegalArgumentException (String .format ("Node %s is unknown to cluster" , node ), ex );
177
182
}
178
183
}
179
184
@@ -209,8 +214,8 @@ public <S, T> MultiNodeResult<T> executeCommandAsyncOnNodes(ClusterCommandCallba
209
214
for (RedisClusterNode node : nodes ) {
210
215
try {
211
216
resolvedRedisClusterNodes .add (topology .lookup (node ));
212
- } catch (ClusterStateFailureException cause ) {
213
- throw new IllegalArgumentException (String .format ("Node %s is unknown to cluster" , node ), cause );
217
+ } catch (ClusterStateFailureException ex ) {
218
+ throw new IllegalArgumentException (String .format ("Node %s is unknown to cluster" , node ), ex );
214
219
}
215
220
}
216
221
@@ -249,13 +254,13 @@ <T> MultiNodeResult<T> collectResults(Map<NodeExecution, Future<NodeResult<T>>>
249
254
}
250
255
251
256
entryIterator .remove ();
252
- } catch (ExecutionException exception ) {
257
+ } catch (ExecutionException ex ) {
253
258
entryIterator .remove ();
254
- exceptionCollector .addException (nodeExecution , exception .getCause ());
259
+ exceptionCollector .addException (nodeExecution , ex .getCause ());
255
260
} catch (TimeoutException ignore ) {
256
- } catch (InterruptedException exception ) {
261
+ } catch (InterruptedException ex ) {
257
262
Thread .currentThread ().interrupt ();
258
- exceptionCollector .addException (nodeExecution , exception );
263
+ exceptionCollector .addException (nodeExecution , ex );
259
264
break OUT ;
260
265
}
261
266
}
@@ -316,11 +321,11 @@ private <S, T> NodeResult<T> executeMultiKeyCommandOnSingleNode(MultiKeyClusterC
316
321
317
322
try {
318
323
return new NodeResult <>(node , commandCallback .doInCluster (client , key ), key );
319
- } catch (RuntimeException cause ) {
324
+ } catch (RuntimeException ex ) {
320
325
321
- RuntimeException translatedException = convertToDataAccessException (cause );
326
+ RuntimeException translatedException = convertToDataAccessException (ex );
322
327
323
- throw translatedException != null ? translatedException : cause ;
328
+ throw translatedException != null ? translatedException : ex ;
324
329
} finally {
325
330
this .resourceProvider .returnResourceForSpecificNode (node , client );
326
331
}
0 commit comments