Skip to content

StandardStackTracePrinter prints root first if configured otherwise #44398

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

Closed
Closed
Show file tree
Hide file tree
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 @@ -120,7 +120,7 @@ private boolean hasAnyOtherProperty() {
}

private StandardStackTracePrinter createStandardPrinter() {
StandardStackTracePrinter printer = (root() != Root.FIRST) ? StandardStackTracePrinter.rootFirst()
StandardStackTracePrinter printer = (root() == Root.FIRST) ? StandardStackTracePrinter.rootFirst()
: StandardStackTracePrinter.rootLast();
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
printer = map.from(this::maxLength).to(printer, StandardStackTracePrinter::withMaximumLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,11 @@ void createPrinterWhenStandardAppliesCustomizations() {
.withLineSeparator("\n");
String actual = TestException.withoutLineNumbers(printer.printStackTraceToString(exception));
assertThat(actual).isEqualToNormalizingNewlines("""
java.lang.RuntimeException: exception
at org.springframework.boot.logging.TestException.actualCreateException(TestException.java:NN)
at org.springframework.boot.logging.TestException.createException(TestException.java:NN)
... 2 filtered
Suppressed: java.lang.RuntimeException: supressed
at o...""");
java.lang.RuntimeException: root
at org.springframework.boot.logging.TestException.createTestException(TestException.java:NN)
at org.springframework.boot.logging.TestException$CreatorThread.run(TestException.java:NN)
Wrapped by: java.lang.RuntimeException: cause
at org.springframework.boot.log...""");
}

@Test
Expand All @@ -184,8 +183,7 @@ void createPrinterWhenClassNameInjectsConfiguredPrinter() {
true, null);
StackTracePrinter printer = properties.createPrinter();
String actual = TestException.withoutLineNumbers(printer.printStackTraceToString(exception));
assertThat(actual).isEqualTo("RuntimeExceptionexception! at org.spr...");

assertThat(actual).isEqualTo("RuntimeExceptionroot! at org.springfr...");
}

@Test
Expand Down
Loading