Skip to content
Permalink
Browse files

Be extra defensive about Errors and Exceptions

[JENKINS-39835] Be even more defensive then against leaving connections dangling.
  • Loading branch information
jtnord committed Nov 17, 2016
1 parent 35223f3 commit ec9b5c13b879f44c04fa28ee6c8b113a165c9e57
Showing with 11 additions and 7 deletions.
  1. +11 −7 src/main/java/org/jenkinsci/remoting/protocol/impl/NIONetworkLayer.java
@@ -177,15 +177,19 @@ public void ready(boolean accept, boolean connect, boolean read, boolean write)
}
recvKey.cancel();
onRecvClosed();
} catch (RuntimeException e) {
} catch (Throwable t) {
// this should *never* happen... but just in case it does we will log & close connection
if (LOGGER.isLoggable(Level.WARNING)) {
LogRecord record = new LogRecord(Level.WARNING, "[{0}] Uncaught {1}");
record.setThrown(e);
record.setParameters(new Object[]{stack().name(), e.getClass().getSimpleName()});
try {
if (LOGGER.isLoggable(Level.SEVERE)) {
LogRecord record = new LogRecord(Level.SEVERE, "[{0}] Uncaught {1}");
record.setThrown(t);
record.setParameters(new Object[]{stack().name(), t.getClass().getSimpleName()});
}
} finally {
// incase this was an OOMErr and logging caused another OOMErr
recvKey.cancel();
onRecvClosed();
}
recvKey.cancel();
onRecvClosed();
} finally {
release(recv);
}

0 comments on commit ec9b5c1

Please sign in to comment.