Browse Source

Merge pull request #44398 from typat

* pr/44398:
  Ensure StandardStackTracePrinter respects stacktrace.root configuration property

Closes gh-44398
pull/44432/head
Moritz Halbritter 11 months ago
parent
commit
2ec99a7591
  1. 2
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonProperties.java
  2. 14
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/structured/StructuredLoggingJsonPropertiesTests.java

2
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonProperties.java

@ -120,7 +120,7 @@ record StructuredLoggingJsonProperties(Set<String> include, Set<String> exclude, @@ -120,7 +120,7 @@ record StructuredLoggingJsonProperties(Set<String> include, Set<String> exclude,
}
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);

14
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/structured/StructuredLoggingJsonPropertiesTests.java

@ -152,12 +152,11 @@ class StructuredLoggingJsonPropertiesTests { @@ -152,12 +152,11 @@ class StructuredLoggingJsonPropertiesTests {
.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
@ -184,8 +183,7 @@ class StructuredLoggingJsonPropertiesTests { @@ -184,8 +183,7 @@ class StructuredLoggingJsonPropertiesTests {
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

Loading…
Cancel
Save