Skip to content

Commit

Permalink
Merge pull request spring-projects#44398 from typat
Browse files Browse the repository at this point in the history
* pr/44398:
  Ensure StandardStackTracePrinter respects stacktrace.root configuration property

Closes spring-projectsgh-44398
  • Loading branch information
mhalbritter committed Feb 25, 2025
2 parents bde4fb0 + 9199fec commit 2ec99a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
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

0 comments on commit 2ec99a7

Please sign in to comment.