Make HttpComponentsAsyncClientHttpRequest abortable

This commit aborts the HttpComponentsAsyncClientHttpRequest whenever the
returned Future is canceled.

Issue: SPR-14845
This commit is contained in:
Arjen Poutsma
2016-10-28 14:18:46 +02:00
parent 7b469f9c62
commit 8f844461a0
2 changed files with 21 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -222,4 +222,14 @@ public abstract class AbstractAsyncHttpRequestFactoryTestCase extends AbstractJe
}
}
@Test
public void cancel() throws Exception {
URI uri = new URI(baseUrl + "/status/notfound");
AsyncClientHttpRequest request = this.factory.createAsyncRequest(uri, HttpMethod.GET);
Future<ClientHttpResponse> futureResponse = request.executeAsync();
futureResponse.cancel(true);
assertTrue(futureResponse.isCancelled());
}
}