-
-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-39835] - Be extra defensive about Errors and Exceptions #133
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Easier and probably safer to set a |
||
recvKey.cancel(); | ||
onRecvClosed(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose this code should rethrow errors afterwards There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was not doing it before the change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was not catching There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it does that you could kill the thread / leave the system in a bad state. |
||
} | ||
recvKey.cancel(); | ||
onRecvClosed(); | ||
} finally { | ||
release(recv); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole block could be written more simply as
without any real loss.