Browse Source

Update http-core and http-client dependencies (#46549)

* Update http-core and http-client dependencies

Relates to #45808
Closes #45577

* update shas dependencies

* update test
Luca Cavanna 6 năm trước cách đây
mục cha
commit
c512214cdc
45 tập tin đã thay đổi với 51 bổ sung35 xóa
  1. 2 2
      buildSrc/version.properties
  2. 1 0
      client/rest/licenses/httpclient-4.5.10.jar.sha1
  3. 0 1
      client/rest/licenses/httpclient-4.5.8.jar.sha1
  4. 0 1
      client/rest/licenses/httpcore-4.4.11.jar.sha1
  5. 1 0
      client/rest/licenses/httpcore-4.4.12.jar.sha1
  6. 0 1
      client/rest/licenses/httpcore-nio-4.4.11.jar.sha1
  7. 1 0
      client/rest/licenses/httpcore-nio-4.4.12.jar.sha1
  8. 17 8
      client/rest/src/test/java/org/elasticsearch/client/RestClientMultipleHostsIntegTests.java
  9. 11 4
      client/rest/src/test/java/org/elasticsearch/client/RestClientSingleHostIntegTests.java
  10. 1 0
      client/sniffer/licenses/httpclient-4.5.10.jar.sha1
  11. 0 1
      client/sniffer/licenses/httpclient-4.5.8.jar.sha1
  12. 0 1
      client/sniffer/licenses/httpcore-4.4.11.jar.sha1
  13. 1 0
      client/sniffer/licenses/httpcore-4.4.12.jar.sha1
  14. 1 0
      plugins/discovery-azure-classic/licenses/httpclient-4.5.10.jar.sha1
  15. 0 1
      plugins/discovery-azure-classic/licenses/httpclient-4.5.8.jar.sha1
  16. 0 1
      plugins/discovery-azure-classic/licenses/httpcore-4.4.11.jar.sha1
  17. 1 0
      plugins/discovery-azure-classic/licenses/httpcore-4.4.12.jar.sha1
  18. 1 0
      plugins/discovery-ec2/licenses/httpclient-4.5.10.jar.sha1
  19. 0 1
      plugins/discovery-ec2/licenses/httpclient-4.5.8.jar.sha1
  20. 0 1
      plugins/discovery-ec2/licenses/httpcore-4.4.11.jar.sha1
  21. 1 0
      plugins/discovery-ec2/licenses/httpcore-4.4.12.jar.sha1
  22. 1 0
      plugins/discovery-gce/licenses/httpclient-4.5.10.jar.sha1
  23. 0 1
      plugins/discovery-gce/licenses/httpclient-4.5.8.jar.sha1
  24. 0 1
      plugins/discovery-gce/licenses/httpcore-4.4.11.jar.sha1
  25. 1 0
      plugins/discovery-gce/licenses/httpcore-4.4.12.jar.sha1
  26. 1 0
      plugins/repository-gcs/licenses/httpclient-4.5.10.jar.sha1
  27. 0 1
      plugins/repository-gcs/licenses/httpclient-4.5.8.jar.sha1
  28. 0 1
      plugins/repository-gcs/licenses/httpcore-4.4.11.jar.sha1
  29. 1 0
      plugins/repository-gcs/licenses/httpcore-4.4.12.jar.sha1
  30. 1 0
      plugins/repository-s3/licenses/httpclient-4.5.10.jar.sha1
  31. 0 1
      plugins/repository-s3/licenses/httpclient-4.5.8.jar.sha1
  32. 0 1
      plugins/repository-s3/licenses/httpcore-4.4.11.jar.sha1
  33. 1 0
      plugins/repository-s3/licenses/httpcore-4.4.12.jar.sha1
  34. 1 0
      x-pack/plugin/core/licenses/httpclient-4.5.10.jar.sha1
  35. 0 1
      x-pack/plugin/core/licenses/httpclient-4.5.8.jar.sha1
  36. 0 1
      x-pack/plugin/core/licenses/httpcore-4.4.11.jar.sha1
  37. 1 0
      x-pack/plugin/core/licenses/httpcore-4.4.12.jar.sha1
  38. 0 1
      x-pack/plugin/core/licenses/httpcore-nio-4.4.11.jar.sha1
  39. 1 0
      x-pack/plugin/core/licenses/httpcore-nio-4.4.12.jar.sha1
  40. 1 0
      x-pack/plugin/security/licenses/httpclient-cache-4.5.10.jar.sha1
  41. 0 1
      x-pack/plugin/security/licenses/httpclient-cache-4.5.8.jar.sha1
  42. 1 0
      x-pack/snapshot-tool/licenses/httpclient-4.5.10.jar.sha1
  43. 0 1
      x-pack/snapshot-tool/licenses/httpclient-4.5.8.jar.sha1
  44. 0 1
      x-pack/snapshot-tool/licenses/httpcore-4.4.11.jar.sha1
  45. 1 0
      x-pack/snapshot-tool/licenses/httpcore-4.4.12.jar.sha1

+ 2 - 2
buildSrc/version.properties

@@ -32,8 +32,8 @@ bouncycastle      = 1.61
 # test dependencies
 randomizedrunner  = 2.7.1
 junit             = 4.12
-httpclient        = 4.5.8
-httpcore          = 4.4.11
+httpclient        = 4.5.10
+httpcore          = 4.4.12
 httpasyncclient   = 4.1.4
 commonslogging    = 1.1.3
 commonscodec      = 1.11

+ 1 - 0
client/rest/licenses/httpclient-4.5.10.jar.sha1

@@ -0,0 +1 @@
+7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

+ 0 - 1
client/rest/licenses/httpclient-4.5.8.jar.sha1

@@ -1 +0,0 @@
-c27c9d6f15435dc2b6947112027b418b0eef32b9

+ 0 - 1
client/rest/licenses/httpcore-4.4.11.jar.sha1

@@ -1 +0,0 @@
-de748cf874e4e193b42eceea9fe5574fabb9d4df

+ 1 - 0
client/rest/licenses/httpcore-4.4.12.jar.sha1

@@ -0,0 +1 @@
+21ebaf6d532bc350ba95bd81938fa5f0e511c132

+ 0 - 1
client/rest/licenses/httpcore-nio-4.4.11.jar.sha1

@@ -1 +0,0 @@
-7d0a97d01d39cff9aa3e6db81f21fddb2435f4e6

+ 1 - 0
client/rest/licenses/httpcore-nio-4.4.12.jar.sha1

@@ -0,0 +1 @@
+84cd29eca842f31db02987cfedea245af020198b

+ 17 - 8
client/rest/src/test/java/org/elasticsearch/client/RestClientMultipleHostsIntegTests.java

@@ -27,7 +27,6 @@ import org.elasticsearch.mocksocket.MockHttpServer;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 
 import java.io.IOException;
 import java.net.ConnectException;
@@ -75,6 +74,7 @@ public class RestClientMultipleHostsIntegTests extends RestClientTestCase {
         int numHttpServers = randomIntBetween(2, 4);
         httpServers = new HttpServer[numHttpServers];
         httpHosts = new HttpHost[numHttpServers];
+        waitForCancelHandler = new WaitForCancelHandler();
         for (int i = 0; i < numHttpServers; i++) {
             HttpServer httpServer = createHttpServer();
             httpServers[i] = httpServer;
@@ -99,24 +99,30 @@ public class RestClientMultipleHostsIntegTests extends RestClientTestCase {
         for (int statusCode : getAllStatusCodes()) {
             httpServer.createContext(pathPrefix + "/" + statusCode, new ResponseHandler(statusCode));
         }
-        waitForCancelHandler = new WaitForCancelHandler();
         httpServer.createContext(pathPrefix + "/wait", waitForCancelHandler);
         return httpServer;
     }
 
     private static class WaitForCancelHandler implements HttpHandler {
-        private CountDownLatch cancelHandlerLatch;
+        private volatile CountDownLatch requestCameInLatch;
+        private volatile CountDownLatch cancelHandlerLatch;
 
         void reset() {
             cancelHandlerLatch = new CountDownLatch(1);
+            requestCameInLatch = new CountDownLatch(1);
         }
 
         void cancelDone() {
             cancelHandlerLatch.countDown();
         }
 
+        void awaitRequest() throws InterruptedException {
+            requestCameInLatch.await();
+        }
+
         @Override
         public void handle(HttpExchange exchange) throws IOException {
+            requestCameInLatch.countDown();
             try {
                 cancelHandlerLatch.await();
             } catch (InterruptedException ignore) {
@@ -225,16 +231,14 @@ public class RestClientMultipleHostsIntegTests extends RestClientTestCase {
         }
     }
 
-    @Ignore("https://github.com/elastic/elasticsearch/issues/45577")
     public void testCancelAsyncRequests() throws Exception {
         int numRequests = randomIntBetween(5, 20);
-        final CountDownLatch latch = new CountDownLatch(numRequests);
         final List<Response> responses = new CopyOnWriteArrayList<>();
         final List<Exception> exceptions = new CopyOnWriteArrayList<>();
         for (int i = 0; i < numRequests; i++) {
+            CountDownLatch latch = new CountDownLatch(1);
             waitForCancelHandler.reset();
-            final String method = RestClientTestUtil.randomHttpMethod(getRandom());
-            Cancellable cancellable = restClient.performRequestAsync(new Request(method, "/wait"), new ResponseListener() {
+            Cancellable cancellable = restClient.performRequestAsync(new Request("GET", "/wait"), new ResponseListener() {
                 @Override
                 public void onSuccess(Response response) {
                     responses.add(response);
@@ -247,10 +251,15 @@ public class RestClientMultipleHostsIntegTests extends RestClientTestCase {
                     latch.countDown();
                 }
             });
+            if (randomBoolean()) {
+                //we wait for the request to get to the server-side otherwise we almost always cancel
+                // the request artificially on the client-side before even sending it
+                waitForCancelHandler.awaitRequest();
+            }
             cancellable.cancel();
             waitForCancelHandler.cancelDone();
+            assertTrue(latch.await(5, TimeUnit.SECONDS));
         }
-        assertTrue(latch.await(5, TimeUnit.SECONDS));
         assertEquals(0, responses.size());
         assertEquals(numRequests, exceptions.size());
         for (Exception exception : exceptions) {

+ 11 - 4
client/rest/src/test/java/org/elasticsearch/client/RestClientSingleHostIntegTests.java

@@ -105,7 +105,7 @@ public class RestClientSingleHostIntegTests extends RestClientTestCase {
         return httpServer;
     }
 
-    private class WaitForCancelHandler implements HttpHandler {
+    private static class WaitForCancelHandler implements HttpHandler {
 
         private final CountDownLatch cancelHandlerLatch = new CountDownLatch(1);
 
@@ -259,6 +259,8 @@ public class RestClientSingleHostIntegTests extends RestClientTestCase {
     /**
      * This test verifies some assumptions that we rely upon around the way the async http client works when reusing the same request
      * throughout multiple retries, and the use of the {@link HttpRequestBase#abort()} method.
+     * In fact the low-level REST client reuses the same request instance throughout multiple retries, and relies on the http client
+     * to set the future ref to the request properly so that when abort is called, the proper future gets cancelled.
      */
     public void testRequestResetAndAbort() throws Exception {
         try (CloseableHttpAsyncClient client = HttpAsyncClientBuilder.create().build()) {
@@ -273,10 +275,15 @@ public class RestClientSingleHostIntegTests extends RestClientTestCase {
             {
                 httpGet.reset();
                 assertFalse(httpGet.isAborted());
-                httpGet.abort();//this has no effect on the next call (although isAborted will return true until the next reset)
+                httpGet.abort();
                 Future<HttpResponse> future = client.execute(httpHost, httpGet, null);
-                assertEquals(200, future.get().getStatusLine().getStatusCode());
-                assertFalse(future.isCancelled());
+                try {
+                    future.get();
+                    fail("expected cancellation exception");
+                } catch(CancellationException e) {
+                    //expected
+                }
+                assertTrue(future.isCancelled());
             }
             {
                 httpGet.reset();

+ 1 - 0
client/sniffer/licenses/httpclient-4.5.10.jar.sha1

@@ -0,0 +1 @@
+7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

+ 0 - 1
client/sniffer/licenses/httpclient-4.5.8.jar.sha1

@@ -1 +0,0 @@
-c27c9d6f15435dc2b6947112027b418b0eef32b9

+ 0 - 1
client/sniffer/licenses/httpcore-4.4.11.jar.sha1

@@ -1 +0,0 @@
-de748cf874e4e193b42eceea9fe5574fabb9d4df

+ 1 - 0
client/sniffer/licenses/httpcore-4.4.12.jar.sha1

@@ -0,0 +1 @@
+21ebaf6d532bc350ba95bd81938fa5f0e511c132

+ 1 - 0
plugins/discovery-azure-classic/licenses/httpclient-4.5.10.jar.sha1

@@ -0,0 +1 @@
+7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

+ 0 - 1
plugins/discovery-azure-classic/licenses/httpclient-4.5.8.jar.sha1

@@ -1 +0,0 @@
-c27c9d6f15435dc2b6947112027b418b0eef32b9

+ 0 - 1
plugins/discovery-azure-classic/licenses/httpcore-4.4.11.jar.sha1

@@ -1 +0,0 @@
-de748cf874e4e193b42eceea9fe5574fabb9d4df

+ 1 - 0
plugins/discovery-azure-classic/licenses/httpcore-4.4.12.jar.sha1

@@ -0,0 +1 @@
+21ebaf6d532bc350ba95bd81938fa5f0e511c132

+ 1 - 0
plugins/discovery-ec2/licenses/httpclient-4.5.10.jar.sha1

@@ -0,0 +1 @@
+7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

+ 0 - 1
plugins/discovery-ec2/licenses/httpclient-4.5.8.jar.sha1

@@ -1 +0,0 @@
-c27c9d6f15435dc2b6947112027b418b0eef32b9

+ 0 - 1
plugins/discovery-ec2/licenses/httpcore-4.4.11.jar.sha1

@@ -1 +0,0 @@
-de748cf874e4e193b42eceea9fe5574fabb9d4df

+ 1 - 0
plugins/discovery-ec2/licenses/httpcore-4.4.12.jar.sha1

@@ -0,0 +1 @@
+21ebaf6d532bc350ba95bd81938fa5f0e511c132

+ 1 - 0
plugins/discovery-gce/licenses/httpclient-4.5.10.jar.sha1

@@ -0,0 +1 @@
+7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

+ 0 - 1
plugins/discovery-gce/licenses/httpclient-4.5.8.jar.sha1

@@ -1 +0,0 @@
-c27c9d6f15435dc2b6947112027b418b0eef32b9

+ 0 - 1
plugins/discovery-gce/licenses/httpcore-4.4.11.jar.sha1

@@ -1 +0,0 @@
-de748cf874e4e193b42eceea9fe5574fabb9d4df

+ 1 - 0
plugins/discovery-gce/licenses/httpcore-4.4.12.jar.sha1

@@ -0,0 +1 @@
+21ebaf6d532bc350ba95bd81938fa5f0e511c132

+ 1 - 0
plugins/repository-gcs/licenses/httpclient-4.5.10.jar.sha1

@@ -0,0 +1 @@
+7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

+ 0 - 1
plugins/repository-gcs/licenses/httpclient-4.5.8.jar.sha1

@@ -1 +0,0 @@
-c27c9d6f15435dc2b6947112027b418b0eef32b9

+ 0 - 1
plugins/repository-gcs/licenses/httpcore-4.4.11.jar.sha1

@@ -1 +0,0 @@
-de748cf874e4e193b42eceea9fe5574fabb9d4df

+ 1 - 0
plugins/repository-gcs/licenses/httpcore-4.4.12.jar.sha1

@@ -0,0 +1 @@
+21ebaf6d532bc350ba95bd81938fa5f0e511c132

+ 1 - 0
plugins/repository-s3/licenses/httpclient-4.5.10.jar.sha1

@@ -0,0 +1 @@
+7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

+ 0 - 1
plugins/repository-s3/licenses/httpclient-4.5.8.jar.sha1

@@ -1 +0,0 @@
-c27c9d6f15435dc2b6947112027b418b0eef32b9

+ 0 - 1
plugins/repository-s3/licenses/httpcore-4.4.11.jar.sha1

@@ -1 +0,0 @@
-de748cf874e4e193b42eceea9fe5574fabb9d4df

+ 1 - 0
plugins/repository-s3/licenses/httpcore-4.4.12.jar.sha1

@@ -0,0 +1 @@
+21ebaf6d532bc350ba95bd81938fa5f0e511c132

+ 1 - 0
x-pack/plugin/core/licenses/httpclient-4.5.10.jar.sha1

@@ -0,0 +1 @@
+7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

+ 0 - 1
x-pack/plugin/core/licenses/httpclient-4.5.8.jar.sha1

@@ -1 +0,0 @@
-c27c9d6f15435dc2b6947112027b418b0eef32b9

+ 0 - 1
x-pack/plugin/core/licenses/httpcore-4.4.11.jar.sha1

@@ -1 +0,0 @@
-de748cf874e4e193b42eceea9fe5574fabb9d4df

+ 1 - 0
x-pack/plugin/core/licenses/httpcore-4.4.12.jar.sha1

@@ -0,0 +1 @@
+21ebaf6d532bc350ba95bd81938fa5f0e511c132

+ 0 - 1
x-pack/plugin/core/licenses/httpcore-nio-4.4.11.jar.sha1

@@ -1 +0,0 @@
-7d0a97d01d39cff9aa3e6db81f21fddb2435f4e6

+ 1 - 0
x-pack/plugin/core/licenses/httpcore-nio-4.4.12.jar.sha1

@@ -0,0 +1 @@
+84cd29eca842f31db02987cfedea245af020198b

+ 1 - 0
x-pack/plugin/security/licenses/httpclient-cache-4.5.10.jar.sha1

@@ -0,0 +1 @@
+b195778247a21e980cb9f80c41364dc0c38feaef

+ 0 - 1
x-pack/plugin/security/licenses/httpclient-cache-4.5.8.jar.sha1

@@ -1 +0,0 @@
-bb984b73da2153285b660f3e278498abd94ccbb5

+ 1 - 0
x-pack/snapshot-tool/licenses/httpclient-4.5.10.jar.sha1

@@ -0,0 +1 @@
+7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

+ 0 - 1
x-pack/snapshot-tool/licenses/httpclient-4.5.8.jar.sha1

@@ -1 +0,0 @@
-c27c9d6f15435dc2b6947112027b418b0eef32b9

+ 0 - 1
x-pack/snapshot-tool/licenses/httpcore-4.4.11.jar.sha1

@@ -1 +0,0 @@
-de748cf874e4e193b42eceea9fe5574fabb9d4df

+ 1 - 0
x-pack/snapshot-tool/licenses/httpcore-4.4.12.jar.sha1

@@ -0,0 +1 @@
+21ebaf6d532bc350ba95bd81938fa5f0e511c132