You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/05/01 10:47:11 UTC
svn commit: r1793305 [1/5] - in /httpcomponents/httpclient/trunk: ./
httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/
httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/
httpclient5-fluent/src/main/java/org...
Author: olegk
Date: Mon May 1 10:47:09 2017
New Revision: 1793305
URL: http://svn.apache.org/viewvc?rev=1793305&view=rev
Log:
Upgraded HttpCore to version 5.0-alpha3; fixed HttpCore API usage
Added:
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientEventHandlerFactory.java (contents, props changed)
- copied, changed from r1790039, httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/DefaultAsyncHttp2ClientEventHandlerFactory.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/H2TlsStrategy.java (contents, props changed)
- copied, changed from r1790039, httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLUpgradeStrategy.java
Removed:
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/AsyncClientEndpoint.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractBinDataConsumer.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractCharDataConsumer.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ComplexFuture.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultThreadFactory.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/DefaultAsyncHttp1ClientEventHandlerFactory.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/DefaultAsyncHttp2ClientEventHandlerFactory.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/DefaultAsyncHttpClientProtocolNegotiator.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/H2TlsSupport.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLUpgradeStrategy.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/utils/Identifiable.java
Modified:
httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java
httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestStaleWhileRevalidationReleasesConnection.java
httpcomponents/httpclient/trunk/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentExecutor.java
httpcomponents/httpclient/trunk/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentRequests.java
httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java
httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java
httpcomponents/httpclient/trunk/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/RelaxedLayeredConnectionSocketFactory.java
httpcomponents/httpclient/trunk/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/TestRelaxedLayeredConnectionSocketFactory.java
httpcomponents/httpclient/trunk/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
httpcomponents/httpclient/trunk/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java
httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java
httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java
httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java
httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java
httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java
httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java
httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java
httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java
httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectionKeepAliveStrategy.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/HttpAsyncClient.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractAsyncResponseConsumer.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractBinPushConsumer.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractBinResponseConsumer.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractCharPushConsumer.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractCharResponseConsumer.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/config/RequestConfig.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ConnPoolSupport.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultUserTokenHandler.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClients.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultManagedHttpClientConnection.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManagerBuilder.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/logging/LoggingIOEventHandler.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/logging/LoggingIOSession.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/AsyncClientConnectionOperator.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/ManagedAsyncClientConnection.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManagerBuilder.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/EndpointHolder.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/HttpClientBuilder.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/InternalHttpClient.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/MainClientExec.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/MinimalClientExec.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/ProxyClient.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/sync/RoutedHttpRequest.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/io/ConnectionEndpoint.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/io/HttpClientConnectionManager.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/io/HttpClientConnectionOperator.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/nio/AsyncClientConnectionManager.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/socket/ConnectionSocketFactory.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/socket/PlainConnectionSocketFactory.java
httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultConnKeepAliveStrategy.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestIdleConnectionEvictor.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestClientAuthentication.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestConnectionAutoRelease.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestConnectionManagement.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestIdleConnectionEviction.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestMalformedServerResponse.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestRedirects.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/integration/TestStatefulConnManagement.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/MockConnPoolControl.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestEndpointHolder.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestFutureRequestExecutionService.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestMainClientExec.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/impl/sync/TestMinimalClientExec.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/localserver/LocalServerTestBase.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java
httpcomponents/httpclient/trunk/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestSSLSocketFactory.java
httpcomponents/httpclient/trunk/pom.xml
Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java Mon May 1 10:47:09 2017
@@ -54,13 +54,13 @@ import org.apache.hc.client5.http.cache.
import org.apache.hc.client5.http.cache.HttpCacheEntry;
import org.apache.hc.client5.http.cache.HttpCacheStorage;
import org.apache.hc.client5.http.impl.sync.ClientExecChain;
+import org.apache.hc.client5.http.impl.sync.RoutedHttpRequest;
import org.apache.hc.client5.http.protocol.ClientProtocolException;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.sync.methods.HttpExecutionAware;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.client5.http.sync.methods.HttpOptions;
import org.apache.hc.client5.http.sync.methods.HttpUriRequest;
-import org.apache.hc.client5.http.impl.sync.RoutedHttpRequest;
import org.apache.hc.client5.http.utils.DateUtils;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
@@ -1409,7 +1409,6 @@ public abstract class TestCachingExecCha
final HttpClientContext ctx = HttpClientContext.create();
impl.execute(request, context, null);
impl.execute(request, ctx, null);
- assertNull(ctx.getConnection());
}
@Test
Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestStaleWhileRevalidationReleasesConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestStaleWhileRevalidationReleasesConnection.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestStaleWhileRevalidationReleasesConnection.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestStaleWhileRevalidationReleasesConnection.java Mon May 1 10:47:09 2017
@@ -32,6 +32,7 @@ import static org.junit.Assert.assertNul
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
+import java.util.concurrent.TimeUnit;
import org.apache.hc.client5.http.cache.CacheResponseStatus;
import org.apache.hc.client5.http.cache.HttpCacheContext;
@@ -48,8 +49,8 @@ import org.apache.hc.core5.http.HttpExce
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.MethodNotSupportedException;
import org.apache.hc.core5.http.config.SocketConfig;
-import org.apache.hc.core5.http.impl.io.bootstrap.HttpServer;
-import org.apache.hc.core5.http.impl.io.bootstrap.ServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
+import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
import org.apache.hc.core5.http.io.HttpRequestHandler;
import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
@@ -78,7 +79,7 @@ public class TestStaleWhileRevalidationR
public void start() throws Exception {
this.localServer = ServerBootstrap.bootstrap()
.setSocketConfig(SocketConfig.custom()
- .setSoTimeout(5000)
+ .setSoTimeout(5, TimeUnit.SECONDS)
.build())
.registerHandler(url + "*", new EchoViaHeaderHandler())
.create();
@@ -97,9 +98,9 @@ public class TestStaleWhileRevalidationR
.build();
final RequestConfig config = RequestConfig.custom()
- .setSocketTimeout(10000)
- .setConnectTimeout(10000)
- .setConnectionRequestTimeout(1000)
+ .setSocketTimeout(10, TimeUnit.SECONDS)
+ .setConnectTimeout(10, TimeUnit.SECONDS)
+ .setConnectionRequestTimeout(1, TimeUnit.SECONDS)
.build();
client = CachingHttpClientBuilder.create()
Modified: httpcomponents/httpclient/trunk/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentExecutor.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentExecutor.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentExecutor.java Mon May 1 10:47:09 2017
@@ -31,9 +31,10 @@ import java.io.File;
import org.apache.hc.client5.http.fluent.Executor;
import org.apache.hc.client5.http.fluent.Form;
import org.apache.hc.client5.http.fluent.Request;
+import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpVersion;
-import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.util.TimeValue;
/**
* This example demonstrates how the he HttpClient fluent API can be used to execute multiple
@@ -51,8 +52,8 @@ public class FluentExecutor {
// Execute a GET with timeout settings and return response content as String.
executor.execute(Request.Get("http://somehost/")
- .connectTimeout(1000)
- .socketTimeout(1000)
+ .connectTimeout(TimeValue.ofSeconds(1))
+ .socketTimeout(TimeValue.ofSeconds(1))
).returnContent().asString();
// Execute a POST with the 'expect-continue' handshake, using HTTP/1.1,
Modified: httpcomponents/httpclient/trunk/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentRequests.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentRequests.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentRequests.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentRequests.java Mon May 1 10:47:09 2017
@@ -30,9 +30,10 @@ import java.io.File;
import org.apache.hc.client5.http.fluent.Form;
import org.apache.hc.client5.http.fluent.Request;
+import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpVersion;
-import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.util.TimeValue;
/**
* This example demonstrates basics of request execution with the HttpClient fluent API.
@@ -42,8 +43,8 @@ public class FluentRequests {
public static void main(String[] args)throws Exception {
// Execute a GET with timeout settings and return response content as String.
Request.Get("http://somehost/")
- .connectTimeout(1000)
- .socketTimeout(1000)
+ .connectTimeout(TimeValue.ofSeconds(1))
+ .socketTimeout(TimeValue.ofSeconds(1))
.execute().returnContent().asString();
// Execute a POST with the 'expect-continue' handshake, using HTTP/1.1,
Modified: httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java Mon May 1 10:47:09 2017
@@ -30,7 +30,6 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
-import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
@@ -56,6 +55,7 @@ import org.apache.hc.client5.http.ssl.SS
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.config.Registry;
import org.apache.hc.core5.http.config.RegistryBuilder;
+import org.apache.hc.core5.util.TimeValue;
/**
* An Executor for fluent requests.
@@ -91,7 +91,7 @@ public class Executor {
CONNMGR = new PoolingHttpClientConnectionManager(sfr);
CONNMGR.setDefaultMaxPerRoute(100);
CONNMGR.setMaxTotal(200);
- CONNMGR.setValidateAfterInactivity(1000);
+ CONNMGR.setValidateAfterInactivity(TimeValue.ofSeconds(1));
CLIENT = HttpClientBuilder.create()
.setConnectionManager(CONNMGR)
.build();
@@ -252,7 +252,7 @@ public class Executor {
* or discarded using {@link Response#discardContent()}, otherwise the
* connection used for the request might not be released to the pool.
*
- * @see Response#handleResponse(org.apache.hc.client5.http.sync.ResponseHandler)
+ * @see Response#handleResponse(org.apache.hc.core5.http.io.ResponseHandler)
* @see Response#discardContent()
*/
public Response execute(
@@ -275,7 +275,7 @@ public class Executor {
* @since 4.4
*/
public static void closeIdleConnections() {
- CONNMGR.closeIdle(0, TimeUnit.MICROSECONDS);
+ CONNMGR.closeIdle(TimeValue.NEG_ONE_MILLISECONDS);
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java Mon May 1 10:47:09 2017
@@ -66,6 +66,7 @@ import org.apache.hc.core5.http.io.entit
import org.apache.hc.core5.http.io.entity.InputStreamEntity;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.net.URLEncodedUtils;
+import org.apache.hc.core5.util.TimeValue;
public class Request {
@@ -75,8 +76,8 @@ public class Request {
private final HttpUriRequestBase request;
private Boolean useExpectContinue;
- private Integer socketTmeout;
- private Integer connectTimeout;
+ private TimeValue socketTmeout;
+ private TimeValue connectTimeout;
private HttpHost proxy;
private SimpleDateFormat dateFormatter;
@@ -282,12 +283,12 @@ public class Request {
//// HTTP connection parameter operations
- public Request socketTimeout(final int timeout) {
+ public Request socketTimeout(final TimeValue timeout) {
this.socketTmeout = timeout;
return this;
}
- public Request connectTimeout(final int timeout) {
+ public Request connectTimeout(final TimeValue timeout) {
this.connectTimeout = timeout;
return this;
}
Modified: httpcomponents/httpclient/trunk/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/RelaxedLayeredConnectionSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/RelaxedLayeredConnectionSocketFactory.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/RelaxedLayeredConnectionSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-osgi/src/main/java/org/apache/hc/client5/http/osgi/impl/RelaxedLayeredConnectionSocketFactory.java Mon May 1 10:47:09 2017
@@ -36,6 +36,7 @@ import org.apache.hc.client5.http.osgi.s
import org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.TimeValue;
final class RelaxedLayeredConnectionSocketFactory implements LayeredConnectionSocketFactory {
@@ -78,7 +79,7 @@ final class RelaxedLayeredConnectionSock
}
@Override
- public Socket connectSocket(final int connectTimeout,
+ public Socket connectSocket(final TimeValue connectTimeout,
final Socket sock,
final HttpHost host,
final InetSocketAddress remoteAddress,
Modified: httpcomponents/httpclient/trunk/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/TestRelaxedLayeredConnectionSocketFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/TestRelaxedLayeredConnectionSocketFactory.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/TestRelaxedLayeredConnectionSocketFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/TestRelaxedLayeredConnectionSocketFactory.java Mon May 1 10:47:09 2017
@@ -38,6 +38,7 @@ import org.apache.hc.client5.http.socket
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.TimeValue;
import org.junit.Test;
import org.mockito.Mock;
import org.osgi.service.cm.ConfigurationException;
@@ -92,7 +93,7 @@ public class TestRelaxedLayeredConnectio
}
@Override
- public Socket connectSocket(final int connectTimeout,
+ public Socket connectSocket(final TimeValue connectTimeout,
final Socket sock,
final HttpHost host,
final InetSocketAddress remoteAddress,
Modified: httpcomponents/httpclient/trunk/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java Mon May 1 10:47:09 2017
@@ -34,7 +34,6 @@ import java.util.concurrent.TimeoutExcep
import javax.net.ssl.SSLContext;
-import org.apache.hc.client5.http.async.AsyncClientEndpoint;
import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
import org.apache.hc.client5.http.async.methods.SimpleRequestProducer;
@@ -48,12 +47,13 @@ import org.apache.hc.client5.http.impl.n
import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder;
import org.apache.hc.client5.http.impl.sync.BasicCredentialsProvider;
import org.apache.hc.client5.http.protocol.HttpClientContext;
-import org.apache.hc.client5.http.ssl.SSLUpgradeStrategy;
+import org.apache.hc.client5.http.ssl.H2TlsStrategy;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.HttpVersion;
-import org.apache.hc.core5.http2.config.H2Config;
+import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
+import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.hc.core5.util.TextUtils;
@@ -104,13 +104,10 @@ public class HttpAsyncClientCompatibilit
final SSLContext sslContext = SSLContexts.custom()
.loadTrustMaterial(getClass().getResource("/test-ca.keystore"), "nopassword".toCharArray()).build();
this.connManager = PoolingAsyncClientConnectionManagerBuilder.create()
- .setTlsStrategy(new SSLUpgradeStrategy(sslContext))
+ .setTlsStrategy(new H2TlsStrategy(sslContext))
.build();
this.client = HttpAsyncClients.custom()
- .setProtocolVersion(this.protocolVersion)
- .setH2Config(H2Config.custom()
- .setSettingAckNeeded(false)
- .build())
+ .setVersionPolicy(this.protocolVersion == HttpVersion.HTTP_2 ? HttpVersionPolicy.FORCE_HTTP_2 : HttpVersionPolicy.FORCE_HTTP_1)
.setConnectionManager(this.connManager)
.setDefaultRequestConfig(requestConfig)
.build();
Modified: httpcomponents/httpclient/trunk/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java Mon May 1 10:47:09 2017
@@ -27,7 +27,6 @@
package org.apache.hc.client5.testing.external;
import java.util.Objects;
-import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
@@ -53,6 +52,7 @@ import org.apache.hc.core5.http.HttpStat
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.hc.core5.util.TextUtils;
+import org.apache.hc.core5.util.TimeValue;
public class HttpClientCompatibilityTest {
@@ -157,7 +157,7 @@ public class HttpClientCompatibilityTest
}
// Basic GET requests
{
- connManager.closeIdle(0, TimeUnit.MILLISECONDS);
+ connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS);
final HttpClientContext context = HttpClientContext.create();
context.setCredentialsProvider(credentialsProvider);
final String[] requestUris = new String[] {"/", "/news.html", "/status.html"};
@@ -178,7 +178,7 @@ public class HttpClientCompatibilityTest
}
// Wrong target auth scope
{
- connManager.closeIdle(0, TimeUnit.MILLISECONDS);
+ connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS);
credentialsProvider.setCredentials(
new AuthScope("otherhost", AuthScope.ANY_PORT, "Restricted Files"),
new UsernamePasswordCredentials("testuser", "nopassword".toCharArray()));
@@ -200,7 +200,7 @@ public class HttpClientCompatibilityTest
}
// Wrong target credentials
{
- connManager.closeIdle(0, TimeUnit.MILLISECONDS);
+ connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS);
credentialsProvider.setCredentials(
new AuthScope(target),
new UsernamePasswordCredentials("testuser", "wrong password".toCharArray()));
@@ -222,7 +222,7 @@ public class HttpClientCompatibilityTest
}
// Correct target credentials
{
- connManager.closeIdle(0, TimeUnit.MILLISECONDS);
+ connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS);
credentialsProvider.setCredentials(
new AuthScope(target),
new UsernamePasswordCredentials("testuser", "nopassword".toCharArray()));
@@ -244,7 +244,7 @@ public class HttpClientCompatibilityTest
}
// Correct target credentials (no keep-alive)
{
- connManager.closeIdle(0, TimeUnit.MILLISECONDS);
+ connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS);
credentialsProvider.setCredentials(
new AuthScope(target),
new UsernamePasswordCredentials("testuser", "nopassword".toCharArray()));
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java Mon May 1 10:47:09 2017
@@ -37,7 +37,9 @@ import org.apache.hc.client5.http.impl.a
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.io.ShutdownType;
import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.util.TimeValue;
/**
* Example demonstrating how to evict expired and idle connections
@@ -48,14 +50,13 @@ public class AsyncClientConnectionEvicti
public static void main(final String[] args) throws Exception {
final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
- .setConnectTimeout(5000)
- .setSoTimeout(5000)
+ .setSoTimeout(TimeValue.ofSeconds(5))
.build();
final CloseableHttpAsyncClient client = HttpAsyncClients.custom()
.setIOReactorConfig(ioReactorConfig)
.evictExpiredConnections()
- .evictIdleConnections(10, TimeUnit.SECONDS)
+ .evictIdleConnections(TimeValue.ofSeconds(10))
.build();
client.start();
@@ -118,7 +119,7 @@ public class AsyncClientConnectionEvicti
future2.get();
System.out.println("Shutting down");
- client.shutdown(5, TimeUnit.SECONDS);
+ client.shutdown(ShutdownType.GRACEFUL);
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java Mon May 1 10:47:09 2017
@@ -30,7 +30,6 @@ import java.util.concurrent.CountDownLat
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import org.apache.hc.client5.http.async.AsyncClientEndpoint;
import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
import org.apache.hc.client5.http.async.methods.SimpleRequestProducer;
@@ -39,8 +38,11 @@ import org.apache.hc.client5.http.impl.a
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
+import org.apache.hc.core5.http2.HttpVersionPolicy;
+import org.apache.hc.core5.io.ShutdownType;
import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.util.TimeValue;
/**
* This example demonstrates pipelined execution of multiple HTTP/1.1 message exchanges.
@@ -50,12 +52,11 @@ public class AsyncClientHttp1Pipelining
public static void main(final String[] args) throws Exception {
final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
- .setConnectTimeout(5000)
- .setSoTimeout(5000)
+ .setSoTimeout(TimeValue.ofSeconds(5))
.build();
final CloseableHttpAsyncClient client = HttpAsyncClients.custom()
- .setProtocolVersion(HttpVersion.HTTP_1_1)
+ .setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_1)
.setIOReactorConfig(ioReactorConfig)
.build();
@@ -102,7 +103,7 @@ public class AsyncClientHttp1Pipelining
}
System.out.println("Shutting down");
- client.shutdown(5, TimeUnit.SECONDS);
+ client.shutdown(ShutdownType.GRACEFUL);
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java Mon May 1 10:47:09 2017
@@ -30,7 +30,6 @@ import java.util.concurrent.CountDownLat
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import org.apache.hc.client5.http.async.AsyncClientEndpoint;
import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
import org.apache.hc.client5.http.async.methods.SimpleRequestProducer;
@@ -39,9 +38,12 @@ import org.apache.hc.client5.http.impl.a
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpVersion;
+import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
+import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.http2.config.H2Config;
+import org.apache.hc.core5.io.ShutdownType;
import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.util.TimeValue;
/**
* This example demonstrates concurrent (multiplexed) execution of multiple
@@ -52,8 +54,7 @@ public class AsyncClientHttp2Multiplexin
public static void main(final String[] args) throws Exception {
final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
- .setConnectTimeout(5000)
- .setSoTimeout(5000)
+ .setSoTimeout(TimeValue.ofSeconds(5))
.build();
final H2Config h2Config = H2Config.custom()
@@ -62,7 +63,7 @@ public class AsyncClientHttp2Multiplexin
final CloseableHttpAsyncClient client = HttpAsyncClients.custom()
.setIOReactorConfig(ioReactorConfig)
- .setProtocolVersion(HttpVersion.HTTP_2)
+ .setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_2)
.setH2Config(h2Config)
.build();
@@ -109,7 +110,7 @@ public class AsyncClientHttp2Multiplexin
}
System.out.println("Shutting down");
- client.shutdown(5, TimeUnit.SECONDS);
+ client.shutdown(ShutdownType.GRACEFUL);
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java Mon May 1 10:47:09 2017
@@ -30,7 +30,6 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
import org.apache.hc.client5.http.async.methods.AbstractBinPushConsumer;
import org.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer;
@@ -43,11 +42,13 @@ import org.apache.hc.core5.http.HttpExce
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
+import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.http2.config.H2Config;
+import org.apache.hc.core5.io.ShutdownType;
import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.util.TimeValue;
/**
* This example demonstrates handling of HTTP/2 message exchanges pushed by the server.
@@ -57,8 +58,7 @@ public class AsyncClientHttp2ServerPush
public static void main(final String[] args) throws Exception {
final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
- .setConnectTimeout(5000)
- .setSoTimeout(5000)
+ .setSoTimeout(TimeValue.ofSeconds(5))
.build();
final H2Config h2Config = H2Config.custom()
@@ -67,7 +67,7 @@ public class AsyncClientHttp2ServerPush
final CloseableHttpAsyncClient client = HttpAsyncClients.custom()
.setIOReactorConfig(ioReactorConfig)
- .setProtocolVersion(HttpVersion.HTTP_2)
+ .setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_2)
.setH2Config(h2Config)
.build();
@@ -147,6 +147,11 @@ public class AsyncClientHttp2ServerPush
}
@Override
+ public Void getResult() {
+ return null;
+ }
+
+ @Override
public void releaseResources() {
}
@@ -154,7 +159,7 @@ public class AsyncClientHttp2ServerPush
future.get();
System.out.println("Shutting down");
- client.shutdown(5, TimeUnit.SECONDS);
+ client.shutdown(ShutdownType.GRACEFUL);
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java Mon May 1 10:47:09 2017
@@ -27,7 +27,6 @@
package org.apache.hc.client5.http.examples;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
@@ -37,7 +36,9 @@ import org.apache.hc.client5.http.impl.a
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.io.ShutdownType;
import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.util.TimeValue;
/**
* Example of asynchronous HTTP/1.1 request execution.
@@ -47,8 +48,7 @@ public class AsyncClientHttpExchange {
public static void main(final String[] args) throws Exception {
final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
- .setConnectTimeout(5000)
- .setSoTimeout(5000)
+ .setSoTimeout(TimeValue.ofSeconds(5))
.build();
final CloseableHttpAsyncClient client = HttpAsyncClients.custom()
@@ -88,7 +88,7 @@ public class AsyncClientHttpExchange {
}
System.out.println("Shutting down");
- client.shutdown(5, TimeUnit.SECONDS);
+ client.shutdown(ShutdownType.GRACEFUL);
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java Mon May 1 10:47:09 2017
@@ -29,7 +29,6 @@ package org.apache.hc.client5.http.examp
import java.io.IOException;
import java.nio.CharBuffer;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
import org.apache.hc.client5.http.async.methods.AbstractCharResponseConsumer;
import org.apache.hc.client5.http.async.methods.AsyncRequestBuilder;
@@ -40,7 +39,9 @@ import org.apache.hc.core5.http.HttpExce
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.message.StatusLine;
+import org.apache.hc.core5.io.ShutdownType;
import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.util.TimeValue;
/**
* Example of asynchronous HTTP/1.1 request execution with response streaming.
@@ -50,8 +51,7 @@ public class AsyncClientHttpExchangeStre
public static void main(final String[] args) throws Exception {
final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
- .setConnectTimeout(5000)
- .setSoTimeout(5000)
+ .setSoTimeout(TimeValue.ofSeconds(5))
.build();
final CloseableHttpAsyncClient client = HttpAsyncClients.custom()
@@ -96,6 +96,11 @@ public class AsyncClientHttpExchangeStre
}
@Override
+ public Void getResult() {
+ return null;
+ }
+
+ @Override
public void failed(final Exception cause) {
System.out.println(requestUri + "->" + cause);
}
@@ -109,7 +114,7 @@ public class AsyncClientHttpExchangeStre
}
System.out.println("Shutting down");
- client.shutdown(5, TimeUnit.SECONDS);
+ client.shutdown(ShutdownType.GRACEFUL);
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java Mon May 1 10:47:09 2017
@@ -61,7 +61,7 @@ import org.apache.hc.core5.http.ClassicH
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.ParseException;
-import org.apache.hc.core5.http.config.ConnectionConfig;
+import org.apache.hc.core5.http.config.CharCodingConfig;
import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.config.Registry;
import org.apache.hc.core5.http.config.RegistryBuilder;
@@ -80,6 +80,7 @@ import org.apache.hc.core5.http.message.
import org.apache.hc.core5.http.message.LineParser;
import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.hc.core5.util.CharArrayBuffer;
+import org.apache.hc.core5.util.TimeValue;
/**
* This example demonstrates how to customize and configure the most common aspects
@@ -119,7 +120,7 @@ public class ClientConfiguration {
.setMaxLineLength(2000)
.build();
// Create connection configuration
- final ConnectionConfig connectionConfig = ConnectionConfig.custom()
+ final CharCodingConfig connectionConfig = CharCodingConfig.custom()
.setMalformedInputAction(CodingErrorAction.IGNORE)
.setUnmappableInputAction(CodingErrorAction.IGNORE)
.setCharset(StandardCharsets.UTF_8)
@@ -174,7 +175,7 @@ public class ClientConfiguration {
// by default or for a specific host.
connManager.setDefaultSocketConfig(socketConfig);
// Validate connections after 1 sec of inactivity
- connManager.setValidateAfterInactivity(1000);
+ connManager.setValidateAfterInactivity(TimeValue.ofSeconds(10));
// Configure total max or per route limits for persistent connections
// that can be kept in the pool or leased by the connection manager.
@@ -207,9 +208,9 @@ public class ClientConfiguration {
// Request configuration can be overridden at the request level.
// They will take precedence over the one set at the client level.
final RequestConfig requestConfig = RequestConfig.copy(defaultRequestConfig)
- .setSocketTimeout(5000)
- .setConnectTimeout(5000)
- .setConnectionRequestTimeout(5000)
+ .setSocketTimeout(TimeValue.ofSeconds(5))
+ .setConnectTimeout(TimeValue.ofSeconds(5))
+ .setConnectionRequestTimeout(TimeValue.ofSeconds(5))
.setProxy(new HttpHost("myotherproxy", 8080))
.build();
httpget.setConfig(requestConfig);
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java Mon May 1 10:47:09 2017
@@ -26,8 +26,6 @@
*/
package org.apache.hc.client5.http.examples;
-import java.util.concurrent.TimeUnit;
-
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
@@ -35,6 +33,7 @@ import org.apache.hc.client5.http.impl.s
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.pool.PoolStats;
+import org.apache.hc.core5.util.TimeValue;
/**
* Example demonstrating how to evict expired and idle connections
@@ -48,7 +47,7 @@ public class ClientEvictExpiredConnectio
try (CloseableHttpClient httpclient = HttpClients.custom()
.setConnectionManager(cm)
.evictExpiredConnections()
- .evictIdleConnections(5L, TimeUnit.SECONDS)
+ .evictIdleConnections(TimeValue.ofSeconds(5))
.build()) {
// create an array of URIs to perform GETs on
final String[] urisToGet = {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java Mon May 1 10:47:09 2017
@@ -46,6 +46,7 @@ import org.apache.hc.core5.http.config.R
import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.TimeValue;
/**
* How to send a request via SOCKS proxy.
@@ -90,7 +91,7 @@ public class ClientExecuteSOCKS {
@Override
public Socket connectSocket(
- final int connectTimeout,
+ final TimeValue connectTimeout,
final Socket socket,
final HttpHost host,
final InetSocketAddress remoteAddress,
@@ -106,7 +107,7 @@ public class ClientExecuteSOCKS {
sock.bind(localAddress);
}
try {
- sock.connect(remoteAddress, connectTimeout);
+ sock.connect(remoteAddress, connectTimeout != null ? connectTimeout.toMillisIntBound() : 0);
} catch (final SocketTimeoutException ex) {
throw new ConnectTimeoutException(ex, host, remoteAddress.getAddress());
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectionKeepAliveStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectionKeepAliveStrategy.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectionKeepAliveStrategy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectionKeepAliveStrategy.java Mon May 1 10:47:09 2017
@@ -28,6 +28,7 @@ package org.apache.hc.client5.http;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.util.TimeValue;
/**
* Interface for deciding how long a connection can remain
@@ -61,6 +62,6 @@ public interface ConnectionKeepAliveStra
* @return the duration in ms for which it is safe to keep the connection
* idle, or <=0 if no suggested duration.
*/
- long getKeepAliveDuration(HttpResponse response, HttpContext context);
+ TimeValue getKeepAliveDuration(HttpResponse response, HttpContext context);
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/HttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/HttpAsyncClient.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/HttpAsyncClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/HttpAsyncClient.java Mon May 1 10:47:09 2017
@@ -31,6 +31,7 @@ import java.util.concurrent.Future;
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
import org.apache.hc.core5.http.nio.AsyncRequestProducer;
import org.apache.hc.core5.http.nio.AsyncResponseConsumer;
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractAsyncResponseConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractAsyncResponseConsumer.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractAsyncResponseConsumer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractAsyncResponseConsumer.java Mon May 1 10:47:09 2017
@@ -46,6 +46,8 @@ public abstract class AbstractAsyncRespo
private final AsyncEntityConsumer<E> entityConsumer;
+ private volatile T result;
+
public AbstractAsyncResponseConsumer(final AsyncEntityConsumer<E> entityConsumer) {
Args.notNull(entityConsumer, "Entity consumer");
this.entityConsumer = entityConsumer;
@@ -62,11 +64,12 @@ public abstract class AbstractAsyncRespo
entityConsumer.streamStart(entityDetails, new FutureCallback<E>() {
@Override
- public void completed(final E result) {
+ public void completed(final E entity) {
final ContentType contentType;
try {
contentType = ContentType.parse(entityDetails.getContentType());
- resultCallback.completed(buildResult(response, result, contentType));
+ result = buildResult(response, entity, contentType);
+ resultCallback.completed(result);
} catch (final UnsupportedCharsetException ex) {
resultCallback.failed(ex);
}
@@ -106,6 +109,11 @@ public abstract class AbstractAsyncRespo
}
@Override
+ public T getResult() {
+ return result;
+ }
+
+ @Override
public final void failed(final Exception cause) {
releaseResources();
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractBinPushConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractBinPushConsumer.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractBinPushConsumer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractBinPushConsumer.java Mon May 1 10:47:09 2017
@@ -36,6 +36,7 @@ import org.apache.hc.core5.http.HttpExce
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
+import org.apache.hc.core5.http.nio.entity.AbstractBinDataConsumer;
public abstract class AbstractBinPushConsumer extends AbstractBinDataConsumer implements AsyncPushConsumer {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractBinResponseConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractBinResponseConsumer.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractBinResponseConsumer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractBinResponseConsumer.java Mon May 1 10:47:09 2017
@@ -36,6 +36,7 @@ import org.apache.hc.core5.http.EntityDe
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.nio.AsyncResponseConsumer;
+import org.apache.hc.core5.http.nio.entity.AbstractBinDataConsumer;
public abstract class AbstractBinResponseConsumer<T> extends AbstractBinDataConsumer implements AsyncResponseConsumer<T> {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractCharPushConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractCharPushConsumer.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractCharPushConsumer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractCharPushConsumer.java Mon May 1 10:47:09 2017
@@ -38,6 +38,7 @@ import org.apache.hc.core5.http.HttpExce
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
+import org.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer;
public abstract class AbstractCharPushConsumer extends AbstractCharDataConsumer implements AsyncPushConsumer {
@@ -59,7 +60,7 @@ public abstract class AbstractCharPushCo
if (charset == null) {
charset = StandardCharsets.US_ASCII;
}
- setCharsetDecoder(charset.newDecoder());
+ setCharset(charset);
start(promise, response, contentType);
} else {
start(promise, response, null);
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractCharResponseConsumer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractCharResponseConsumer.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractCharResponseConsumer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/AbstractCharResponseConsumer.java Mon May 1 10:47:09 2017
@@ -38,6 +38,7 @@ import org.apache.hc.core5.http.EntityDe
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.nio.AsyncResponseConsumer;
+import org.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer;
public abstract class AbstractCharResponseConsumer<T> extends AbstractCharDataConsumer implements AsyncResponseConsumer<T> {
@@ -64,7 +65,7 @@ public abstract class AbstractCharRespon
if (charset == null) {
charset = StandardCharsets.US_ASCII;
}
- setCharsetDecoder(charset.newDecoder());
+ setCharset(charset);
start(response, contentType);
} else {
start(response, null);
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/config/RequestConfig.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/config/RequestConfig.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/config/RequestConfig.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/config/RequestConfig.java Mon May 1 10:47:09 2017
@@ -34,6 +34,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.util.TimeValue;
/**
* Immutable class encapsulating request configuration items.
@@ -41,9 +42,9 @@ import org.apache.hc.core5.http.HttpHost
@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class RequestConfig implements Cloneable {
- private static final int DEFAULT_CONNECTION_REQUEST_TIMEOUT = (int) TimeUnit.MILLISECONDS.convert(3, TimeUnit.MINUTES);
- private static final int DEFAULT_CONNECT_TIMEOUT = (int) TimeUnit.MILLISECONDS.convert(3, TimeUnit.MINUTES);
- private static final int DEFAULT_SOCKET_TIMEOUT = -1;
+ private static final TimeValue DEFAULT_CONNECTION_REQUEST_TIMEOUT = TimeValue.ofMinutes(3);
+ private static final TimeValue DEFAULT_CONNECT_TIMEOUT = TimeValue.ofMinutes(3);
+ private static final TimeValue DEFAULT_SOCKET_TIMEOUT = TimeValue.NEG_ONE_MILLISECONDS;
public static final RequestConfig DEFAULT = new Builder().build();
@@ -57,9 +58,9 @@ public class RequestConfig implements Cl
private final boolean authenticationEnabled;
private final Collection<String> targetPreferredAuthSchemes;
private final Collection<String> proxyPreferredAuthSchemes;
- private final int connectionRequestTimeout;
- private final int connectTimeout;
- private final int socketTimeout;
+ private final TimeValue connectionRequestTimeout;
+ private final TimeValue connectTimeout;
+ private final TimeValue socketTimeout;
private final boolean contentCompressionEnabled;
/**
@@ -81,9 +82,9 @@ public class RequestConfig implements Cl
final boolean authenticationEnabled,
final Collection<String> targetPreferredAuthSchemes,
final Collection<String> proxyPreferredAuthSchemes,
- final int connectionRequestTimeout,
- final int connectTimeout,
- final int socketTimeout,
+ final TimeValue connectionRequestTimeout,
+ final TimeValue connectTimeout,
+ final TimeValue socketTimeout,
final boolean contentCompressionEnabled) {
super();
this.expectContinueEnabled = expectContinueEnabled;
@@ -238,10 +239,10 @@ public class RequestConfig implements Cl
* A negative value is interpreted as undefined (system default).
* </p>
* <p>
- * Default: 2 minutes.
+ * Default: 3 minutes.
* </p>
*/
- public int getConnectionRequestTimeout() {
+ public TimeValue getConnectionRequestTimeout() {
return connectionRequestTimeout;
}
@@ -253,10 +254,10 @@ public class RequestConfig implements Cl
* A negative value is interpreted as undefined (system default).
* </p>
* <p>
- * Default: no timeout
+ * Default: 3 minutes
* </p>
*/
- public int getConnectTimeout() {
+ public TimeValue getConnectTimeout() {
return connectTimeout;
}
@@ -269,10 +270,10 @@ public class RequestConfig implements Cl
* A negative value is interpreted as undefined (system default).
* </p>
* <p>
- * Default: 2 minutes.
+ * Default: no timeout.
* </p>
*/
- public int getSocketTimeout() {
+ public TimeValue getSocketTimeout() {
return socketTimeout;
}
@@ -349,9 +350,9 @@ public class RequestConfig implements Cl
private boolean authenticationEnabled;
private Collection<String> targetPreferredAuthSchemes;
private Collection<String> proxyPreferredAuthSchemes;
- private int connectionRequestTimeout;
- private int connectTimeout;
- private int socketTimeout;
+ private TimeValue connectionRequestTimeout;
+ private TimeValue connectTimeout;
+ private TimeValue socketTimeout;
private boolean contentCompressionEnabled;
Builder() {
@@ -415,21 +416,36 @@ public class RequestConfig implements Cl
return this;
}
- public Builder setConnectionRequestTimeout(final int connectionRequestTimeout) {
+ public Builder setConnectionRequestTimeout(final TimeValue connectionRequestTimeout) {
this.connectionRequestTimeout = connectionRequestTimeout;
return this;
}
- public Builder setConnectTimeout(final int connectTimeout) {
+ public Builder setConnectionRequestTimeout(final long connectionRequestTimeout, final TimeUnit timeUnit) {
+ this.connectionRequestTimeout = TimeValue.of(connectionRequestTimeout, timeUnit);
+ return this;
+ }
+
+ public Builder setConnectTimeout(final TimeValue connectTimeout) {
this.connectTimeout = connectTimeout;
return this;
}
- public Builder setSocketTimeout(final int socketTimeout) {
+ public Builder setConnectTimeout(final long connectTimeout, final TimeUnit timeUnit) {
+ this.connectTimeout = TimeValue.of(connectTimeout, timeUnit);
+ return this;
+ }
+
+ public Builder setSocketTimeout(final TimeValue socketTimeout) {
this.socketTimeout = socketTimeout;
return this;
}
+ public Builder setSocketTimeout(final long socketTimeout, final TimeUnit timeUnit) {
+ this.socketTimeout = TimeValue.of(socketTimeout, timeUnit);
+ return this;
+ }
+
public Builder setContentCompressionEnabled(final boolean contentCompressionEnabled) {
this.contentCompressionEnabled = contentCompressionEnabled;
return this;
@@ -447,9 +463,9 @@ public class RequestConfig implements Cl
authenticationEnabled,
targetPreferredAuthSchemes,
proxyPreferredAuthSchemes,
- connectionRequestTimeout,
- connectTimeout,
- socketTimeout,
+ connectionRequestTimeout != null ? connectionRequestTimeout : DEFAULT_CONNECTION_REQUEST_TIMEOUT,
+ connectTimeout != null ? connectTimeout : DEFAULT_CONNECT_TIMEOUT,
+ socketTimeout != null ? socketTimeout : DEFAULT_SOCKET_TIMEOUT,
contentCompressionEnabled);
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ConnPoolSupport.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ConnPoolSupport.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ConnPoolSupport.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ConnPoolSupport.java Mon May 1 10:47:09 2017
@@ -27,9 +27,9 @@
package org.apache.hc.client5.http.impl;
import org.apache.hc.client5.http.HttpRoute;
-import org.apache.hc.client5.http.utils.Identifiable;
import org.apache.hc.core5.pool.ConnPoolControl;
import org.apache.hc.core5.pool.PoolStats;
+import org.apache.hc.core5.util.Identifiable;
public final class ConnPoolSupport {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java Mon May 1 10:47:09 2017
@@ -29,14 +29,15 @@ package org.apache.hc.client5.http.impl;
import java.util.Iterator;
import org.apache.hc.client5.http.ConnectionKeepAliveStrategy;
-import org.apache.hc.core5.http.message.MessageSupport;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.HeaderElement;
import org.apache.hc.core5.http.HeaderElements;
import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.message.MessageSupport;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.TimeValue;
/**
* Default implementation of a strategy deciding duration
@@ -53,7 +54,7 @@ public class DefaultConnectionKeepAliveS
public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy();
@Override
- public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
+ public TimeValue getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
Args.notNull(response, "HTTP response");
final Iterator<HeaderElement> it = MessageSupport.iterate(response, HeaderElements.KEEP_ALIVE);
while (it.hasNext()) {
@@ -62,12 +63,12 @@ public class DefaultConnectionKeepAliveS
final String value = he.getValue();
if (value != null && param.equalsIgnoreCase("timeout")) {
try {
- return Long.parseLong(value) * 1000;
+ return TimeValue.ofSeconds(Long.parseLong(value));
} catch(final NumberFormatException ignore) {
}
}
}
- return -1;
+ return TimeValue.NEG_ONE_MILLISECONDS;
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultUserTokenHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultUserTokenHandler.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultUserTokenHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultUserTokenHandler.java Mon May 1 10:47:09 2017
@@ -33,12 +33,10 @@ import javax.net.ssl.SSLSession;
import org.apache.hc.client5.http.HttpRoute;
import org.apache.hc.client5.http.auth.AuthExchange;
import org.apache.hc.client5.http.auth.AuthScheme;
-import org.apache.hc.client5.http.io.ManagedHttpClientConnection;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.protocol.UserTokenHandler;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.http.HttpConnection;
import org.apache.hc.core5.http.protocol.HttpContext;
/**
@@ -77,12 +75,9 @@ public class DefaultUserTokenHandler imp
}
if (userPrincipal == null) {
- final HttpConnection conn = clientContext.getConnection();
- if (conn.isOpen() && conn instanceof ManagedHttpClientConnection) {
- final SSLSession sslsession = ((ManagedHttpClientConnection) conn).getSSLSession();
- if (sslsession != null) {
- userPrincipal = sslsession.getLocalPrincipal();
- }
+ final SSLSession sslSession = clientContext.getSSLSession();
+ if (sslSession != null) {
+ userPrincipal = sslSession.getLocalPrincipal();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java Mon May 1 10:47:09 2017
@@ -30,8 +30,10 @@ package org.apache.hc.client5.http.impl;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
+import org.apache.hc.core5.concurrent.DefaultThreadFactory;
import org.apache.hc.core5.pool.ConnPoolControl;
import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.TimeValue;
/**
* This class maintains a background thread to enforce an eviction policy for expired / idle
@@ -43,52 +45,36 @@ public final class IdleConnectionEvictor
private final ThreadFactory threadFactory;
private final Thread thread;
- private final long sleepTimeMs;
- private final long maxIdleTimeMs;
- private volatile Exception exception;
-
- public IdleConnectionEvictor(
- final ConnPoolControl<?> connectionManager,
- final ThreadFactory threadFactory,
- final long sleepTime, final TimeUnit sleepTimeUnit,
- final long maxIdleTime, final TimeUnit maxIdleTimeUnit) {
+ public IdleConnectionEvictor(final ConnPoolControl<?> connectionManager, final ThreadFactory threadFactory,
+ final TimeValue sleepTime, final TimeValue maxIdleTime) {
Args.notNull(connectionManager, "Connection manager");
this.threadFactory = threadFactory != null ? threadFactory : new DefaultThreadFactory("idle-connection-evictor", true);
- this.sleepTimeMs = sleepTimeUnit != null ? sleepTimeUnit.toMillis(sleepTime) : sleepTime;
- this.maxIdleTimeMs = maxIdleTimeUnit != null ? maxIdleTimeUnit.toMillis(maxIdleTime) : maxIdleTime;
+ final TimeValue localSleepTime = sleepTime != null ? sleepTime : TimeValue.ofSeconds(5);
this.thread = this.threadFactory.newThread(new Runnable() {
@Override
public void run() {
try {
while (!Thread.currentThread().isInterrupted()) {
- Thread.sleep(sleepTimeMs);
+ Thread.sleep(localSleepTime.toMillis());
connectionManager.closeExpired();
- if (maxIdleTimeMs > 0) {
- connectionManager.closeIdle(maxIdleTimeMs, TimeUnit.MILLISECONDS);
+ if (maxIdleTime != null) {
+ connectionManager.closeIdle(maxIdleTime);
}
}
- } catch (final Exception ex) {
- exception = ex;
+ } catch (final Exception ignore) {
}
}
});
}
- public IdleConnectionEvictor(
- final ConnPoolControl<?> connectionManager,
- final long sleepTime, final TimeUnit sleepTimeUnit,
- final long maxIdleTime, final TimeUnit maxIdleTimeUnit) {
- this(connectionManager, null, sleepTime, sleepTimeUnit, maxIdleTime, maxIdleTimeUnit);
+ public IdleConnectionEvictor(final ConnPoolControl<?> connectionManager, final TimeValue sleepTime, final TimeValue maxIdleTime) {
+ this(connectionManager, null, sleepTime, maxIdleTime);
}
- public IdleConnectionEvictor(
- final ConnPoolControl<?> connectionManager,
- final long maxIdleTime, final TimeUnit maxIdleTimeUnit) {
- this(connectionManager, null,
- maxIdleTime > 0 ? maxIdleTime : 5, maxIdleTimeUnit != null ? maxIdleTimeUnit : TimeUnit.SECONDS,
- maxIdleTime, maxIdleTimeUnit);
+ public IdleConnectionEvictor(final ConnPoolControl<?> connectionManager, final TimeValue maxIdleTime) {
+ this(connectionManager, null, maxIdleTime, maxIdleTime);
}
public void start() {
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractHttpAsyncClientBase.java Mon May 1 10:47:09 2017
@@ -30,7 +30,6 @@ import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.hc.core5.function.Callback;
@@ -38,7 +37,7 @@ import org.apache.hc.core5.function.Supp
import org.apache.hc.core5.http.ExceptionListener;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
import org.apache.hc.core5.http.nio.command.ShutdownCommand;
-import org.apache.hc.core5.http.nio.command.ShutdownType;
+import org.apache.hc.core5.io.ShutdownType;
import org.apache.hc.core5.reactor.ConnectionInitiator;
import org.apache.hc.core5.reactor.DefaultConnectingIOReactor;
import org.apache.hc.core5.reactor.ExceptionEvent;
@@ -47,6 +46,7 @@ import org.apache.hc.core5.reactor.IORea
import org.apache.hc.core5.reactor.IOReactorException;
import org.apache.hc.core5.reactor.IOReactorStatus;
import org.apache.hc.core5.reactor.IOSession;
+import org.apache.hc.core5.util.TimeValue;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -138,8 +138,8 @@ abstract class AbstractHttpAsyncClientBa
}
@Override
- public final void awaitShutdown(final long deadline, final TimeUnit timeUnit) throws InterruptedException {
- ioReactor.awaitShutdown(deadline, timeUnit);
+ public final void awaitShutdown(final TimeValue waitTime) throws InterruptedException {
+ ioReactor.awaitShutdown(waitTime);
}
@Override
@@ -148,14 +148,14 @@ abstract class AbstractHttpAsyncClientBa
}
@Override
- public final void shutdown(final long graceTime, final TimeUnit timeUnit) {
+ public final void shutdown(final ShutdownType shutdownType) {
ioReactor.initiateShutdown();
- ioReactor.shutdown(graceTime, timeUnit);
+ ioReactor.shutdown(shutdownType);
}
@Override
public void close() {
- shutdown(5, TimeUnit.SECONDS);
+ shutdown(ShutdownType.GRACEFUL);
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java?rev=1793305&r1=1793304&r2=1793305&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java Mon May 1 10:47:09 2017
@@ -29,9 +29,7 @@ package org.apache.hc.client5.http.impl.
import java.io.Closeable;
import java.util.List;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import org.apache.hc.client5.http.async.AsyncClientEndpoint;
import org.apache.hc.client5.http.async.HttpAsyncClient;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.annotation.Contract;
@@ -39,11 +37,14 @@ import org.apache.hc.core5.annotation.Th
import org.apache.hc.core5.concurrent.FutureCallback;
import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
import org.apache.hc.core5.http.nio.AsyncPushConsumer;
import org.apache.hc.core5.http.nio.AsyncRequestProducer;
import org.apache.hc.core5.http.nio.AsyncResponseConsumer;
+import org.apache.hc.core5.io.ShutdownType;
import org.apache.hc.core5.reactor.ExceptionEvent;
import org.apache.hc.core5.reactor.IOReactorStatus;
+import org.apache.hc.core5.util.TimeValue;
/**
* Base implementation of {@link HttpAsyncClient} that also implements {@link Closeable}.
@@ -59,11 +60,11 @@ public abstract class CloseableHttpAsync
public abstract List<ExceptionEvent> getAuditLog();
- public abstract void awaitShutdown(long deadline, TimeUnit timeUnit) throws InterruptedException;
+ public abstract void awaitShutdown(TimeValue waitTime) throws InterruptedException;
public abstract void initiateShutdown();
- public abstract void shutdown(long graceTime, TimeUnit timeUnit);
+ public abstract void shutdown(ShutdownType shutdownType);
public final Future<AsyncClientEndpoint> lease(
final HttpHost host,