Skip to content

Commit

Permalink
Ensure closing connection in Pipeline (#3865)
Browse files Browse the repository at this point in the history
even if there is an error in sync method.
  • Loading branch information
sazzad16 committed Jul 11, 2024
1 parent 1c13877 commit 287d743
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/redis/clients/jedis/Pipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.graph.GraphCommandObjects;
import redis.clients.jedis.params.*;
import redis.clients.jedis.util.IOUtils;
import redis.clients.jedis.util.KeyValue;

public class Pipeline extends PipelineBase implements DatabasePipelineCommands, Closeable {
Expand Down Expand Up @@ -46,10 +47,12 @@ public final <T> Response<T> appendCommand(CommandObject<T> commandObject) {

@Override
public void close() {
sync();

if (closeConnection) {
connection.close();
try {
sync();
} finally {
if (closeConnection) {
IOUtils.closeQuietly(connection);
}
}
}

Expand Down

0 comments on commit 287d743

Please sign in to comment.