Skip to content

Commit

Permalink
Revert Sharded Jedis related changes from "Avoid using QUIT command (#…
Browse files Browse the repository at this point in the history
…3377)"

This partially reverts commit 1787d31.
  • Loading branch information
sazzad16 committed Apr 20, 2023
1 parent 1787d31 commit 153841e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/main/java/redis/clients/jedis/BinaryShardedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,20 @@ public BinaryShardedJedis(List<JedisShardInfo> shards, Hashing algo, Pattern key
public void disconnect() {
for (Jedis jedis : getAllShards()) {
if (jedis.isConnected()) {
try {
// need a proper test, probably with mock
if (!jedis.isBroken()) {
jedis.quit();
}
} catch (JedisConnectionException e) {
// ignore the exception node, so that all other normal nodes can release all connections.
logger.warn("Error while QUIT", e);
}
try {
jedis.disconnect();
} catch (JedisConnectionException e) {
// ignore the exception node, so that all other normal nodes can release all connections.
logger.debug("Error while disconnect", e);
logger.warn("Error while disconnect", e);
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/redis/clients/jedis/ShardedJedisPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,18 @@ public void destroyObject(PooledObject<ShardedJedis> pooledShardedJedis) throws
final ShardedJedis shardedJedis = pooledShardedJedis.getObject();
for (Jedis jedis : shardedJedis.getAllShards()) {
if (jedis.isConnected()) {
try {
// need a proper test, probably with mock
if (!jedis.isBroken()) {
jedis.quit();
}
} catch (RuntimeException e) {
logger.warn("Error while QUIT", e);
}
try {
jedis.disconnect();
} catch (RuntimeException e) {
logger.debug("Error while disconnect", e);
logger.warn("Error while disconnect", e);
}
}
}
Expand Down

0 comments on commit 153841e

Please sign in to comment.