Hi experts,
From the redis.clients.jedis.Connection.java, found the code snippets below:
public void sendCommand(final ProtocolCommand cmd, final byte[]... args) {
try {
connect();
Protocol.
sendCommand(outputStream, cmd, args);
} catch (JedisConnectionException ex) {
/*
* When client send request which formed by invalid protocol, Redis send back error message
* before close connection. We try to read it to provide reason of failure.
*/
try {
String errorMessage = Protocol.
readErrorLineIfPossible(inputStream);
if (errorMessage != null && errorMessage.length() > 0) {
ex = new JedisConnectionException(errorMessage, ex.getCause());
}
} catch (Exception e) {
/*
* Catch any IOException or JedisConnectionException occurred from InputStream#read and just
* ignore. This approach is safe because reading error message is optional and connection
* will eventually be closed.
*/
}
// Any other exceptions related to connection?
broken = true;
throw ex;
}
}
On exception, the connection will be marked with broken = true. In this case, isn't the connection will be closed during the period check? And on the subsequence successful calls, why we don't reset back the broken flag to false;
Thanks,