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

Relates to #45808
Closes #45577
This commit is contained in:
Luca Cavanna 2019-09-11 13:42:32 +02:00
parent de47ea2cf4
commit e57756492a
47 changed files with 57 additions and 41 deletions

View File

@ -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

View File

@ -496,9 +496,9 @@ public class IndexLifecycleClient {
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
*/
public void getSnapshotLifecycleStatsAsync(GetSnapshotLifecycleStatsRequest request, RequestOptions options,
public Cancellable getSnapshotLifecycleStatsAsync(GetSnapshotLifecycleStatsRequest request, RequestOptions options,
ActionListener<GetSnapshotLifecycleStatsResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::getSnapshotLifecycleStats,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndexLifecycleRequestConverters::getSnapshotLifecycleStats,
options, GetSnapshotLifecycleStatsResponse::fromXContent, listener, emptySet());
}
}

View File

@ -1013,7 +1013,7 @@ public final class SecurityClient {
* authenticated TLS session, and it is validated by the PKI realms with {@code delegation.enabled} toggled to {@code true}.<br>
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delegate-pki-authentication.html"> the
* docs</a> for more details.
*
*
* @param request the request containing the certificate chain
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response from the delegate-pki-authentication API key call
@ -1031,14 +1031,14 @@ public final class SecurityClient {
* {@code true}.<br>
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delegate-pki-authentication.html"> the
* docs</a> for more details.
*
*
* @param request the request containing the certificate chain
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
*/
public void delegatePkiAuthenticationAsync(DelegatePkiAuthenticationRequest request, RequestOptions options,
public Cancellable delegatePkiAuthenticationAsync(DelegatePkiAuthenticationRequest request, RequestOptions options,
ActionListener<DelegatePkiAuthenticationResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::delegatePkiAuthentication, options,
return restHighLevelClient.performRequestAsyncAndParseEntity(request, SecurityRequestConverters::delegatePkiAuthentication, options,
DelegatePkiAuthenticationResponse::fromXContent, listener, emptySet());
}
}

View File

@ -0,0 +1 @@
7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

View File

@ -1 +0,0 @@
c27c9d6f15435dc2b6947112027b418b0eef32b9

View File

@ -1 +0,0 @@
de748cf874e4e193b42eceea9fe5574fabb9d4df

View File

@ -0,0 +1 @@
21ebaf6d532bc350ba95bd81938fa5f0e511c132

View File

@ -1 +0,0 @@
7d0a97d01d39cff9aa3e6db81f21fddb2435f4e6

View File

@ -0,0 +1 @@
84cd29eca842f31db02987cfedea245af020198b

View File

@ -74,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;
@ -98,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) {
@ -226,15 +233,12 @@ public class RestClientMultipleHostsIntegTests extends RestClientTestCase {
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());
//we don't test status codes that are subject to retries as they interfere with hosts being stopped
final int statusCode = randomBoolean() ? randomOkStatusCode(getRandom()) : randomErrorNoRetryStatusCode(getRandom());
Cancellable cancellable = restClient.performRequestAsync(new Request(method, "/" + statusCode), 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) {

View File

@ -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();

View File

@ -0,0 +1 @@
7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

View File

@ -1 +0,0 @@
c27c9d6f15435dc2b6947112027b418b0eef32b9

View File

@ -1 +0,0 @@
de748cf874e4e193b42eceea9fe5574fabb9d4df

View File

@ -0,0 +1 @@
21ebaf6d532bc350ba95bd81938fa5f0e511c132

View File

@ -0,0 +1 @@
7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

View File

@ -1 +0,0 @@
c27c9d6f15435dc2b6947112027b418b0eef32b9

View File

@ -1 +0,0 @@
de748cf874e4e193b42eceea9fe5574fabb9d4df

View File

@ -0,0 +1 @@
21ebaf6d532bc350ba95bd81938fa5f0e511c132

View File

@ -0,0 +1 @@
7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

View File

@ -1 +0,0 @@
c27c9d6f15435dc2b6947112027b418b0eef32b9

View File

@ -1 +0,0 @@
de748cf874e4e193b42eceea9fe5574fabb9d4df

View File

@ -0,0 +1 @@
21ebaf6d532bc350ba95bd81938fa5f0e511c132

View File

@ -0,0 +1 @@
7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

View File

@ -1 +0,0 @@
c27c9d6f15435dc2b6947112027b418b0eef32b9

View File

@ -1 +0,0 @@
de748cf874e4e193b42eceea9fe5574fabb9d4df

View File

@ -0,0 +1 @@
21ebaf6d532bc350ba95bd81938fa5f0e511c132

View File

@ -0,0 +1 @@
7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

View File

@ -1 +0,0 @@
c27c9d6f15435dc2b6947112027b418b0eef32b9

View File

@ -1 +0,0 @@
de748cf874e4e193b42eceea9fe5574fabb9d4df

View File

@ -0,0 +1 @@
21ebaf6d532bc350ba95bd81938fa5f0e511c132

View File

@ -0,0 +1 @@
7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

View File

@ -1 +0,0 @@
c27c9d6f15435dc2b6947112027b418b0eef32b9

View File

@ -1 +0,0 @@
de748cf874e4e193b42eceea9fe5574fabb9d4df

View File

@ -0,0 +1 @@
21ebaf6d532bc350ba95bd81938fa5f0e511c132

View File

@ -0,0 +1 @@
7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

View File

@ -1 +0,0 @@
c27c9d6f15435dc2b6947112027b418b0eef32b9

View File

@ -1 +0,0 @@
de748cf874e4e193b42eceea9fe5574fabb9d4df

View File

@ -0,0 +1 @@
21ebaf6d532bc350ba95bd81938fa5f0e511c132

View File

@ -1 +0,0 @@
7d0a97d01d39cff9aa3e6db81f21fddb2435f4e6

View File

@ -0,0 +1 @@
84cd29eca842f31db02987cfedea245af020198b

View File

@ -0,0 +1 @@
b195778247a21e980cb9f80c41364dc0c38feaef

View File

@ -1 +0,0 @@
bb984b73da2153285b660f3e278498abd94ccbb5

View File

@ -0,0 +1 @@
7ca2e4276f4ef95e4db725a8cd4a1d1e7585b9e5

View File

@ -1 +0,0 @@
c27c9d6f15435dc2b6947112027b418b0eef32b9

View File

@ -1 +0,0 @@
de748cf874e4e193b42eceea9fe5574fabb9d4df

View File

@ -0,0 +1 @@
21ebaf6d532bc350ba95bd81938fa5f0e511c132