Skip to content

Commit

Permalink
[CONJ-539] better message when server close connection
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Oct 15, 2017
1 parent fde60c1 commit 8c59138
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Expand Up @@ -191,7 +191,8 @@ private void readBlocking(byte[] arr, int length) throws IOException {
do {
int count = inputStream.read(arr, off, remaining);
if (count < 0) {
throw new EOFException("unexpected end of stream, read " + (length - remaining) + " bytes from " + length);
throw new EOFException("unexpected end of stream, read " + (length - remaining) + " bytes from " + length
+ " (socket was closed by server)");
}
remaining -= count;
off += count;
Expand Down
Expand Up @@ -237,7 +237,7 @@ public byte[] getPacketArray(boolean reUsable) throws IOException {
do {
int count = inputStream.read(header, off, remaining);
if (count < 0) {
throw new EOFException("unexpected end of stream, read " + off + " bytes from 4");
throw new EOFException("unexpected end of stream, read " + off + " bytes from 4 (socket was closed by server)");
}
remaining -= count;
off += count;
Expand All @@ -260,7 +260,8 @@ public byte[] getPacketArray(boolean reUsable) throws IOException {
do {
int count = inputStream.read(rawBytes, off, remaining);
if (count < 0) {
throw new EOFException("unexpected end of stream, read " + (lastPacketLength - remaining) + " bytes from " + lastPacketLength);
throw new EOFException("unexpected end of stream, read " + (lastPacketLength - remaining) + " bytes from " + lastPacketLength
+ " (socket was closed by server)");
}
remaining -= count;
off += count;
Expand Down
Expand Up @@ -1756,7 +1756,7 @@ public SQLException handleIoException(IOException initialException) {
try {
connect();
} catch (SQLException queryException) {
return new SQLNonTransientConnectionException("Could not send query: " + initialException.getMessage()
return new SQLNonTransientConnectionException(initialException.getMessage()
+ "\nError during reconnection" + getTraces(), CONNECTION_EXCEPTION.getSqlState(), initialException);
}

Expand All @@ -1771,7 +1771,7 @@ public SQLException handleIoException(IOException initialException) {
+ writer.getMaxAllowedPacket() + ")" + getTraces(), UNDEFINED_SQLSTATE.getSqlState(), initialException);
}

return new SQLException("Could not send query: " + initialException.getMessage() + getTraces(),
return new SQLException(initialException.getMessage() + getTraces(),
driverPreventError ? UNDEFINED_SQLSTATE.getSqlState() : CONNECTION_EXCEPTION.getSqlState(), initialException);

}
Expand Down

0 comments on commit 8c59138

Please sign in to comment.