Skip to content

Commit 52a10e1

Browse files
authored
Newly disconnected connections are set as broken (#3381)
* Address+Fix #3353
1 parent e0f0357 commit 52a10e1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/main/java/redis/clients/jedis/Connection.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,21 @@ public void connect() throws JedisConnectionException {
190190

191191
outputStream = new RedisOutputStream(socket.getOutputStream());
192192
inputStream = new RedisInputStream(socket.getInputStream());
193+
194+
broken = false; // unset broken status when connection is (re)initialized
195+
193196
} catch (JedisConnectionException jce) {
194-
broken = true;
197+
198+
setBroken();
195199
throw jce;
200+
196201
} catch (IOException ioe) {
197-
broken = true;
202+
203+
setBroken();
198204
throw new JedisConnectionException("Failed to create input/output stream", ioe);
205+
199206
} finally {
207+
200208
if (broken) {
201209
IOUtils.closeQuietly(socket);
202210
}
@@ -228,10 +236,10 @@ public void disconnect() {
228236
outputStream.flush();
229237
socket.close();
230238
} catch (IOException ex) {
231-
broken = true;
232239
throw new JedisConnectionException(ex);
233240
} finally {
234241
IOUtils.closeQuietly(socket);
242+
setBroken();
235243
}
236244
}
237245
}

0 commit comments

Comments
 (0)