diff --git a/CHANGELOG.md b/CHANGELOG.md index c81586548d210..cbed5a95c5d6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Bump `org.xerial.snappy:snappy-java` from 1.1.10.6 to 1.1.10.7 ([#16665](https://github.com/opensearch-project/OpenSearch/pull/16665)) - Bump `codecov/codecov-action` from 4 to 5 ([#16667](https://github.com/opensearch-project/OpenSearch/pull/16667)) - Bump `org.apache.logging.log4j:log4j-core` from 2.24.1 to 2.24.2 ([#16718](https://github.com/opensearch-project/OpenSearch/pull/16718)) +- Bump Apache HttpCore5/HttpClient5 dependencies from 5.2.5/5.3.1 to 5.3.1/5.4.1 to support ExtendedSocketOption in HttpAsyncClient ([#16757](https://github.com/opensearch-project/OpenSearch/pull/16757)) ### Changed - Indexed IP field supports `terms_query` with more than 1025 IP masks [#16391](https://github.com/opensearch-project/OpenSearch/pull/16391) diff --git a/client/rest/licenses/httpclient5-5.3.1.jar.sha1 b/client/rest/licenses/httpclient5-5.3.1.jar.sha1 deleted file mode 100644 index c8f32c1ec23a1..0000000000000 --- a/client/rest/licenses/httpclient5-5.3.1.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -56b53c8f4bcdaada801d311cf2ff8a24d6d96883 \ No newline at end of file diff --git a/client/rest/licenses/httpclient5-5.4.1.jar.sha1 b/client/rest/licenses/httpclient5-5.4.1.jar.sha1 new file mode 100644 index 0000000000000..3a4fec6e8afc7 --- /dev/null +++ b/client/rest/licenses/httpclient5-5.4.1.jar.sha1 @@ -0,0 +1 @@ +ce913081e592ee8eeee35c4e577d7dce13cba7a4 diff --git a/client/rest/licenses/httpcore5-5.2.5.jar.sha1 b/client/rest/licenses/httpcore5-5.2.5.jar.sha1 deleted file mode 100644 index ca97e8612ea39..0000000000000 --- a/client/rest/licenses/httpcore5-5.2.5.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -dab1e18842971a45ca8942491ce005ab86a028d7 \ No newline at end of file diff --git a/client/rest/licenses/httpcore5-5.3.1.jar.sha1 b/client/rest/licenses/httpcore5-5.3.1.jar.sha1 new file mode 100644 index 0000000000000..90f194e770368 --- /dev/null +++ b/client/rest/licenses/httpcore5-5.3.1.jar.sha1 @@ -0,0 +1 @@ +eaf64237945d7d0f301d48420e8bdb7f565a7b0e diff --git a/client/rest/licenses/httpcore5-h2-5.2.5.jar.sha1 b/client/rest/licenses/httpcore5-h2-5.2.5.jar.sha1 deleted file mode 100644 index bb40fe65854f6..0000000000000 --- a/client/rest/licenses/httpcore5-h2-5.2.5.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -09425df4d1365cee86a8e031a036bdca4343da4b \ No newline at end of file diff --git a/client/rest/licenses/httpcore5-h2-5.3.1.jar.sha1 b/client/rest/licenses/httpcore5-h2-5.3.1.jar.sha1 new file mode 100644 index 0000000000000..bc122991af736 --- /dev/null +++ b/client/rest/licenses/httpcore5-h2-5.3.1.jar.sha1 @@ -0,0 +1 @@ +760c34db3ba41b0ffa07e956bc308d3a12356915 diff --git a/client/rest/licenses/httpcore5-reactive-5.2.5.jar.sha1 b/client/rest/licenses/httpcore5-reactive-5.2.5.jar.sha1 deleted file mode 100644 index ab9241fc93d45..0000000000000 --- a/client/rest/licenses/httpcore5-reactive-5.2.5.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -f68949965075b957c12b4c1ef89fd4bab2a0fdb1 \ No newline at end of file diff --git a/client/rest/licenses/httpcore5-reactive-5.3.1.jar.sha1 b/client/rest/licenses/httpcore5-reactive-5.3.1.jar.sha1 new file mode 100644 index 0000000000000..cb71833aad877 --- /dev/null +++ b/client/rest/licenses/httpcore5-reactive-5.3.1.jar.sha1 @@ -0,0 +1 @@ +c4c0c3c7bbcb0db54aa7ddd39e34a835428c99c0 diff --git a/client/rest/src/test/java/org/opensearch/client/RestClientBuilderTests.java b/client/rest/src/test/java/org/opensearch/client/RestClientBuilderTests.java index 7165174e688e1..2560dec53b512 100644 --- a/client/rest/src/test/java/org/opensearch/client/RestClientBuilderTests.java +++ b/client/rest/src/test/java/org/opensearch/client/RestClientBuilderTests.java @@ -37,6 +37,7 @@ import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.message.BasicHeader; +import org.apache.hc.core5.reactor.IOReactorConfig; import org.apache.hc.core5.util.Timeout; import java.io.IOException; @@ -143,6 +144,12 @@ public void testBuild() throws IOException { builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() { @Override public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) { + IOReactorConfig.Builder iOReactorConfig = IOReactorConfig.custom(); + iOReactorConfig.setTcpKeepCount(randomIntBetween(5, 10)); + iOReactorConfig.setTcpKeepInterval(randomIntBetween(5, 10)); + iOReactorConfig.setTcpKeepIdle(randomIntBetween(100, 200)); + iOReactorConfig.setIoThreadCount(2); + httpClientBuilder.setIOReactorConfig(iOReactorConfig.build()); return httpClientBuilder; } }); diff --git a/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java b/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java index de04dd843b2db..880f5c8a833e6 100644 --- a/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java +++ b/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostIntegTests.java @@ -65,6 +65,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -377,8 +378,20 @@ public void testRequestResetAndAbort() throws Exception { * Exercises the test http server ability to send back whatever headers it received. */ public void testHeaders() throws Exception { + // https://github.com/apache/httpcomponents-client/pull/542 + Set upgradableMethods = new HashSet<>(Arrays.asList("HEAD", "OPTIONS", "GET")); for (String method : getHttpMethods()) { - final Set standardHeaders = new HashSet<>(Arrays.asList("Connection", "Host", "User-agent", "Date")); + final List standardHeaders = new ArrayList<>(); + standardHeaders.add("Connection"); + if (upgradableMethods.contains(method)) { + standardHeaders.add("Connection"); + } + standardHeaders.add("Host"); + standardHeaders.add("User-agent"); + if (upgradableMethods.contains(method)) { + standardHeaders.add("Upgrade"); + } + standardHeaders.add("Date"); if (method.equals("HEAD") == false) { standardHeaders.add("Content-length"); } diff --git a/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostTests.java b/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostTests.java index 1d57fe2c8dcab..5b6eee18fb2ee 100644 --- a/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostTests.java +++ b/client/rest/src/test/java/org/opensearch/client/RestClientSingleHostTests.java @@ -482,7 +482,7 @@ public void testHeaders() throws Exception { esResponse = e.getResponse(); } assertThat(esResponse.getStatusLine().getStatusCode(), equalTo(statusCode)); - assertHeaders(defaultHeaders, requestHeaders, esResponse.getHeaders(), Collections.emptySet()); + assertHeaders(defaultHeaders, requestHeaders, esResponse.getHeaders(), Collections.emptyList()); assertFalse(esResponse.hasWarnings()); } } diff --git a/client/rest/src/test/java/org/opensearch/client/documentation/RestClientDocumentation.java b/client/rest/src/test/java/org/opensearch/client/documentation/RestClientDocumentation.java index 42c31864e0578..c78642631fe37 100644 --- a/client/rest/src/test/java/org/opensearch/client/documentation/RestClientDocumentation.java +++ b/client/rest/src/test/java/org/opensearch/client/documentation/RestClientDocumentation.java @@ -376,6 +376,24 @@ public HttpAsyncClientBuilder customizeHttpClient( }); //end::rest-client-config-threads } + { + //tag::rest-client-config-tcpKeepIdle/tcpKeepInterval/tcpKeepCount + RestClientBuilder builder = RestClient.builder( + new HttpHost("localhost", 9200)) + .setHttpClientConfigCallback(new HttpClientConfigCallback() { + @Override + public HttpAsyncClientBuilder customizeHttpClient( + HttpAsyncClientBuilder httpClientBuilder) { + return httpClientBuilder.setIOReactorConfig( + IOReactorConfig.custom() + .setTcpKeepIdle(200) + .setTcpKeepInterval(10) + .setTcpKeepCount(10) + .build()); + } + }); + //end::rest-client-config-tcpKeepIdle/tcpKeepInterval/tcpKeepCount + } { //tag::rest-client-config-basic-auth final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider(); diff --git a/client/sniffer/licenses/httpclient5-5.3.1.jar.sha1 b/client/sniffer/licenses/httpclient5-5.3.1.jar.sha1 deleted file mode 100644 index c8f32c1ec23a1..0000000000000 --- a/client/sniffer/licenses/httpclient5-5.3.1.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -56b53c8f4bcdaada801d311cf2ff8a24d6d96883 \ No newline at end of file diff --git a/client/sniffer/licenses/httpclient5-5.4.1.jar.sha1 b/client/sniffer/licenses/httpclient5-5.4.1.jar.sha1 new file mode 100644 index 0000000000000..3a4fec6e8afc7 --- /dev/null +++ b/client/sniffer/licenses/httpclient5-5.4.1.jar.sha1 @@ -0,0 +1 @@ +ce913081e592ee8eeee35c4e577d7dce13cba7a4 diff --git a/client/sniffer/licenses/httpcore5-5.2.5.jar.sha1 b/client/sniffer/licenses/httpcore5-5.2.5.jar.sha1 deleted file mode 100644 index ca97e8612ea39..0000000000000 --- a/client/sniffer/licenses/httpcore5-5.2.5.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -dab1e18842971a45ca8942491ce005ab86a028d7 \ No newline at end of file diff --git a/client/sniffer/licenses/httpcore5-5.3.1.jar.sha1 b/client/sniffer/licenses/httpcore5-5.3.1.jar.sha1 new file mode 100644 index 0000000000000..90f194e770368 --- /dev/null +++ b/client/sniffer/licenses/httpcore5-5.3.1.jar.sha1 @@ -0,0 +1 @@ +eaf64237945d7d0f301d48420e8bdb7f565a7b0e diff --git a/client/test/src/main/java/org/opensearch/client/RestClientTestCase.java b/client/test/src/main/java/org/opensearch/client/RestClientTestCase.java index b4eacdbf88827..2b851cb2daa68 100644 --- a/client/test/src/main/java/org/opensearch/client/RestClientTestCase.java +++ b/client/test/src/main/java/org/opensearch/client/RestClientTestCase.java @@ -81,7 +81,7 @@ protected static void assertHeaders( final Header[] defaultHeaders, final Header[] requestHeaders, final Header[] actualHeaders, - final Set ignoreHeaders + final List ignoreHeaders ) { final Map> expectedHeaders = new HashMap<>(); final Set requestHeaderKeys = new HashSet<>(); @@ -96,7 +96,7 @@ protected static void assertHeaders( addValueToListEntry(expectedHeaders, name, defaultHeader.getValue()); } } - Set actualIgnoredHeaders = new HashSet<>(); + List actualIgnoredHeaders = new ArrayList<>(); for (Header responseHeader : actualHeaders) { final String name = responseHeader.getName(); if (ignoreHeaders.contains(name)) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4e8aee298345a..469950c46fb49 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -40,8 +40,8 @@ reactor_netty = "1.1.23" reactor = "3.5.20" # client dependencies -httpclient5 = "5.3.1" -httpcore5 = "5.2.5" +httpclient5 = "5.4.1" +httpcore5 = "5.3.1" httpclient = "4.5.14" httpcore = "4.4.16" httpasyncclient = "4.1.5"