mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Polish "Fix broken AnsiOutput.detectIfAnsiCapable on JDK22"
See gh-40172
This commit is contained in:
parent
1f9b62b122
commit
713f4f2292
|
@ -157,13 +157,13 @@ public abstract class AnsiOutput {
|
|||
return false;
|
||||
}
|
||||
if (consoleAvailable == null) {
|
||||
Console c = System.console();
|
||||
if (c == null) {
|
||||
Console console = System.console();
|
||||
if (console == null) {
|
||||
return false;
|
||||
}
|
||||
Method isTerminalMethod = ClassUtils.getMethodIfAvailable(Console.class, "isTerminal");
|
||||
if (isTerminalMethod != null) {
|
||||
Boolean isTerminal = (Boolean) isTerminalMethod.invoke(c);
|
||||
Boolean isTerminal = (Boolean) isTerminalMethod.invoke(console);
|
||||
if (Boolean.FALSE.equals(isTerminal)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class ConsoleIntegrationTests {
|
|||
void runJarOn17() {
|
||||
try (GenericContainer<?> container = createContainer(JDK_17_RUNTIME)) {
|
||||
container.start();
|
||||
assertThat(this.output.toString(StandardCharsets.ISO_8859_1)).contains("System.console() is null")
|
||||
assertThat(this.output.toString(StandardCharsets.UTF_8)).contains("System.console() is null")
|
||||
.doesNotContain(ENCODE_START);
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class ConsoleIntegrationTests {
|
|||
void runJarOn22() {
|
||||
try (GenericContainer<?> container = createContainer(JDK_22_RUNTIME)) {
|
||||
container.start();
|
||||
assertThat(this.output.toString(StandardCharsets.ISO_8859_1)).doesNotContain("System.console() is null")
|
||||
assertThat(this.output.toString(StandardCharsets.UTF_8)).doesNotContain("System.console() is null")
|
||||
.doesNotContain(ENCODE_START);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user