Skip to content

Commit

Permalink
Merge pull request #7741 from sdedic/sdedic/fix-stuck-nblogger
Browse files Browse the repository at this point in the history
Prevent nblogger from dying on errors during format.
  • Loading branch information
sdedic authored Sep 12, 2024
2 parents 1f07376 + 8aef7e4 commit 7bdf651
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,21 @@ public String format(java.util.logging.LogRecord record) {
}

private void print(StringBuilder sb, LogRecord record, Set<Throwable> beenThere) {
String message = formatMessage(record);
String message;
try {
message = formatMessage(record);
} catch (ThreadDeath td) {
throw td;
} catch (Throwable t) {
message = record.getMessage();
sb.append("*** Error occured during formatting of message: ");
sb.append(lineSeparator);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
sb.append(sw.toString());
sb.append(lineSeparator);
}
if (message != null && message.indexOf('\n') != -1 && record.getThrown() == null) {
// multi line messages print witout any wrappings
sb.append(message);
Expand Down

0 comments on commit 7bdf651

Please sign in to comment.