Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split JedisClusterCommand into multiple methods #2355

Merged
merged 9 commits into from
Feb 26, 2021
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);
walles marked this conversation as resolved.
Show resolved Hide resolved
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
sazzad16 marked this conversation as resolved.
Show resolved Hide resolved
}

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