From 479326f68bf23d40b29ef045dd813eed66de0103 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 29 Jun 2017 09:41:58 -0400 Subject: [PATCH] Appease the forbidden APIs task Original commit: elastic/x-pack-elasticsearch@4a392aa1102815eafde28c22fab3d7dd5cef2014 --- .../xpack/sql/cli/net/protocol/InfoRequest.java | 15 +++++++++------ .../xpack/sql/cli/net/client/CliHttpClient.java | 2 +- .../xpack/sql/jdbc/net/protocol/InfoRequest.java | 16 +++++++++------- .../sql/jdbc/net/client/JdbcHttpClient.java | 2 +- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/sql-clients/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoRequest.java b/sql-clients/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoRequest.java index 3a8019854f3..77798ef10e4 100644 --- a/sql-clients/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoRequest.java +++ b/sql-clients/cli-proto/src/main/java/org/elasticsearch/xpack/sql/cli/net/protocol/InfoRequest.java @@ -17,13 +17,16 @@ public class InfoRequest extends Request { public final String jvmVersion, jvmVendor, jvmClassPath, osName, osVersion; - public InfoRequest(Properties props) { + /** + * Build the info request containing information about the current JVM. + */ + public InfoRequest() { super(Action.INFO); - jvmVersion = props.getProperty("java.version", EMPTY); - jvmVendor = props.getProperty("java.vendor", EMPTY); - jvmClassPath = props.getProperty("java.class.path", EMPTY); - osName = props.getProperty("os.name", EMPTY); - osVersion = props.getProperty("os.version", EMPTY); + jvmVersion = System.getProperty("java.version", EMPTY); + jvmVendor = System.getProperty("java.vendor", EMPTY); + jvmClassPath = System.getProperty("java.class.path", EMPTY); + osName = System.getProperty("os.name", EMPTY); + osVersion = System.getProperty("os.version", EMPTY); } public InfoRequest(String jvmVersion, String jvmVendor, String jvmClassPath, String osName, String osVersion) { diff --git a/sql-clients/cli/src/main/java/org/elasticsearch/xpack/sql/cli/net/client/CliHttpClient.java b/sql-clients/cli/src/main/java/org/elasticsearch/xpack/sql/cli/net/client/CliHttpClient.java index 36dcfce16e4..e6557dcdaf9 100644 --- a/sql-clients/cli/src/main/java/org/elasticsearch/xpack/sql/cli/net/client/CliHttpClient.java +++ b/sql-clients/cli/src/main/java/org/elasticsearch/xpack/sql/cli/net/client/CliHttpClient.java @@ -31,7 +31,7 @@ public class CliHttpClient implements AutoCloseable { } public Response serverInfo() { - Bytes ba = http.put(out -> ProtoUtils.write(out, new InfoRequest(System.getProperties()))); + Bytes ba = http.put(out -> ProtoUtils.write(out, new InfoRequest())); return doIO(ba, in -> readResponse(in, Action.INFO)); } diff --git a/sql-clients/jdbc-proto/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/protocol/InfoRequest.java b/sql-clients/jdbc-proto/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/protocol/InfoRequest.java index 9b99d8bf43b..73cba13350d 100644 --- a/sql-clients/jdbc-proto/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/protocol/InfoRequest.java +++ b/sql-clients/jdbc-proto/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/protocol/InfoRequest.java @@ -10,20 +10,22 @@ import org.elasticsearch.xpack.sql.jdbc.net.protocol.Proto.Action; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; -import java.util.Properties; import static org.elasticsearch.xpack.sql.jdbc.net.protocol.StringUtils.EMPTY; public class InfoRequest extends Request { public final String jvmVersion, jvmVendor, jvmClassPath, osName, osVersion; - public InfoRequest(Properties props) { + /** + * Build the info request containing information about the current JVM. + */ + public InfoRequest() { super(Action.INFO); - jvmVersion = props.getProperty("java.version", EMPTY); - jvmVendor = props.getProperty("java.vendor", EMPTY); - jvmClassPath = props.getProperty("java.class.path", EMPTY); - osName = props.getProperty("os.name", EMPTY); - osVersion = props.getProperty("os.version", EMPTY); + jvmVersion = System.getProperty("java.version", EMPTY); + jvmVendor = System.getProperty("java.vendor", EMPTY); + jvmClassPath = System.getProperty("java.class.path", EMPTY); + osName = System.getProperty("os.name", EMPTY); + osVersion = System.getProperty("os.version", EMPTY); } public InfoRequest(String jvmVersion, String jvmVendor, String jvmClassPath, String osName, String osVersion) { diff --git a/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/client/JdbcHttpClient.java b/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/client/JdbcHttpClient.java index db804c7635c..a208bd92446 100644 --- a/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/client/JdbcHttpClient.java +++ b/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/client/JdbcHttpClient.java @@ -136,7 +136,7 @@ public class JdbcHttpClient implements Closeable { } private InfoResponse fetchServerInfo() throws SQLException { - BytesArray ba = http.put(out -> ProtoUtils.write(out, new InfoRequest(System.getProperties()))); + BytesArray ba = http.put(out -> ProtoUtils.write(out, new InfoRequest())); return doIO(ba, in -> readResponse(in, Action.INFO)); }