diff --git a/plugin/sql/sql-cli/build.gradle b/plugin/sql/sql-cli/build.gradle index 73782e25cd8..36644a54433 100644 --- a/plugin/sql/sql-cli/build.gradle +++ b/plugin/sql/sql-cli/build.gradle @@ -68,6 +68,14 @@ artifacts { nodeps nodepsJar } + +forbiddenApisMain { + signaturesURLs += file('src/forbidden/cli-signatures.txt').toURI().toURL() +} +forbiddenApisTest { + signaturesURLs += file('src/forbidden/cli-signatures.txt').toURI().toURL() +} + thirdPartyAudit.excludes = [ // jLine's optional dependencies 'org.apache.sshd.client.SshClient', diff --git a/plugin/sql/sql-cli/src/forbidden/cli-signatures.txt b/plugin/sql/sql-cli/src/forbidden/cli-signatures.txt new file mode 100644 index 00000000000..3d90ba67b03 --- /dev/null +++ b/plugin/sql/sql-cli/src/forbidden/cli-signatures.txt @@ -0,0 +1,3 @@ +@defaultMessage println doesn't pay attention to terminal type so it breaks tests on Windows. Just use \n. +java.io.PrintWriter#println() +java.io.PrintWriter#println(java.lang.String) diff --git a/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/JLineTerminal.java b/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/JLineTerminal.java index 7211bc51e59..528e44afb51 100644 --- a/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/JLineTerminal.java +++ b/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/JLineTerminal.java @@ -71,7 +71,8 @@ public class JLineTerminal implements CliTerminal { @Override public void println(String text) { - terminal.writer().println(text); + print(text); + print("\n"); } @Override @@ -86,7 +87,7 @@ public class JLineTerminal implements CliTerminal { @Override public void println() { - terminal.writer().println(); + print("\n"); } @Override @@ -168,7 +169,7 @@ public class JLineTerminal implements CliTerminal { } public void ln() { - terminal.writer().println(line.toAnsi(terminal)); + println(line.toAnsi(terminal)); } public void end() { diff --git a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/cli/EmbeddedCli.java b/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/cli/EmbeddedCli.java index e2c090dc3ae..89184edec0a 100644 --- a/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/cli/EmbeddedCli.java +++ b/qa/sql/src/main/java/org/elasticsearch/xpack/qa/sql/cli/EmbeddedCli.java @@ -25,19 +25,10 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PipedInputStream; import java.io.PipedOutputStream; -import java.io.PrintWriter; -import java.net.InetAddress; -import java.net.Socket; -import java.net.UnknownHostException; import java.nio.charset.StandardCharsets; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; import java.util.List; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Predicate; @@ -46,7 +37,6 @@ import static org.elasticsearch.test.ESTestCase.randomBoolean; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; @@ -54,7 +44,7 @@ import static org.junit.Assert.fail; /** * Wraps a CLI in as "real" a way as it can get without forking the CLI * subprocess with the goal being integration testing of the CLI without - * breaking out security model by forking. We test the script that starts + * breaking our security model by forking. We test the script that starts * the CLI using packaging tests which is super "real" but not super fast * and doesn't run super frequently. */