Skip to content

Commit 213d2da

Browse files
authored
Clean up static web server in sql-client tests (#49187)
The JdbcHttpClientRequestTests and HttpClientRequestTests classes both hold a static reference to a mock web server that internally uses the JDKs built-in HttpServer, which resides in a sun package that the RamUsageEstimator does not have access to. This causes builds that use a runtime of Java 8 to fail since the StaticFieldsInvariantRule is run when Java 8 is used. Relates #41526 Relates #49105
1 parent 2234090 commit 213d2da

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

x-pack/plugin/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/JdbcHttpClientRequestTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ public static void init() throws Exception {
5353

5454
@AfterClass
5555
public static void cleanup() {
56-
webServer.close();
56+
try {
57+
webServer.close();
58+
} finally {
59+
webServer = null;
60+
}
5761
}
5862

5963
public void testBinaryRequestEnabled() throws Exception {

x-pack/plugin/sql/sql-client/src/test/java/org/elasticsearch/xpack/sql/client/HttpClientRequestTests.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ public static void init() throws Exception {
5959

6060
@AfterClass
6161
public static void cleanup() {
62-
webServer.close();
62+
try {
63+
webServer.close();
64+
} finally {
65+
webServer = null;
66+
}
6367
}
6468

6569
public void testBinaryRequestForCLIEnabled() throws URISyntaxException {
@@ -145,7 +149,7 @@ private void assertBinaryRequestForDrivers(boolean isBinary, XContentType xConte
145149
HttpClient httpClient = new HttpClient(conCfg);
146150

147151
Mode mode = randomFrom(Mode.JDBC, Mode.ODBC);
148-
SqlQueryRequest request = new SqlQueryRequest(query,
152+
SqlQueryRequest request = new SqlQueryRequest(query,
149153
null,
150154
ZoneId.of("Z"),
151155
randomIntBetween(1, 100),

0 commit comments

Comments
 (0)