Skip to content

Commit

Permalink
Update src/main/java/redis/clients/jedis/JedisClusterCommand.java
Browse files Browse the repository at this point in the history
Co-authored-by: Mina Asham <mina.asham@hotmail.com>
  • Loading branch information
Johan Walles and mina-asham committed Feb 17, 2021
1 parent 4f138e4 commit 4f80d73
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/redis/clients/jedis/JedisClusterCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private T runWithRetries(final int slot) {
// If we got one redirection, stick with that and don't try anything else
Supplier<Jedis> redirectionSupplier = null;

Exception lastException = null;
for (int currentAttempt = 0; currentAttempt < this.maxAttempts; currentAttempt++) {
Jedis connection = null;
try {
Expand All @@ -98,15 +99,17 @@ private T runWithRetries(final int slot) {
} catch (JedisNoReachableClusterNodeException e) {
throw e;
} catch (JedisConnectionException e) {
lastException = e;
connectionSupplier = handleConnectionProblem(slot, currentAttempt);
} catch (JedisRedirectionException e) {
lastException = e;
redirectionSupplier = handleRedirection(connection, e);
} finally {
releaseConnection(connection);
}
}

throw new JedisClusterMaxAttemptsException("No more cluster attempts left.");
throw new JedisClusterMaxAttemptsException("No more cluster attempts left.", lastException);
}

private Supplier<Jedis> handleConnectionProblem(final int slot, int currentAttempt) {
Expand Down

0 comments on commit 4f80d73

Please sign in to comment.