Skip to content

Commit 57f5722

Browse files
authored
Clean up static web server in sql-client tests (#49187) (#49197)
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 bc6a9de commit 57f5722

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ public static void init() throws Exception {
5353

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

6063
public void testBinaryRequestEnabled() throws Exception {

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ public static void init() throws Exception {
5959

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

6669
public void testBinaryRequestForCLIEnabled() throws URISyntaxException {
@@ -146,7 +149,7 @@ private void assertBinaryRequestForDrivers(boolean isBinary, XContentType xConte
146149
HttpClient httpClient = new HttpClient(conCfg);
147150

148151
Mode mode = randomFrom(Mode.JDBC, Mode.ODBC);
149-
SqlQueryRequest request = new SqlQueryRequest(query,
152+
SqlQueryRequest request = new SqlQueryRequest(query,
150153
null,
151154
ZoneId.of("Z"),
152155
randomIntBetween(1, 100),

0 commit comments

Comments
 (0)