Skip to content
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

Prevent nblogger from dying on errors during format. #7741

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading