From 4f80d7398c6210d189f9cf70749baf31c8dc55e9 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Wed, 17 Feb 2021 14:24:14 +0100 Subject: [PATCH] Update src/main/java/redis/clients/jedis/JedisClusterCommand.java Co-authored-by: Mina Asham --- src/main/java/redis/clients/jedis/JedisClusterCommand.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/redis/clients/jedis/JedisClusterCommand.java b/src/main/java/redis/clients/jedis/JedisClusterCommand.java index ca31caeba1..be46d7aded 100644 --- a/src/main/java/redis/clients/jedis/JedisClusterCommand.java +++ b/src/main/java/redis/clients/jedis/JedisClusterCommand.java @@ -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 redirectionSupplier = null; + Exception lastException = null; for (int currentAttempt = 0; currentAttempt < this.maxAttempts; currentAttempt++) { Jedis connection = null; try { @@ -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 handleConnectionProblem(final int slot, int currentAttempt) {