Skip to content

Commit 713f4f2

Browse files
committed
Polish "Fix broken AnsiOutput.detectIfAnsiCapable on JDK22"
See gh-40172
1 parent 1f9b62b commit 713f4f2

File tree

2 files changed

+5
-5
lines changed
  • spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi
  • spring-boot-tests/spring-boot-integration-tests/spring-boot-console-tests/src/intTest/java/org/springframework/boot/console

2 files changed

+5
-5
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiOutput.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ private static boolean detectIfAnsiCapable() {
157157
return false;
158158
}
159159
if (consoleAvailable == null) {
160-
Console c = System.console();
161-
if (c == null) {
160+
Console console = System.console();
161+
if (console == null) {
162162
return false;
163163
}
164164
Method isTerminalMethod = ClassUtils.getMethodIfAvailable(Console.class, "isTerminal");
165165
if (isTerminalMethod != null) {
166-
Boolean isTerminal = (Boolean) isTerminalMethod.invoke(c);
166+
Boolean isTerminal = (Boolean) isTerminalMethod.invoke(console);
167167
if (Boolean.FALSE.equals(isTerminal)) {
168168
return false;
169169
}

spring-boot-tests/spring-boot-integration-tests/spring-boot-console-tests/src/intTest/java/org/springframework/boot/console/ConsoleIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ConsoleIntegrationTests {
5454
void runJarOn17() {
5555
try (GenericContainer<?> container = createContainer(JDK_17_RUNTIME)) {
5656
container.start();
57-
assertThat(this.output.toString(StandardCharsets.ISO_8859_1)).contains("System.console() is null")
57+
assertThat(this.output.toString(StandardCharsets.UTF_8)).contains("System.console() is null")
5858
.doesNotContain(ENCODE_START);
5959
}
6060
}
@@ -63,7 +63,7 @@ void runJarOn17() {
6363
void runJarOn22() {
6464
try (GenericContainer<?> container = createContainer(JDK_22_RUNTIME)) {
6565
container.start();
66-
assertThat(this.output.toString(StandardCharsets.ISO_8859_1)).doesNotContain("System.console() is null")
66+
assertThat(this.output.toString(StandardCharsets.UTF_8)).doesNotContain("System.console() is null")
6767
.doesNotContain(ENCODE_START);
6868
}
6969
}

0 commit comments

Comments
 (0)