Skip to content

Commit 5c6140f

Browse files
committed
Merge branch '3.2.x'
Closes gh-39824
2 parents 2f99c19 + 8efdc1e commit 5c6140f

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
toolchain: false
2121
- version: 21
2222
toolchain: true
23+
- version: 22
24+
toolchain: true
2325
exclude:
2426
- os:
2527
name: Linux

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,8 @@
2525
import org.junit.jupiter.api.io.TempDir;
2626
import org.slf4j.MDC;
2727

28+
import org.springframework.boot.ansi.AnsiOutput;
29+
import org.springframework.boot.ansi.AnsiOutput.Enabled;
2830
import org.springframework.util.StringUtils;
2931

3032
import static org.assertj.core.api.Assertions.contentOf;
@@ -42,18 +44,39 @@ public abstract class AbstractLoggingSystemTests {
4244

4345
private String originalTempDirectory;
4446

47+
private AnsiOutput.Enabled ansiOutputEnabled;
48+
4549
@BeforeEach
46-
void configureTempDir(@TempDir Path temp) {
50+
void beforeEach(@TempDir Path temp) {
51+
disableAnsiOutput();
52+
configureTempDir(temp);
53+
}
54+
55+
private void disableAnsiOutput() {
56+
this.ansiOutputEnabled = AnsiOutput.getEnabled();
57+
AnsiOutput.setEnabled(Enabled.NEVER);
58+
}
59+
60+
private void configureTempDir(@TempDir Path temp) {
4761
this.originalTempDirectory = System.getProperty(JAVA_IO_TMPDIR);
4862
System.setProperty(JAVA_IO_TMPDIR, temp.toAbsolutePath().toString());
4963
MDC.clear();
5064
}
5165

5266
@AfterEach
53-
void reinstateTempDir() {
67+
void afterEach() {
68+
reinstateTempDir();
69+
restoreAnsiOutputEnabled();
70+
}
71+
72+
private void reinstateTempDir() {
5473
System.setProperty(JAVA_IO_TMPDIR, this.originalTempDirectory);
5574
}
5675

76+
private void restoreAnsiOutputEnabled() {
77+
AnsiOutput.setEnabled(this.ansiOutputEnabled);
78+
}
79+
5780
@AfterEach
5881
void clear() {
5982
for (LoggingSystemProperty property : LoggingSystemProperty.values()) {

0 commit comments

Comments
 (0)