GP-1693 protect against NPE with BlockStreamServer

This commit is contained in:
ghidra1
2022-01-24 14:37:39 -05:00
parent c39d792e9a
commit 9bf394f90a

View File

@@ -315,11 +315,12 @@ public class BlockStreamServer extends Thread {
}
else if (!(e instanceof EOFException)) { // silent on closed connection
log.error("file block stream failed from " + socket.getInetAddress() + ": " +
e.getMessage());
e.getMessage(), e);
}
}
finally {
if (!success && (registration.blockStream instanceof InputBlockStream)) {
if (!success && (registration != null) &&
(registration.blockStream instanceof InputBlockStream)) {
// ensure input stream is closed since it can be terminated by client,
// let client handle error if any
try {
@@ -337,7 +338,9 @@ public class BlockStreamServer extends Thread {
// ignore
}
}
registration.state = HandlerConnectionState.CLOSED;
if (registration != null) {
registration.state = HandlerConnectionState.CLOSED;
}
}
}