Skip to content

Commit 2ec99a7

Browse files
committed
Merge pull request #44398 from typat
* pr/44398: Ensure StandardStackTracePrinter respects stacktrace.root configuration property Closes gh-44398
2 parents bde4fb0 + 9199fec commit 2ec99a7

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Diff for: spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonProperties.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private boolean hasAnyOtherProperty() {
120120
}
121121

122122
private StandardStackTracePrinter createStandardPrinter() {
123-
StandardStackTracePrinter printer = (root() != Root.FIRST) ? StandardStackTracePrinter.rootFirst()
123+
StandardStackTracePrinter printer = (root() == Root.FIRST) ? StandardStackTracePrinter.rootFirst()
124124
: StandardStackTracePrinter.rootLast();
125125
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
126126
printer = map.from(this::maxLength).to(printer, StandardStackTracePrinter::withMaximumLength);

Diff for: spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/structured/StructuredLoggingJsonPropertiesTests.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,11 @@ void createPrinterWhenStandardAppliesCustomizations() {
152152
.withLineSeparator("\n");
153153
String actual = TestException.withoutLineNumbers(printer.printStackTraceToString(exception));
154154
assertThat(actual).isEqualToNormalizingNewlines("""
155-
java.lang.RuntimeException: exception
156-
at org.springframework.boot.logging.TestException.actualCreateException(TestException.java:NN)
157-
at org.springframework.boot.logging.TestException.createException(TestException.java:NN)
158-
... 2 filtered
159-
Suppressed: java.lang.RuntimeException: supressed
160-
at o...""");
155+
java.lang.RuntimeException: root
156+
at org.springframework.boot.logging.TestException.createTestException(TestException.java:NN)
157+
at org.springframework.boot.logging.TestException$CreatorThread.run(TestException.java:NN)
158+
Wrapped by: java.lang.RuntimeException: cause
159+
at org.springframework.boot.log...""");
161160
}
162161

163162
@Test
@@ -184,8 +183,7 @@ void createPrinterWhenClassNameInjectsConfiguredPrinter() {
184183
true, null);
185184
StackTracePrinter printer = properties.createPrinter();
186185
String actual = TestException.withoutLineNumbers(printer.printStackTraceToString(exception));
187-
assertThat(actual).isEqualTo("RuntimeExceptionexception! at org.spr...");
188-
186+
assertThat(actual).isEqualTo("RuntimeExceptionroot! at org.springfr...");
189187
}
190188

191189
@Test

0 commit comments

Comments
 (0)