Skip to content

Commit

Permalink
Newly disconnected connections are set as broken (#3381)
Browse files Browse the repository at this point in the history
* Address+Fix #3353
  • Loading branch information
sazzad16 committed Apr 27, 2023
1 parent e0f0357 commit 52a10e1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main/java/redis/clients/jedis/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,21 @@ public void connect() throws JedisConnectionException {

outputStream = new RedisOutputStream(socket.getOutputStream());
inputStream = new RedisInputStream(socket.getInputStream());

broken = false; // unset broken status when connection is (re)initialized

} catch (JedisConnectionException jce) {
broken = true;

setBroken();
throw jce;

} catch (IOException ioe) {
broken = true;

setBroken();
throw new JedisConnectionException("Failed to create input/output stream", ioe);

} finally {

if (broken) {
IOUtils.closeQuietly(socket);
}
Expand Down Expand Up @@ -228,10 +236,10 @@ public void disconnect() {
outputStream.flush();
socket.close();
} catch (IOException ex) {
broken = true;
throw new JedisConnectionException(ex);
} finally {
IOUtils.closeQuietly(socket);
setBroken();
}
}
}
Expand Down

0 comments on commit 52a10e1

Please sign in to comment.