Skip to content

Commit 7c27cc5

Browse files
committed
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
1 parent 491a335 commit 7c27cc5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/StandardStackTracePrinterTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ void withFrameFilter() {
263263
void withLineSeparatorUsesLineSeparator() {
264264
Throwable exception = TestException.create();
265265
StandardStackTracePrinter printer = StandardStackTracePrinter.rootLast().withLineSeparator("!");
266-
assertThatCleanedStackTraceMatches(printer, exception,
267-
standardStackTrace().replace(System.lineSeparator(), "!"));
266+
assertThatCleanedStackTraceMatches(printer, exception, standardStackTrace().replace("\n", "!"));
268267
}
269268

270269
@Test

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ void createPrinterWhenStandardRelaxedReturnsStandardPrinter() {
144144
void createPrinterWhenStandardAppliesCustomizations() {
145145
Exception exception = TestException.create();
146146
StackTrace properties = new StackTrace(null, Root.FIRST, 300, 2, true, false);
147-
StackTracePrinter printer = properties.createPrinter();
147+
StackTracePrinter printer = ((StandardStackTracePrinter) properties.createPrinter())
148+
.withLineSeparator("\n");
148149
String actual = TestException.withoutLineNumbers(printer.printStackTraceToString(exception));
149150
assertThat(actual).isEqualToNormalizingNewlines("""
150151
java.lang.RuntimeException: exception

0 commit comments

Comments
 (0)