From e7e55f254e0ffa8594aad33e41beb409edc1cdfb Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Sat, 7 Aug 2021 22:34:16 +0600 Subject: [PATCH] Throw SHUTDOWN error received from Redis (#2613) --- .../java/redis/clients/jedis/BinaryJedis.java | 15 +++++++++------ .../clients/jedis/commands/BasicCommands.java | 5 +++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/redis/clients/jedis/BinaryJedis.java b/src/main/java/redis/clients/jedis/BinaryJedis.java index 6e9220830e..1408ddb779 100644 --- a/src/main/java/redis/clients/jedis/BinaryJedis.java +++ b/src/main/java/redis/clients/jedis/BinaryJedis.java @@ -3442,16 +3442,19 @@ public Long lastsave() { * is switched off without the lost of any data. This is not guaranteed if the client uses simply * {@link #save() SAVE} and then {@link #quit() QUIT} because other clients may alter the DB data * between the two commands. - * @return Status code reply on error. On success nothing is returned since the server quits and - * the connection is closed. + * @return {@code null} + * @throws JedisException with the status code reply on error. On success nothing is thrown since + * the server quits and the connection is closed. */ @Override - public String shutdown() { + public String shutdown() throws JedisException { client.shutdown(); String status; try { status = client.getStatusCodeReply(); - } catch (JedisException ex) { + throw new JedisException(status); + } catch (JedisConnectionException jce) { + // expected status = null; } return status; @@ -3461,8 +3464,8 @@ public String shutdown() { public void shutdown(final SaveMode saveMode) throws JedisException { client.shutdown(saveMode); try { - throw new JedisDataException(client.getStatusCodeReply()); - } catch (JedisConnectionException ex) { + throw new JedisException(client.getStatusCodeReply()); + } catch (JedisConnectionException jce) { // expected } } diff --git a/src/main/java/redis/clients/jedis/commands/BasicCommands.java b/src/main/java/redis/clients/jedis/commands/BasicCommands.java index 88b9bf11fb..78c2fabbeb 100644 --- a/src/main/java/redis/clients/jedis/commands/BasicCommands.java +++ b/src/main/java/redis/clients/jedis/commands/BasicCommands.java @@ -134,9 +134,10 @@ public interface BasicCommands { /** * Stop all the client. Perform a SAVE (if one save point is configured). Flush the append only * file if AOF is enabled quit the server - * @return only in case of error. + * @return {@code null} + * @throws JedisException only in case of error. */ - String shutdown(); + String shutdown() throws JedisException; /** * @see SaveMode