From 7c27cc52ee59fcca01965ee227d79ff4412f391b Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 11 Feb 2025 09:43:59 +0000 Subject: [PATCH] Try to fix Windows build failures Text blocks use \n as their separator on all platforms. Update withLineSeparatorUsesLineSeparator() to replace \n rather than System.lineSeparator() createPrinterWhenStandardAppliesCustomizations() limits the length of the output. On Windows, the default \r\n line separator uses an extra byte per separator compared to \n. Configure the printer to use \n as a line separator so that non-whitespace output is the same on all platforms. See gh-43864 --- .../boot/logging/StandardStackTracePrinterTests.java | 3 +-- .../structured/StructuredLoggingJsonPropertiesTests.java | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/StandardStackTracePrinterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/StandardStackTracePrinterTests.java index 3cd1012860..3150f15787 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/StandardStackTracePrinterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/StandardStackTracePrinterTests.java @@ -263,8 +263,7 @@ class StandardStackTracePrinterTests { void withLineSeparatorUsesLineSeparator() { Throwable exception = TestException.create(); StandardStackTracePrinter printer = StandardStackTracePrinter.rootLast().withLineSeparator("!"); - assertThatCleanedStackTraceMatches(printer, exception, - standardStackTrace().replace(System.lineSeparator(), "!")); + assertThatCleanedStackTraceMatches(printer, exception, standardStackTrace().replace("\n", "!")); } @Test diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/structured/StructuredLoggingJsonPropertiesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/structured/StructuredLoggingJsonPropertiesTests.java index 7b3a370c50..7bd10b42f1 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/structured/StructuredLoggingJsonPropertiesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/structured/StructuredLoggingJsonPropertiesTests.java @@ -144,7 +144,8 @@ class StructuredLoggingJsonPropertiesTests { void createPrinterWhenStandardAppliesCustomizations() { Exception exception = TestException.create(); StackTrace properties = new StackTrace(null, Root.FIRST, 300, 2, true, false); - StackTracePrinter printer = properties.createPrinter(); + StackTracePrinter printer = ((StandardStackTracePrinter) properties.createPrinter()) + .withLineSeparator("\n"); String actual = TestException.withoutLineNumbers(printer.printStackTraceToString(exception)); assertThat(actual).isEqualToNormalizingNewlines(""" java.lang.RuntimeException: exception