Skip to content

Commit

Permalink
Avoid NPE in MultiNodePipelineBase.java
Browse files Browse the repository at this point in the history
should get connection first and then create new pipeline queue, otherwise it would cause NPE when timeout for getting connection and call sync() method
  • Loading branch information
stillerrr committed Jan 26, 2024
1 parent 152d2d4 commit 04ecc41
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/redis/clients/jedis/MultiNodePipelineBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ protected final <T> Response<T> appendCommand(CommandObject<T> commandObject) {
queue = pipelinedResponses.get(nodeKey);
connection = connections.get(nodeKey);
} else {
pipelinedResponses.putIfAbsent(nodeKey, new LinkedList<>());
queue = pipelinedResponses.get(nodeKey);

Connection newOne = getConnection(nodeKey);
connections.putIfAbsent(nodeKey, newOne);
connection = connections.get(nodeKey);
if (connection != newOne) {
log.debug("Duplicate connection to {}, closing it.", nodeKey);
IOUtils.closeQuietly(newOne);
}

pipelinedResponses.putIfAbsent(nodeKey, new LinkedList<>());
queue = pipelinedResponses.get(nodeKey);
}

connection.sendCommand(commandObject.getArguments());
Expand Down

0 comments on commit 04ecc41

Please sign in to comment.