Skip to content

Commit

Permalink
Polish "Fix broken AnsiOutput.detectIfAnsiCapable on JDK22"
Browse files Browse the repository at this point in the history
  • Loading branch information
mhalbritter committed May 2, 2024
1 parent 1f9b62b commit 713f4f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ private static boolean detectIfAnsiCapable() {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -63,7 +63,7 @@ void runJarOn17() {
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);
}
}
Expand Down

0 comments on commit 713f4f2

Please sign in to comment.