Skip to content

Commit

Permalink
Merge pull request #133 from jenkinsci/jtnord-patch-1
Browse files Browse the repository at this point in the history
[JENKINS-39835] - Be extra defensive about Errors and Exceptions
  • Loading branch information
oleg-nenashev authored Dec 22, 2016
2 parents b50beca + ec9b5c1 commit 32674f6
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 32674f6

Please sign in to comment.