From 3aec96d3dbbc1a167e0be376c4734d5c246e9bf3 Mon Sep 17 00:00:00 2001 From: Ryan Schmitt Date: Wed, 11 Dec 2019 15:11:29 -0800 Subject: [PATCH] Upgraded HttpCore to version 5.0-beta11 --- .../http/impl/cache/BasicHttpAsyncCache.java | 6 +- .../http/impl/cache/BasicHttpCache.java | 6 +- .../cache/DefaultAsyncCacheRevalidator.java | 2 +- .../ExponentialBackOffSchedulingStrategy.java | 4 +- .../http/cache/TestHttpCacheEntry.java | 6 +- .../hc/client5/http/fluent/Request.java | 4 +- .../AbstractHttpAsyncFundamentalsTest.java | 6 +- .../TestHttp1AsyncStatefulConnManagement.java | 2 +- .../testing/async/TestHttpAsyncMinimal.java | 4 +- ...chingHttpAsyncClientCompatibilityTest.java | 2 +- .../CachingHttpClientCompatibilityTest.java | 2 +- .../HttpAsyncClientCompatibilityTest.java | 10 ++-- .../external/HttpClientCompatibilityTest.java | 10 ++-- .../testing/sync/LocalServerTestBase.java | 12 +++- .../sync/TestConnectionManagement.java | 22 ++++---- .../sync/TestStatefulConnManagement.java | 2 +- .../http/async/methods/HttpRequests.java | 34 +++++------ .../http/async/methods/SimpleHttpRequest.java | 6 +- .../async/methods/SimpleHttpRequests.java | 34 +++++------ .../DefaultConnectionKeepAliveStrategy.java | 2 +- .../impl/DefaultHttpRequestRetryStrategy.java | 4 +- .../http/impl/IdleConnectionEvictor.java | 2 +- .../http/impl/async/AsyncProtocolExec.java | 4 +- .../http/impl/async/AsyncRedirectExec.java | 6 +- .../async/InternalHttpAsyncExecRuntime.java | 2 +- .../http/impl/async/LoggingIOSession.java | 2 +- .../impl/async/MinimalHttpAsyncClient.java | 2 +- .../http/impl/classic/AIMDBackoffManager.java | 6 +- .../impl/classic/InternalExecRuntime.java | 2 +- .../http/impl/classic/MinimalHttpClient.java | 2 +- .../http/impl/classic/ProtocolExec.java | 4 +- .../http/impl/classic/RedirectExec.java | 4 +- .../io/BasicHttpClientConnectionManager.java | 4 +- .../DefaultHttpClientConnectionOperator.java | 4 +- .../PoolingHttpClientConnectionManager.java | 4 +- ...ingHttpClientConnectionManagerBuilder.java | 2 +- .../PoolingAsyncClientConnectionManager.java | 4 +- .../socket/PlainConnectionSocketFactory.java | 2 +- .../http/ssl/AbstractClientTlsStrategy.java | 4 +- .../http/ssl/ClientTlsStrategyBuilder.java | 2 +- .../http/ssl/SSLConnectionSocketFactory.java | 4 +- .../SSLConnectionSocketFactoryBuilder.java | 2 +- .../client5/http/cookie/TestCookieOrigin.java | 4 +- .../examples/AsyncClientH2ServerPush.java | 4 +- .../AsyncClientHttpExchangeStreaming.java | 4 +- .../http/examples/ClientExecuteSOCKS.java | 2 +- .../http/impl/TestAuthenticationStrategy.java | 12 ++-- .../TestDefaultConnKeepAliveStrategy.java | 8 +-- .../impl/TestDefaultRedirectStrategy.java | 20 +++---- .../http/impl/auth/TestBasicAuthCache.java | 2 +- .../http/impl/auth/TestDigestScheme.java | 12 ++-- .../http/impl/auth/TestRequestAuthCache.java | 4 +- .../classic/TestContentCompressionExec.java | 20 +++---- .../impl/cookie/TestBasicClientCookie.java | 4 +- .../cookie/TestBasicCookieAttribHandlers.java | 56 +++++++++---------- .../cookie/TestLaxCookieAttribHandlers.java | 4 +- .../TestBasicHttpClientConnectionManager.java | 12 ++-- ...estPoolingHttpClientConnectionManager.java | 22 ++++---- .../http/impl/routing/TestRouteDirector.java | 2 +- .../http/impl/routing/TestRouteTracker.java | 10 ++-- .../http/protocol/TestRequestAddCookies.java | 4 +- .../TestRequestClientConnControl.java | 2 +- .../protocol/TestRequestDefaultHeaders.java | 2 +- .../protocol/TestRequestExpectContinue.java | 4 +- .../protocol/TestResponseProcessCookies.java | 4 +- .../client5/http/routing/TestHttpRoute.java | 4 +- .../hc/client5/http/utils/TestDateUtils.java | 12 ++-- pom.xml | 2 +- 68 files changed, 246 insertions(+), 238 deletions(-) diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java index 9494d2ffb..0d8d53c5c 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java @@ -47,7 +47,7 @@ import org.apache.hc.core5.http.Header; 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.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.message.RequestLine; import org.apache.hc.core5.http.message.StatusLine; import org.apache.hc.core5.util.ByteArrayBuffer; @@ -100,7 +100,7 @@ class BasicHttpAsyncCache implements HttpAsyncCache { if (log.isDebugEnabled()) { log.debug("Flush cache entries: " + host + "; " + new RequestLine(request)); } - if (!Methods.isSafe(request.getMethod())) { + if (!Method.isSafe(request.getMethod())) { final String cacheKey = cacheKeyGenerator.generateKey(host, request); return storage.removeEntry(cacheKey, new FutureCallback() { @@ -147,7 +147,7 @@ class BasicHttpAsyncCache implements HttpAsyncCache { if (log.isDebugEnabled()) { log.debug("Flush cache entries invalidated by exchange: " + host + "; " + new RequestLine(request) + " -> " + new StatusLine(response)); } - if (!Methods.isSafe(request.getMethod())) { + if (!Method.isSafe(request.getMethod())) { return cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage, callback); } callback.completed(Boolean.TRUE); diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java index 14b3638a7..8a01a9f4d 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java @@ -42,7 +42,7 @@ import org.apache.hc.core5.http.Header; 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.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.message.RequestLine; import org.apache.hc.core5.http.message.StatusLine; import org.apache.hc.core5.util.ByteArrayBuffer; @@ -102,7 +102,7 @@ class BasicHttpCache implements HttpCache { if (log.isDebugEnabled()) { log.debug("Flush cache entries: " + host + "; " + new RequestLine(request)); } - if (!Methods.isSafe(request.getMethod())) { + if (!Method.isSafe(request.getMethod())) { final String cacheKey = cacheKeyGenerator.generateKey(host, request); try { storage.removeEntry(cacheKey); @@ -127,7 +127,7 @@ class BasicHttpCache implements HttpCache { if (log.isDebugEnabled()) { log.debug("Flush cache entries invalidated by exchange: " + host + "; " + new RequestLine(request) + " -> " + new StatusLine(response)); } - if (!Methods.isSafe(request.getMethod())) { + if (!Method.isSafe(request.getMethod())) { cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage); } } diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java index 5468cec3e..255622dc3 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/DefaultAsyncCacheRevalidator.java @@ -64,7 +64,7 @@ class DefaultAsyncCacheRevalidator extends CacheRevalidatorBase { @Override public Future schedule(final Runnable command, final TimeValue timeValue) throws RejectedExecutionException { - if (timeValue.toMillis() <= 0) { + if (timeValue.toMilliseconds() <= 0) { command.run(); return new Operations.CompletedFuture(null); } diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java index af70789bd..29629e118 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java @@ -108,8 +108,8 @@ public class ExponentialBackOffSchedulingStrategy implements SchedulingStrategy protected TimeValue calculateDelay(final int consecutiveFailedAttempts) { if (consecutiveFailedAttempts > 0) { - final long delay = (long) (initialExpiry.toMillis() * Math.pow(backOffRate, consecutiveFailedAttempts - 1)); - return TimeValue.ofMilliseconds(Math.min(delay, maxExpiry.toMillis())); + final long delay = (long) (initialExpiry.toMilliseconds() * Math.pow(backOffRate, consecutiveFailedAttempts - 1)); + return TimeValue.ofMilliseconds(Math.min(delay, maxExpiry.toMilliseconds())); } return TimeValue.ZERO_MILLISECONDS; } diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java index bfeca364f..88b8cbcc3 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java @@ -142,7 +142,7 @@ public class TestHttpCacheEntry { try { new HttpCacheEntry(null, new Date(), HttpStatus.SC_OK, new Header[]{}, mockResource); fail("Should have thrown exception"); - } catch (final IllegalArgumentException expected) { + } catch (final NullPointerException expected) { } } @@ -152,7 +152,7 @@ public class TestHttpCacheEntry { try { new HttpCacheEntry(new Date(), null, HttpStatus.SC_OK, new Header[]{}, mockResource); fail("Should have thrown exception"); - } catch (final IllegalArgumentException expected) { + } catch (final NullPointerException expected) { } } @@ -162,7 +162,7 @@ public class TestHttpCacheEntry { try { new HttpCacheEntry(new Date(), new Date(), HttpStatus.SC_OK, null, mockResource); fail("Should have thrown exception"); - } catch (final IllegalArgumentException expected) { + } catch (final NullPointerException expected) { } } diff --git a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java index 339abee1c..dee0a9a90 100644 --- a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java +++ b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java @@ -55,7 +55,7 @@ import org.apache.hc.core5.http.HttpEntity; import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpVersion; -import org.apache.hc.core5.http.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.NameValuePair; import org.apache.hc.core5.http.io.entity.ByteArrayEntity; import org.apache.hc.core5.http.io.entity.FileEntity; @@ -81,7 +81,7 @@ public class Request { private SimpleDateFormat dateFormatter; - public static Request create(final Methods method, final URI uri) { + public static Request create(final Method method, final URI uri) { return new Request(new HttpUriRequestBase(method.name(), uri)); } diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java index 33a47f22c..4c8882e5b 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java @@ -45,7 +45,7 @@ import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.Message; -import org.apache.hc.core5.http.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.URIScheme; import org.apache.hc.core5.http.nio.entity.AsyncEntityProducers; import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityConsumer; @@ -98,7 +98,7 @@ public abstract class AbstractHttpAsyncFundamentalsTest> future = httpclient.execute( - new BasicRequestProducer(Methods.GET, target, "/echo/", + new BasicRequestProducer(Method.GET, target, "/echo/", AsyncEntityProducers.create(b1, ContentType.APPLICATION_OCTET_STREAM)), new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null); final Message responseMessage = future.get(); @@ -122,7 +122,7 @@ public abstract class AbstractHttpAsyncFundamentalsTest>> queue = new LinkedList<>(); for (int i = 0; i < reqCount; i++) { final Future> future = httpclient.execute( - new BasicRequestProducer(Methods.POST, target, "/echo/", + new BasicRequestProducer(Method.POST, target, "/echo/", AsyncEntityProducers.create(b1, ContentType.APPLICATION_OCTET_STREAM)), new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null); queue.add(future); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java index 32c68e99f..553dcb967 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java @@ -157,7 +157,7 @@ public class TestHttp1AsyncStatefulConnManagement extends AbstractIntegrationTes worker.start(); } for (final HttpWorker worker : workers) { - worker.join(LONG_TIMEOUT.toMillis()); + worker.join(LONG_TIMEOUT.toMilliseconds()); } for (final HttpWorker worker : workers) { final Exception ex = worker.getException(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncMinimal.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncMinimal.java index 23eb5f084..377d4109b 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncMinimal.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncMinimal.java @@ -46,7 +46,7 @@ import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpVersion; import org.apache.hc.core5.http.Message; -import org.apache.hc.core5.http.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.URIScheme; import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.nio.AsyncClientEndpoint; @@ -124,7 +124,7 @@ public class TestHttpAsyncMinimal extends AbstractHttpAsyncFundamentalsTest>> queue = new LinkedList<>(); for (int i = 0; i < reqCount; i++) { final Future> future = endpoint.execute( - new BasicRequestProducer(Methods.GET, target, "/echo/", + new BasicRequestProducer(Method.GET, target, "/echo/", AsyncEntityProducers.create(b1, ContentType.APPLICATION_OCTET_STREAM)), new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null); queue.add(future); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java index 7262f8819..4f65936b6 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpAsyncClientCompatibilityTest.java @@ -150,7 +150,7 @@ public class CachingHttpAsyncClientCompatibilityTest { } // GET with links { - connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); + connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND); final HttpCacheContext context = HttpCacheContext.create(); final Pattern linkPattern = Pattern.compile("^<(.*)>;rel=preload$"); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java index 6c248b237..4f8654ff2 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/CachingHttpClientCompatibilityTest.java @@ -132,7 +132,7 @@ public class CachingHttpClientCompatibilityTest { } // GET with links { - connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); + connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND); final HttpCacheContext context = HttpCacheContext.create(); final Pattern linkPattern = Pattern.compile("^<(.*)>;rel=preload$"); final List links = new ArrayList<>(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java index 7132afb2e..93d854c45 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpAsyncClientCompatibilityTest.java @@ -187,7 +187,7 @@ public class HttpAsyncClientCompatibilityTest { } // Basic GET requests { - connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); + connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND); final HttpClientContext context = HttpClientContext.create(); context.setCredentialsProvider(credentialsProvider); @@ -213,7 +213,7 @@ public class HttpAsyncClientCompatibilityTest { } // Wrong target auth scope { - connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); + connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND); credentialsProvider.setCredentials( new AuthScope("http", "otherhost", -1, "Restricted Files", null), new UsernamePasswordCredentials("testuser", "nopassword".toCharArray())); @@ -239,7 +239,7 @@ public class HttpAsyncClientCompatibilityTest { } // Wrong target credentials { - connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); + connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND); credentialsProvider.setCredentials( new AuthScope(target), new UsernamePasswordCredentials("testuser", "wrong password".toCharArray())); @@ -265,7 +265,7 @@ public class HttpAsyncClientCompatibilityTest { } // Correct target credentials { - connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); + connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND); credentialsProvider.setCredentials( new AuthScope(target), new UsernamePasswordCredentials("testuser", "nopassword".toCharArray())); @@ -292,7 +292,7 @@ public class HttpAsyncClientCompatibilityTest { // Correct target credentials (no keep-alive) if (protocolVersion.lessEquals(HttpVersion.HTTP_1_1)) { - connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); + connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND); credentialsProvider.setCredentials( new AuthScope(target), new UsernamePasswordCredentials("testuser", "nopassword".toCharArray())); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java index e1f3f8bc7..ca8eaef97 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/external/HttpClientCompatibilityTest.java @@ -157,7 +157,7 @@ public class HttpClientCompatibilityTest { } // Basic GET requests { - connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); + connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND); 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(TimeValue.NEG_ONE_MILLISECONDS); + connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND); credentialsProvider.setCredentials( new AuthScope("http", "otherhost", -1, "Restricted Files", null), new UsernamePasswordCredentials("testuser", "nopassword".toCharArray())); @@ -200,7 +200,7 @@ public class HttpClientCompatibilityTest { } // Wrong target credentials { - connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); + connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND); credentialsProvider.setCredentials( new AuthScope(target), new UsernamePasswordCredentials("testuser", "wrong password".toCharArray())); @@ -222,7 +222,7 @@ public class HttpClientCompatibilityTest { } // Correct target credentials { - connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); + connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND); 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(TimeValue.NEG_ONE_MILLISECONDS); + connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND); credentialsProvider.setCredentials( new AuthScope(target), new UsernamePasswordCredentials("testuser", "nopassword".toCharArray())); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/LocalServerTestBase.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/LocalServerTestBase.java index d0cda8bf4..07a98b553 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/LocalServerTestBase.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/LocalServerTestBase.java @@ -39,6 +39,7 @@ import org.apache.hc.client5.testing.classic.RandomHandler; import org.apache.hc.core5.function.Decorator; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.URIScheme; +import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.io.HttpServerRequestHandler; import org.apache.hc.core5.http.io.SocketConfig; import org.apache.hc.core5.http.protocol.HttpProcessor; @@ -126,9 +127,10 @@ public abstract class LocalServerTestBase { }; public HttpHost start( + final Http1Config http1Config, final HttpProcessor httpProcessor, final Decorator handlerDecorator) throws IOException { - this.server.start(httpProcessor, handlerDecorator); + this.server.start(http1Config, httpProcessor, handlerDecorator); if (this.httpclient == null) { this.httpclient = this.clientBuilder.build(); @@ -137,8 +139,14 @@ public abstract class LocalServerTestBase { return new HttpHost(this.scheme.name(), "localhost", this.server.getPort()); } + public HttpHost start( + final HttpProcessor httpProcessor, + final Decorator handlerDecorator) throws IOException { + return start(null, httpProcessor, handlerDecorator); + } + public HttpHost start() throws Exception { - return start(null, null); + return start(null, null, null); } } diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java index a0fbc9f23..3dd759826 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java @@ -82,7 +82,7 @@ public class TestConnectionManagement extends LocalServerTestBase { final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null); final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS); - this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECONDS, context); + this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECOND, context); final HttpProcessor httpProcessor = new DefaultHttpProcessor( new RequestTargetHost(), new RequestContent(), new RequestConnControl()); @@ -104,12 +104,12 @@ public class TestConnectionManagement extends LocalServerTestBase { } endpoint1.close(); - this.connManager.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); + this.connManager.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND); final LeaseRequest leaseRequest2 = this.connManager.lease("id2", route,null); final ConnectionEndpoint endpoint2 = leaseRequest2.get(Timeout.ZERO_MILLISECONDS); Assert.assertFalse(endpoint2.isConnected()); - this.connManager.connect(endpoint2, TimeValue.NEG_ONE_MILLISECONDS, context); + this.connManager.connect(endpoint2, TimeValue.NEG_ONE_MILLISECOND, context); try (final ClassicHttpResponse response2 = endpoint2.execute("id2", request, exec, context)) { Assert.assertEquals(HttpStatus.SC_OK, response2.getCode()); @@ -117,7 +117,7 @@ public class TestConnectionManagement extends LocalServerTestBase { // release connection after marking it for re-use // expect the next connection obtained to be open - this.connManager.release(endpoint2, null, TimeValue.NEG_ONE_MILLISECONDS); + this.connManager.release(endpoint2, null, TimeValue.NEG_ONE_MILLISECOND); final LeaseRequest leaseRequest3 = this.connManager.lease("id3", route,null); final ConnectionEndpoint endpoint3 = leaseRequest3.get(Timeout.ZERO_MILLISECONDS); @@ -128,7 +128,7 @@ public class TestConnectionManagement extends LocalServerTestBase { Assert.assertEquals(HttpStatus.SC_OK, response3.getCode()); } - this.connManager.release(endpoint3, null, TimeValue.NEG_ONE_MILLISECONDS); + this.connManager.release(endpoint3, null, TimeValue.NEG_ONE_MILLISECOND); this.connManager.close(); } @@ -150,7 +150,7 @@ public class TestConnectionManagement extends LocalServerTestBase { final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null); final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS); - this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECONDS, context); + this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECOND, context); final HttpProcessor httpProcessor = new DefaultHttpProcessor( new RequestTargetHost(), new RequestContent(), new RequestConnControl()); @@ -178,7 +178,7 @@ public class TestConnectionManagement extends LocalServerTestBase { final ConnectionEndpoint endpoint2 = leaseRequest2.get(Timeout.ZERO_MILLISECONDS); Assert.assertFalse(endpoint2.isConnected()); - this.connManager.connect(endpoint2, TimeValue.NEG_ONE_MILLISECONDS, context); + this.connManager.connect(endpoint2, TimeValue.NEG_ONE_MILLISECOND, context); try (final ClassicHttpResponse response2 = endpoint2.execute("id2", request, exec, context)) { Assert.assertEquals(HttpStatus.SC_OK, response2.getCode()); @@ -203,7 +203,7 @@ public class TestConnectionManagement extends LocalServerTestBase { Assert.assertFalse(endpoint4.isConnected()); // repeat the communication, no need to prepare the request again - this.connManager.connect(endpoint4, TimeValue.NEG_ONE_MILLISECONDS, context); + this.connManager.connect(endpoint4, TimeValue.NEG_ONE_MILLISECOND, context); try (final ClassicHttpResponse response4 = endpoint4.execute("id4", request, exec, context)) { Assert.assertEquals(HttpStatus.SC_OK, response4.getCode()); @@ -223,7 +223,7 @@ public class TestConnectionManagement extends LocalServerTestBase { final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null); final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS); - this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECONDS, context); + this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECOND, context); Assert.assertEquals(1, this.connManager.getTotalStats().getLeased()); Assert.assertEquals(1, this.connManager.getStats(route).getLeased()); @@ -272,12 +272,12 @@ public class TestConnectionManagement extends LocalServerTestBase { final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null); final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS); - this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECONDS, context); + this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECOND, context); Assert.assertEquals(1, this.connManager.getTotalStats().getLeased()); Assert.assertEquals(1, this.connManager.getStats(route).getLeased()); // Release, let remain idle for forever - this.connManager.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); + this.connManager.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND); // Released, still active. Assert.assertEquals(1, this.connManager.getTotalStats().getAvailable()); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java index cadf7681b..418550f44 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java @@ -107,7 +107,7 @@ public class TestStatefulConnManagement extends LocalServerTestBase { worker.start(); } for (final HttpWorker worker : workers) { - worker.join(LONG_TIMEOUT.toMillis()); + worker.join(LONG_TIMEOUT.toMilliseconds()); } for (final HttpWorker worker : workers) { final Exception ex = worker.getException(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/HttpRequests.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/HttpRequests.java index 436eee8f7..46e3779fd 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/HttpRequests.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/HttpRequests.java @@ -30,7 +30,7 @@ package org.apache.hc.client5.http.async.methods; import java.net.URI; import org.apache.hc.core5.http.HttpHost; -import org.apache.hc.core5.http.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.message.BasicHttpRequest; /** @@ -43,96 +43,96 @@ public enum HttpRequests { DELETE { @Override public BasicHttpRequest create(final URI uri) { - return new BasicHttpRequest(Methods.DELETE, uri); + return new BasicHttpRequest(Method.DELETE, uri); } @Override public BasicHttpRequest create(final HttpHost host, final String path) { - return new BasicHttpRequest(Methods.DELETE, host, path); + return new BasicHttpRequest(Method.DELETE, host, path); } }, GET { @Override public BasicHttpRequest create(final URI uri) { - return new BasicHttpRequest(Methods.GET, uri); + return new BasicHttpRequest(Method.GET, uri); } @Override public BasicHttpRequest create(final HttpHost host, final String path) { - return new BasicHttpRequest(Methods.GET, host, path); + return new BasicHttpRequest(Method.GET, host, path); } }, HEAD { @Override public BasicHttpRequest create(final URI uri) { - return new BasicHttpRequest(Methods.HEAD, uri); + return new BasicHttpRequest(Method.HEAD, uri); } @Override public BasicHttpRequest create(final HttpHost host, final String path) { - return new BasicHttpRequest(Methods.HEAD, host, path); + return new BasicHttpRequest(Method.HEAD, host, path); } }, OPTIONS { @Override public BasicHttpRequest create(final URI uri) { - return new BasicHttpRequest(Methods.OPTIONS, uri); + return new BasicHttpRequest(Method.OPTIONS, uri); } @Override public BasicHttpRequest create(final HttpHost host, final String path) { - return new BasicHttpRequest(Methods.OPTIONS, host, path); + return new BasicHttpRequest(Method.OPTIONS, host, path); } }, PATCH { @Override public BasicHttpRequest create(final URI uri) { - return new BasicHttpRequest(Methods.PATCH, uri); + return new BasicHttpRequest(Method.PATCH, uri); } @Override public BasicHttpRequest create(final HttpHost host, final String path) { - return new BasicHttpRequest(Methods.PATCH, host, path); + return new BasicHttpRequest(Method.PATCH, host, path); } }, POST { @Override public BasicHttpRequest create(final URI uri) { - return new BasicHttpRequest(Methods.POST, uri); + return new BasicHttpRequest(Method.POST, uri); } @Override public BasicHttpRequest create(final HttpHost host, final String path) { - return new BasicHttpRequest(Methods.POST, host, path); + return new BasicHttpRequest(Method.POST, host, path); } }, PUT { @Override public BasicHttpRequest create(final URI uri) { - return new BasicHttpRequest(Methods.PUT, uri); + return new BasicHttpRequest(Method.PUT, uri); } @Override public BasicHttpRequest create(final HttpHost host, final String path) { - return new BasicHttpRequest(Methods.PUT, host, path); + return new BasicHttpRequest(Method.PUT, host, path); } }, TRACE { @Override public BasicHttpRequest create(final URI uri) { - return new BasicHttpRequest(Methods.TRACE, uri); + return new BasicHttpRequest(Method.TRACE, uri); } @Override public BasicHttpRequest create(final HttpHost host, final String path) { - return new BasicHttpRequest(Methods.TRACE, host, path); + return new BasicHttpRequest(Method.TRACE, host, path); } }; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java index efb63de2c..aad4a8530 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequest.java @@ -34,7 +34,7 @@ import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpRequest; -import org.apache.hc.core5.http.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.util.Args; /** @@ -73,11 +73,11 @@ public final class SimpleHttpRequest extends ConfigurableHttpRequest { super(method, requestUri); } - SimpleHttpRequest(final Methods method, final URI requestUri) { + SimpleHttpRequest(final Method method, final URI requestUri) { this(method.name(), requestUri); } - SimpleHttpRequest(final Methods method, final HttpHost host, final String path) { + SimpleHttpRequest(final Method method, final HttpHost host, final String path) { this(method.name(), host, path); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequests.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequests.java index 13f5d7e33..d04aa4827 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequests.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleHttpRequests.java @@ -30,7 +30,7 @@ package org.apache.hc.client5.http.async.methods; import java.net.URI; import org.apache.hc.core5.http.HttpHost; -import org.apache.hc.core5.http.Methods; +import org.apache.hc.core5.http.Method; /** * Common HTTP methods using {@link SimpleHttpRequest} as a HTTP request message representation. @@ -42,96 +42,96 @@ public enum SimpleHttpRequests { DELETE { @Override public SimpleHttpRequest create(final URI uri) { - return new SimpleHttpRequest(Methods.DELETE, uri); + return new SimpleHttpRequest(Method.DELETE, uri); } @Override public SimpleHttpRequest create(final HttpHost host, final String path) { - return new SimpleHttpRequest(Methods.DELETE, host, path); + return new SimpleHttpRequest(Method.DELETE, host, path); } }, GET { @Override public SimpleHttpRequest create(final URI uri) { - return new SimpleHttpRequest(Methods.GET, uri); + return new SimpleHttpRequest(Method.GET, uri); } @Override public SimpleHttpRequest create(final HttpHost host, final String path) { - return new SimpleHttpRequest(Methods.GET, host, path); + return new SimpleHttpRequest(Method.GET, host, path); } }, HEAD { @Override public SimpleHttpRequest create(final URI uri) { - return new SimpleHttpRequest(Methods.HEAD, uri); + return new SimpleHttpRequest(Method.HEAD, uri); } @Override public SimpleHttpRequest create(final HttpHost host, final String path) { - return new SimpleHttpRequest(Methods.HEAD, host, path); + return new SimpleHttpRequest(Method.HEAD, host, path); } }, OPTIONS { @Override public SimpleHttpRequest create(final URI uri) { - return new SimpleHttpRequest(Methods.OPTIONS, uri); + return new SimpleHttpRequest(Method.OPTIONS, uri); } @Override public SimpleHttpRequest create(final HttpHost host, final String path) { - return new SimpleHttpRequest(Methods.OPTIONS, host, path); + return new SimpleHttpRequest(Method.OPTIONS, host, path); } }, PATCH { @Override public SimpleHttpRequest create(final URI uri) { - return new SimpleHttpRequest(Methods.PATCH, uri); + return new SimpleHttpRequest(Method.PATCH, uri); } @Override public SimpleHttpRequest create(final HttpHost host, final String path) { - return new SimpleHttpRequest(Methods.PATCH, host, path); + return new SimpleHttpRequest(Method.PATCH, host, path); } }, POST { @Override public SimpleHttpRequest create(final URI uri) { - return new SimpleHttpRequest(Methods.POST, uri); + return new SimpleHttpRequest(Method.POST, uri); } @Override public SimpleHttpRequest create(final HttpHost host, final String path) { - return new SimpleHttpRequest(Methods.POST, host, path); + return new SimpleHttpRequest(Method.POST, host, path); } }, PUT { @Override public SimpleHttpRequest create(final URI uri) { - return new SimpleHttpRequest(Methods.PUT, uri); + return new SimpleHttpRequest(Method.PUT, uri); } @Override public SimpleHttpRequest create(final HttpHost host, final String path) { - return new SimpleHttpRequest(Methods.PUT, host, path); + return new SimpleHttpRequest(Method.PUT, host, path); } }, TRACE { @Override public SimpleHttpRequest create(final URI uri) { - return new SimpleHttpRequest(Methods.TRACE, uri); + return new SimpleHttpRequest(Method.TRACE, uri); } @Override public SimpleHttpRequest create(final HttpHost host, final String path) { - return new SimpleHttpRequest(Methods.TRACE, host, path); + return new SimpleHttpRequest(Method.TRACE, host, path); } }; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java index 3c4c225b0..9be7b8ee9 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java @@ -69,7 +69,7 @@ public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveSt } } } - return TimeValue.NEG_ONE_MILLISECONDS; + return TimeValue.NEG_ONE_MILLISECOND; } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryStrategy.java index adef6bf32..513ccc2bc 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryStrategy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryStrategy.java @@ -50,7 +50,7 @@ import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpStatus; -import org.apache.hc.core5.http.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.protocol.HttpContext; import org.apache.hc.core5.util.Args; import org.apache.hc.core5.util.TimeValue; @@ -226,7 +226,7 @@ public class DefaultHttpRequestRetryStrategy implements HttpRequestRetryStrategy } protected boolean handleAsIdempotent(final HttpRequest request) { - return Methods.isIdempotent(request.getMethod()); + return Method.isIdempotent(request.getMethod()); } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java index 1e7258e65..2950c2b7d 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java @@ -95,7 +95,7 @@ public final class IdleConnectionEvictor { } public void awaitTermination(final Timeout timeout) throws InterruptedException { - thread.join(timeout != null ? timeout.toMillis() : Long.MAX_VALUE); + thread.join(timeout != null ? timeout.toMilliseconds() : Long.MAX_VALUE); } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java index 0f18fe18d..11fd40a04 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java @@ -57,7 +57,7 @@ import org.apache.hc.core5.http.HttpHeaders; 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.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.ProtocolException; import org.apache.hc.core5.http.nio.AsyncDataConsumer; import org.apache.hc.core5.http.nio.AsyncEntityProducer; @@ -181,7 +181,7 @@ public final class AsyncProtocolExec implements AsyncExecChainHandler { clientContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response); httpProcessor.process(response, entityDetails, clientContext); - if (Methods.TRACE.isSame(request.getMethod())) { + if (Method.TRACE.isSame(request.getMethod())) { // Do not perform authentication for TRACE request return asyncExecCallback.handleResponse(response, entityDetails); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java index 53d5b7e34..ef7a138a5 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java @@ -51,7 +51,7 @@ 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.HttpStatus; -import org.apache.hc.core5.http.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.ProtocolException; import org.apache.hc.core5.http.message.BasicHttpRequest; import org.apache.hc.core5.http.nio.AsyncDataConsumer; @@ -143,8 +143,8 @@ public final class AsyncRedirectExec implements AsyncExecChainHandler { case HttpStatus.SC_MOVED_PERMANENTLY: case HttpStatus.SC_MOVED_TEMPORARILY: case HttpStatus.SC_SEE_OTHER: - if (!Methods.isSafe(request.getMethod())) { - state.currentRequest = new BasicHttpRequest(Methods.GET, redirectUri); + if (!Method.isSafe(request.getMethod())) { + state.currentRequest = new BasicHttpRequest(Method.GET, redirectUri); state.currentEntityProducer = null; } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java index c6cb2a4e7..52f804fec 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncExecRuntime.java @@ -75,7 +75,7 @@ class InternalHttpAsyncExecRuntime implements AsyncExecRuntime { this.pushHandlerFactory = pushHandlerFactory; this.versionPolicy = versionPolicy; this.endpointRef = new AtomicReference<>(null); - this.validDuration = TimeValue.NEG_ONE_MILLISECONDS; + this.validDuration = TimeValue.NEG_ONE_MILLISECOND; } @Override diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingIOSession.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingIOSession.java index 7d411edbe..5005b3258 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingIOSession.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingIOSession.java @@ -162,7 +162,7 @@ class LoggingIOSession implements IOSession { } @Override - public int getStatus() { + public Status getStatus() { return this.session.getStatus(); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java index e74cf3d53..65af82025 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java @@ -478,7 +478,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient @Override public void releaseAndReuse() { if (released.compareAndSet(false, true)) { - manager.release(connectionEndpoint, null, TimeValue.NEG_ONE_MILLISECONDS); + manager.release(connectionEndpoint, null, TimeValue.NEG_ONE_MILLISECOND); } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/AIMDBackoffManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/AIMDBackoffManager.java index 522019875..c22cb21ae 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/AIMDBackoffManager.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/AIMDBackoffManager.java @@ -91,7 +91,7 @@ public class AIMDBackoffManager implements BackoffManager { final int curr = connPerRoute.getMaxPerRoute(route); final Long lastUpdate = getLastUpdate(lastRouteBackoffs, route); final long now = clock.getCurrentTime(); - if (now - lastUpdate.longValue() < coolDown.toMillis()) { + if (now - lastUpdate.longValue() < coolDown.toMilliseconds()) { return; } connPerRoute.setMaxPerRoute(route, getBackedOffPoolSize(curr)); @@ -114,8 +114,8 @@ public class AIMDBackoffManager implements BackoffManager { final Long lastProbe = getLastUpdate(lastRouteProbes, route); final Long lastBackoff = getLastUpdate(lastRouteBackoffs, route); final long now = clock.getCurrentTime(); - if (now - lastProbe.longValue() < coolDown.toMillis() - || now - lastBackoff.longValue() < coolDown.toMillis()) { + if (now - lastProbe.longValue() < coolDown.toMilliseconds() + || now - lastBackoff.longValue() < coolDown.toMilliseconds()) { return; } connPerRoute.setMaxPerRoute(route, max); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java index 49a9b15cf..7931943ff 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalExecRuntime.java @@ -77,7 +77,7 @@ class InternalExecRuntime implements ExecRuntime, Cancellable { this.requestExecutor = requestExecutor; this.cancellableDependency = cancellableDependency; this.endpointRef = new AtomicReference<>(null); - this.validDuration = TimeValue.NEG_ONE_MILLISECONDS; + this.validDuration = TimeValue.NEG_ONE_MILLISECOND; } @Override diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java index 5dfb6623c..3d074d536 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MinimalHttpClient.java @@ -150,7 +150,7 @@ public class MinimalHttpClient extends CloseableHttpClient { httpProcessor.process(response, response.getEntity(), context); if (reuseStrategy.keepAlive(request, response, context)) { - execRuntime.markConnectionReusable(null, TimeValue.NEG_ONE_MILLISECONDS); + execRuntime.markConnectionReusable(null, TimeValue.NEG_ONE_MILLISECOND); } else { execRuntime.markConnectionNonReusable(); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java index e74b0d47f..756f9bd9f 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java @@ -57,7 +57,7 @@ import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpResponse; -import org.apache.hc.core5.http.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.ProtocolException; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.protocol.HttpCoreContext; @@ -167,7 +167,7 @@ public final class ProtocolExec implements ExecChainHandler { context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response); httpProcessor.process(response, response.getEntity(), context); - if (Methods.TRACE.isSame(request.getMethod())) { + if (Method.TRACE.isSame(request.getMethod())) { // Do not perform authentication for TRACE request return response; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java index d2503e638..bdd32191a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java @@ -52,7 +52,7 @@ import org.apache.hc.core5.http.HttpEntity; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpStatus; -import org.apache.hc.core5.http.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.ProtocolException; import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.message.BasicClassicHttpRequest; @@ -146,7 +146,7 @@ public final class RedirectExec implements ExecChainHandler { case HttpStatus.SC_MOVED_PERMANENTLY: case HttpStatus.SC_MOVED_TEMPORARILY: case HttpStatus.SC_SEE_OTHER: - if (!Methods.isSafe(request.getMethod())) { + if (!Method.isSafe(request.getMethod())) { redirect = new HttpGet(redirectUri); } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java index 3eff4593d..eaa10e4ff 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java @@ -280,7 +280,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan if (this.log.isDebugEnabled()) { this.log.debug("Connection can be kept alive for " + keepAlive); } - this.expiry = this.updated + keepAlive.toMillis(); + this.expiry = this.updated + keepAlive.toMilliseconds(); } else { if (this.log.isDebugEnabled()) { this.log.debug("Connection can be kept alive indefinitely"); @@ -345,7 +345,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan return; } if (!this.leased) { - long time = idleTime.toMillis(); + long time = idleTime.toMilliseconds(); if (time < 0) { time = 0; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java index 2f0b5f28b..7e9964b23 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java @@ -123,7 +123,7 @@ public class DefaultHttpClientConnectionOperator implements HttpClientConnection final boolean last = i == addresses.length - 1; Socket sock = sf.createSocket(context); - sock.setSoTimeout(socketConfig.getSoTimeout().toMillisIntBound()); + sock.setSoTimeout(socketConfig.getSoTimeout().toMillisecondsIntBound()); sock.setReuseAddress(socketConfig.isSoReuseAddress()); sock.setTcpNoDelay(socketConfig.isTcpNoDelay()); sock.setKeepAlive(socketConfig.isSoKeepAlive()); @@ -134,7 +134,7 @@ public class DefaultHttpClientConnectionOperator implements HttpClientConnection sock.setSendBufferSize(socketConfig.getSndBufSize()); } - final int linger = socketConfig.getSoLinger().toMillisIntBound(); + final int linger = socketConfig.getSoLinger().toMillisecondsIntBound(); if (linger >= 0) { sock.setSoLinger(true, linger); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java index 1798dba86..5600f93b0 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java @@ -136,7 +136,7 @@ public class PoolingHttpClientConnectionManager public PoolingHttpClientConnectionManager( final Registry socketFactoryRegistry, final HttpConnectionFactory connFactory) { - this(socketFactoryRegistry, PoolConcurrencyPolicy.STRICT, TimeValue.NEG_ONE_MILLISECONDS, connFactory); + this(socketFactoryRegistry, PoolConcurrencyPolicy.STRICT, TimeValue.NEG_ONE_MILLISECOND, connFactory); } public PoolingHttpClientConnectionManager( @@ -290,7 +290,7 @@ public class PoolingHttpClientConnectionManager if (TimeValue.isNonNegative(validateAfterInactivity)) { final ManagedHttpClientConnection conn = poolEntry.getConnection(); if (conn != null - && poolEntry.getUpdated() + validateAfterInactivity.toMillis() <= System.currentTimeMillis()) { + && poolEntry.getUpdated() + validateAfterInactivity.toMilliseconds() <= System.currentTimeMillis()) { boolean stale; try { stale = conn.isStale(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManagerBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManagerBuilder.java index 98ea2eb13..955c3e746 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManagerBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManagerBuilder.java @@ -208,7 +208,7 @@ public class PoolingHttpClientConnectionManagerBuilder { .build(), poolConcurrencyPolicy, poolReusePolicy, - timeToLive != null ? timeToLive : TimeValue.NEG_ONE_MILLISECONDS, + timeToLive != null ? timeToLive : TimeValue.NEG_ONE_MILLISECOND, schemePortResolver, dnsResolver, connectionFactory); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java index 81fcfa9c1..9582afbc5 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java @@ -121,7 +121,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio } public PoolingAsyncClientConnectionManager(final Lookup tlsStrategyLookup) { - this(tlsStrategyLookup, PoolConcurrencyPolicy.STRICT, TimeValue.NEG_ONE_MILLISECONDS); + this(tlsStrategyLookup, PoolConcurrencyPolicy.STRICT, TimeValue.NEG_ONE_MILLISECOND); } public PoolingAsyncClientConnectionManager( @@ -246,7 +246,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio final ManagedAsyncClientConnection connection = poolEntry.getConnection(); final TimeValue timeValue = PoolingAsyncClientConnectionManager.this.validateAfterInactivity; if (TimeValue.isPositive(timeValue) && connection != null && - poolEntry.getUpdated() + timeValue.toMillis() <= System.currentTimeMillis()) { + poolEntry.getUpdated() + timeValue.toMilliseconds() <= System.currentTimeMillis()) { final ProtocolVersion protocolVersion = connection.getProtocolVersion(); if (HttpVersion.HTTP_2_0.greaterEquals(protocolVersion)) { connection.submitCommand(new PingCommand(new BasicPingHandler(new Callback() { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/socket/PlainConnectionSocketFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/socket/PlainConnectionSocketFactory.java index c82807269..1c66bd062 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/socket/PlainConnectionSocketFactory.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/socket/PlainConnectionSocketFactory.java @@ -84,7 +84,7 @@ public class PlainConnectionSocketFactory implements ConnectionSocketFactory { AccessController.doPrivileged(new PrivilegedExceptionAction() { @Override public Object run() throws IOException { - sock.connect(remoteAddress, TimeValue.isPositive(connectTimeout) ? connectTimeout.toMillisIntBound() : 0); + sock.connect(remoteAddress, TimeValue.isPositive(connectTimeout) ? connectTimeout.toMillisecondsIntBound() : 0); return null; } }); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategy.java index 72859c66d..ac36438da 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategy.java @@ -45,7 +45,7 @@ import org.apache.hc.core5.http.nio.ssl.TlsStrategy; import org.apache.hc.core5.http.ssl.TLS; import org.apache.hc.core5.http.ssl.TlsCiphers; import org.apache.hc.core5.http2.HttpVersionPolicy; -import org.apache.hc.core5.http2.ssl.ApplicationProtocols; +import org.apache.hc.core5.http2.ssl.ApplicationProtocol; import org.apache.hc.core5.http2.ssl.H2TlsSupport; import org.apache.hc.core5.net.NamedEndpoint; import org.apache.hc.core5.reactor.ssl.SSLBufferMode; @@ -134,7 +134,7 @@ abstract class AbstractClientTlsStrategy implements TlsStrategy { verifySession(host.getHostName(), sslEngine.getSession()); final TlsDetails tlsDetails = createTlsDetails(sslEngine); final String negotiatedCipherSuite = sslEngine.getSession().getCipherSuite(); - if (tlsDetails != null && ApplicationProtocols.HTTP_2.id.equals(tlsDetails.getApplicationProtocol())) { + if (tlsDetails != null && ApplicationProtocol.HTTP_2.id.equals(tlsDetails.getApplicationProtocol())) { if (TlsCiphers.isH2Blacklisted(negotiatedCipherSuite)) { throw new SSLHandshakeException("Cipher suite `" + negotiatedCipherSuite + "` does not provide adequate security for HTTP/2"); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/ClientTlsStrategyBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/ClientTlsStrategyBuilder.java index 8b4145e9d..475a69510 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/ClientTlsStrategyBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/ClientTlsStrategyBuilder.java @@ -102,7 +102,7 @@ public class ClientTlsStrategyBuilder { public final ClientTlsStrategyBuilder setTlsVersions(final TLS... tlslVersions) { this.tlsVersions = new String[tlslVersions.length]; for (int i = 0; i < tlslVersions.length; i++) { - this.tlsVersions[i] = tlslVersions[i].ident; + this.tlsVersions[i] = tlslVersions[i].id; } return this; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java index d3be93123..bc6d3b769 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactory.java @@ -208,7 +208,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor } try { if (TimeValue.isPositive(connectTimeout) && sock.getSoTimeout() == 0) { - sock.setSoTimeout(connectTimeout.toMillisIntBound()); + sock.setSoTimeout(connectTimeout.toMillisecondsIntBound()); } if (this.log.isDebugEnabled()) { this.log.debug("Connecting socket to " + remoteAddress + " with timeout " + connectTimeout); @@ -219,7 +219,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor AccessController.doPrivileged(new PrivilegedExceptionAction() { @Override public Object run() throws IOException { - sock.connect(remoteAddress, connectTimeout != null ? connectTimeout.toMillisIntBound() : 0); + sock.connect(remoteAddress, connectTimeout != null ? connectTimeout.toMillisecondsIntBound() : 0); return null; } }); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactoryBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactoryBuilder.java index f31d78d88..0926dce4c 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactoryBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactoryBuilder.java @@ -93,7 +93,7 @@ public class SSLConnectionSocketFactoryBuilder { public final SSLConnectionSocketFactoryBuilder setTlsVersions(final TLS... tlslVersions) { this.tlsVersions = new String[tlslVersions.length]; for (int i = 0; i < tlslVersions.length; i++) { - this.tlsVersions[i] = tlslVersions[i].ident; + this.tlsVersions[i] = tlslVersions[i].id; } return this; } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookieOrigin.java b/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookieOrigin.java index 3d528f0a3..ad32d1b5f 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookieOrigin.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookieOrigin.java @@ -45,7 +45,7 @@ public class TestCookieOrigin { } @SuppressWarnings("unused") - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testNullHost() { new CookieOrigin(null, 80, "/", false); } @@ -63,7 +63,7 @@ public class TestCookieOrigin { } @SuppressWarnings("unused") - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testNullPath() { new CookieOrigin("www.apache.org", 80, null, false); } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java index 4a16dbc66..144329e49 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java @@ -41,7 +41,7 @@ import org.apache.hc.core5.http.HttpException; 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.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.message.StatusLine; import org.apache.hc.core5.http.nio.AsyncPushConsumer; import org.apache.hc.core5.http.nio.support.BasicRequestProducer; @@ -118,7 +118,7 @@ public class AsyncClientH2ServerPush { final HttpHost target = new HttpHost("nghttp2.org"); final String requestURI = "/httpbin/"; final Future future = client.execute( - new BasicRequestProducer(Methods.GET, target, requestURI), + new BasicRequestProducer(Method.GET, target, requestURI), new AbstractCharResponseConsumer() { @Override diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java index dc3e87b8e..c543bf92a 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java @@ -37,7 +37,7 @@ import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpResponse; -import org.apache.hc.core5.http.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.message.StatusLine; import org.apache.hc.core5.http.nio.support.BasicRequestProducer; import org.apache.hc.core5.io.CloseMode; @@ -66,7 +66,7 @@ public class AsyncClientHttpExchangeStreaming { for (final String requestUri: requestUris) { final Future future = client.execute( - new BasicRequestProducer(Methods.GET, target, requestUri), + new BasicRequestProducer(Method.GET, target, requestUri), new AbstractCharResponseConsumer() { @Override diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java index 29f04a64e..93bbca7da 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java @@ -104,7 +104,7 @@ public class ClientExecuteSOCKS { if (localAddress != null) { sock.bind(localAddress); } - sock.connect(remoteAddress, connectTimeout != null ? connectTimeout.toMillisIntBound() : 0); + sock.connect(remoteAddress, connectTimeout != null ? connectTimeout.toMillisecondsIntBound() : 0); return sock; } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAuthenticationStrategy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAuthenticationStrategy.java index e4d612f95..8c5c45b1f 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAuthenticationStrategy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAuthenticationStrategy.java @@ -64,18 +64,18 @@ public class TestAuthenticationStrategy { final HttpClientContext context = HttpClientContext.create(); try { authStrategy.select(null, Collections.emptyMap(), context); - Assert.fail("IllegalArgumentException expected"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException expected"); + } catch (final NullPointerException ex) { } try { authStrategy.select(ChallengeType.TARGET, null, context); - Assert.fail("IllegalArgumentException expected"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException expected"); + } catch (final NullPointerException ex) { } try { authStrategy.select(ChallengeType.TARGET, Collections.emptyMap(), null); - Assert.fail("IllegalArgumentException expected"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException expected"); + } catch (final NullPointerException ex) { } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultConnKeepAliveStrategy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultConnKeepAliveStrategy.java index 460b1a3c7..7f637899d 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultConnKeepAliveStrategy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultConnKeepAliveStrategy.java @@ -41,7 +41,7 @@ import org.junit.Test; */ public class TestDefaultConnKeepAliveStrategy { - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testIllegalResponseArg() throws Exception { final HttpContext context = new BasicHttpContext(null); final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy(); @@ -54,7 +54,7 @@ public class TestDefaultConnKeepAliveStrategy { final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_OK); final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy(); final TimeValue d = keepAliveStrat.getKeepAliveDuration(response, context); - Assert.assertEquals(TimeValue.NEG_ONE_MILLISECONDS, d); + Assert.assertEquals(TimeValue.NEG_ONE_MILLISECOND, d); } @Test @@ -64,7 +64,7 @@ public class TestDefaultConnKeepAliveStrategy { response.addHeader("Keep-Alive", "timeout, max=20"); final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy(); final TimeValue d = keepAliveStrat.getKeepAliveDuration(response, context); - Assert.assertEquals(TimeValue.NEG_ONE_MILLISECONDS, d); + Assert.assertEquals(TimeValue.NEG_ONE_MILLISECOND, d); } @Test @@ -74,7 +74,7 @@ public class TestDefaultConnKeepAliveStrategy { response.addHeader("Keep-Alive", "timeout=whatever, max=20"); final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy(); final TimeValue d = keepAliveStrat.getKeepAliveDuration(response, context); - Assert.assertEquals(TimeValue.NEG_ONE_MILLISECONDS, d); + Assert.assertEquals(TimeValue.NEG_ONE_MILLISECOND, d); } @Test diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultRedirectStrategy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultRedirectStrategy.java index 6ca7e60b0..06a6a9447 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultRedirectStrategy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultRedirectStrategy.java @@ -114,13 +114,13 @@ public class TestDefaultRedirectStrategy { final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_SEE_OTHER, "Redirect"); try { redirectStrategy.isRedirected(null, response, context); - Assert.fail("IllegalArgumentException expected"); - } catch (final IllegalArgumentException expected) { + Assert.fail("NullPointerException expected"); + } catch (final NullPointerException expected) { } try { redirectStrategy.isRedirected(httpget, null, context); - Assert.fail("IllegalArgumentException expected"); - } catch (final IllegalArgumentException expected) { + Assert.fail("NullPointerException expected"); + } catch (final NullPointerException expected) { } } @@ -207,18 +207,18 @@ public class TestDefaultRedirectStrategy { response.addHeader("Location", "http://localhost/stuff"); try { redirectStrategy.getLocationURI(null, response, context); - Assert.fail("IllegalArgumentException expected"); - } catch (final IllegalArgumentException expected) { + Assert.fail("NullPointerException expected"); + } catch (final NullPointerException expected) { } try { redirectStrategy.getLocationURI(httpget, null, context); - Assert.fail("IllegalArgumentException expected"); - } catch (final IllegalArgumentException expected) { + Assert.fail("NullPointerException expected"); + } catch (final NullPointerException expected) { } try { redirectStrategy.getLocationURI(httpget, response, null); - Assert.fail("IllegalArgumentException expected"); - } catch (final IllegalArgumentException expected) { + Assert.fail("NullPointerException expected"); + } catch (final NullPointerException expected) { } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicAuthCache.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicAuthCache.java index 62798057a..d1ebfe703 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicAuthCache.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicAuthCache.java @@ -51,7 +51,7 @@ public class TestBasicAuthCache { Assert.assertNull(cache.get(new HttpHost("localhost", 80))); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = NullPointerException.class) public void testNullKey() throws Exception { final BasicAuthCache cache = new BasicAuthCache(); final AuthScheme authScheme = new BasicScheme(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java index 363f1bc8a..9fafcc235 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java @@ -157,18 +157,18 @@ public class TestDigestScheme { try { authscheme.isResponseReady(null, credentialsProvider, null); - Assert.fail("IllegalArgumentException should have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException should have been thrown"); + } catch (final NullPointerException ex) { } try { authscheme.isResponseReady(host, null, null); - Assert.fail("IllegalArgumentException should have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException should have been thrown"); + } catch (final NullPointerException ex) { } try { authscheme.generateAuthResponse(host, null, null); - Assert.fail("IllegalArgumentException should have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException should have been thrown"); + } catch (final NullPointerException ex) { } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestRequestAuthCache.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestRequestAuthCache.java index 29dbc37e1..29b784a59 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestRequestAuthCache.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestRequestAuthCache.java @@ -71,14 +71,14 @@ public class TestRequestAuthCache { this.credProvider.setCredentials(this.authscope2, this.creds2); } - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testRequestParameterCheck() throws Exception { final HttpClientContext context = HttpClientContext.create(); final HttpRequestInterceptor interceptor = new RequestAuthCache(); interceptor.process(null, null, context); } - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testContextParameterCheck() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpRequestInterceptor interceptor = new RequestAuthCache(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java index fa2ff2b71..ff045dada 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java @@ -39,7 +39,7 @@ import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.HttpEntity; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHost; -import org.apache.hc.core5.http.Methods; +import org.apache.hc.core5.http.Method; import org.apache.hc.core5.http.io.entity.StringEntity; import org.apache.hc.core5.http.message.BasicClassicHttpRequest; import org.apache.hc.core5.http.message.BasicClassicHttpResponse; @@ -77,7 +77,7 @@ public class TestContentCompressionExec { @Test public void testContentEncodingNoEntity() throws Exception { - final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); + final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); Mockito.when(execChain.proceed(request, scope)).thenReturn(response); @@ -90,7 +90,7 @@ public class TestContentCompressionExec { @Test public void testNoContentEncoding() throws Exception { - final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); + final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final StringEntity original = new StringEntity("plain stuff"); response.setEntity(original); @@ -106,7 +106,7 @@ public class TestContentCompressionExec { @Test public void testGzipContentEncoding() throws Exception { - final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); + final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("GZip").build(); response.setEntity(original); @@ -122,7 +122,7 @@ public class TestContentCompressionExec { @Test public void testGzipContentEncodingZeroLength() throws Exception { - final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); + final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("").setContentEncoding("GZip").build(); response.setEntity(original); @@ -138,7 +138,7 @@ public class TestContentCompressionExec { @Test public void testXGzipContentEncoding() throws Exception { - final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); + final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("x-gzip").build(); response.setEntity(original); @@ -154,7 +154,7 @@ public class TestContentCompressionExec { @Test public void testDeflateContentEncoding() throws Exception { - final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); + final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("deFlaTe").build(); response.setEntity(original); @@ -170,7 +170,7 @@ public class TestContentCompressionExec { @Test public void testIdentityContentEncoding() throws Exception { - final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); + final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("identity").build(); response.setEntity(original); @@ -186,7 +186,7 @@ public class TestContentCompressionExec { @Test(expected=HttpException.class) public void testUnknownContentEncoding() throws Exception { - final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); + final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("whatever").build(); response.setEntity(original); @@ -200,7 +200,7 @@ public class TestContentCompressionExec { @Test public void testContentEncodingRequestParameter() throws Exception { - final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); + final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("GZip").build(); response.setEntity(original); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicClientCookie.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicClientCookie.java index ed2c1e1ab..4ad3e9cf2 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicClientCookie.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicClientCookie.java @@ -48,8 +48,8 @@ public class TestBasicClientCookie { Assert.assertEquals("value", cookie.getValue()); try { new BasicClientCookie(null, null); - Assert.fail("IllegalArgumentException should have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException should have been thrown"); + } catch (final NullPointerException ex) { //expected } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieAttribHandlers.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieAttribHandlers.java index a3626251b..b10fbe9be 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieAttribHandlers.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieAttribHandlers.java @@ -193,32 +193,32 @@ public class TestBasicCookieAttribHandlers { final CookieAttributeHandler h = new BasicDomainHandler(); try { h.parse(null, null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } try { h.validate(null, null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } try { h.validate(new BasicClientCookie("name", "value"), null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } try { h.match(null, null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } try { h.match(new BasicClientCookie("name", "value"), null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } } @@ -302,20 +302,20 @@ public class TestBasicCookieAttribHandlers { final CookieAttributeHandler h = new BasicPathHandler(); try { h.parse(null, null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } try { h.match(null, null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } try { h.match(new BasicClientCookie("name", "value"), null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } } @@ -351,8 +351,8 @@ public class TestBasicCookieAttribHandlers { final CookieAttributeHandler h = new BasicMaxAgeHandler(); try { h.parse(null, null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } } @@ -390,20 +390,20 @@ public class TestBasicCookieAttribHandlers { final CookieAttributeHandler h = new BasicSecureHandler(); try { h.parse(null, null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } try { h.match(null, null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } try { h.match(new BasicClientCookie("name", "value"), null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } } @@ -445,15 +445,15 @@ public class TestBasicCookieAttribHandlers { public void testBasicExpiresInvalidInput() throws Exception { try { new BasicExpiresHandler(null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } final CookieAttributeHandler h = new BasicExpiresHandler(new String[] {DateUtils.PATTERN_RFC1123}); try { h.parse(null, null); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestLaxCookieAttribHandlers.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestLaxCookieAttribHandlers.java index 4a1a204a1..4a9dd2727 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestLaxCookieAttribHandlers.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestLaxCookieAttribHandlers.java @@ -82,8 +82,8 @@ public class TestLaxCookieAttribHandlers { final CookieAttributeHandler h = new LaxMaxAgeHandler(); try { h.parse(null, "stuff"); - Assert.fail("IllegalArgumentException must have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException must have been thrown"); + } catch (final NullPointerException ex) { // expected } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java index 3ccc65138..1e603e356 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java @@ -180,7 +180,7 @@ public class TestBasicHttpClientConnectionManager { Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE); - mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); + mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND); Assert.assertEquals(route1, mgr.getRoute()); Assert.assertEquals(null, mgr.getState()); @@ -227,15 +227,15 @@ public class TestBasicHttpClientConnectionManager { Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.any()); } - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testReleaseInvalidArg() throws Exception { - mgr.release(null, null, TimeValue.NEG_ONE_MILLISECONDS); + mgr.release(null, null, TimeValue.NEG_ONE_MILLISECOND); } @Test(expected=IllegalStateException.class) public void testReleaseAnotherConnection() throws Exception { final ConnectionEndpoint wrongCon = Mockito.mock(ConnectionEndpoint.class); - mgr.release(wrongCon, null, TimeValue.NEG_ONE_MILLISECONDS); + mgr.release(wrongCon, null, TimeValue.NEG_ONE_MILLISECOND); } @Test @@ -253,7 +253,7 @@ public class TestBasicHttpClientConnectionManager { Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE); - mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); + mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND); mgr.close(); @@ -316,7 +316,7 @@ public class TestBasicHttpClientConnectionManager { Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE); - mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); + mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND); Assert.assertEquals(route, mgr.getRoute()); Assert.assertEquals(null, mgr.getState()); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java index 94f2c8780..227fa0031 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java @@ -98,7 +98,7 @@ public class TestPoolingHttpClientConnectionManager { final HttpHost target = new HttpHost("localhost", 80); final HttpRoute route = new HttpRoute(target); - final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); + final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND); entry.assignConnection(conn); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE); @@ -121,7 +121,7 @@ public class TestPoolingHttpClientConnectionManager { Assert.assertNotNull(endpoint1); Assert.assertNotSame(conn, endpoint1); - mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); + mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND); Mockito.verify(pool).release(entry, true); } @@ -131,7 +131,7 @@ public class TestPoolingHttpClientConnectionManager { final HttpHost target = new HttpHost("localhost", 80); final HttpRoute route = new HttpRoute(target); - final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); + final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE); Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory); @@ -153,7 +153,7 @@ public class TestPoolingHttpClientConnectionManager { Assert.assertNotNull(endpoint1); Assert.assertNotSame(conn, endpoint1); - mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); + mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND); Mockito.verify(pool).release(entry, false); } @@ -163,7 +163,7 @@ public class TestPoolingHttpClientConnectionManager { final HttpHost target = new HttpHost("localhost", 80); final HttpRoute route = new HttpRoute(target); - final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); + final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND); entry.assignConnection(conn); Mockito.when(future.isCancelled()).thenReturn(Boolean.TRUE); @@ -202,7 +202,7 @@ public class TestPoolingHttpClientConnectionManager { final HttpHost target = new HttpHost("localhost", 80); final HttpRoute route = new HttpRoute(target); - final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); + final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND); entry.assignConnection(conn); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE); @@ -220,7 +220,7 @@ public class TestPoolingHttpClientConnectionManager { Assert.assertNotNull(endpoint1); Assert.assertTrue(endpoint1.isConnected()); - mgr.release(endpoint1, "some state", TimeValue.NEG_ONE_MILLISECONDS); + mgr.release(endpoint1, "some state", TimeValue.NEG_ONE_MILLISECOND); Mockito.verify(pool).release(entry, true); Assert.assertEquals("some state", entry.getState()); @@ -231,7 +231,7 @@ public class TestPoolingHttpClientConnectionManager { final HttpHost target = new HttpHost("localhost", 80); final HttpRoute route = new HttpRoute(target); - final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); + final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND); entry.assignConnection(conn); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE); @@ -249,7 +249,7 @@ public class TestPoolingHttpClientConnectionManager { Assert.assertNotNull(endpoint1); Assert.assertFalse(endpoint1.isConnected()); - mgr.release(endpoint1, "some state", TimeValue.NEG_ONE_MILLISECONDS); + mgr.release(endpoint1, "some state", TimeValue.NEG_ONE_MILLISECOND); Mockito.verify(pool).release(entry, false); Assert.assertEquals(null, entry.getState()); @@ -262,7 +262,7 @@ public class TestPoolingHttpClientConnectionManager { final InetAddress local = InetAddress.getByAddress(new byte[]{127, 0, 0, 1}); final HttpRoute route = new HttpRoute(target, local, true); - final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); + final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND); entry.assignConnection(conn); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE); @@ -315,7 +315,7 @@ public class TestPoolingHttpClientConnectionManager { final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 1}); final HttpRoute route = new HttpRoute(target, local, proxy, true); - final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); + final PoolEntry entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND); entry.assignConnection(conn); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteDirector.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteDirector.java index 53a7ef943..1630142bd 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteDirector.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteDirector.java @@ -81,7 +81,7 @@ public class TestRouteDirector { } } - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testIllegal() { final HttpRouteDirector rowdy = new BasicRouteDirector(); final HttpRoute route = new HttpRoute(TARGET1); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteTracker.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteTracker.java index 690745e95..8b876f645 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteTracker.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteTracker.java @@ -121,7 +121,7 @@ public class TestRouteTracker { try { new RouteTracker(null, LOCAL41); Assert.fail("null target not detected"); - } catch (final IllegalArgumentException iax) { + } catch (final NullPointerException iax) { // expected } } @@ -191,14 +191,14 @@ public class TestRouteTracker { try { rt.connectProxy(null, true); Assert.fail("missing proxy argument not detected (connect/false)"); - } catch (final IllegalArgumentException iax) { + } catch (final NullPointerException iax) { // expected } try { rt.connectProxy(null, false); Assert.fail("missing proxy argument not detected (connect/true)"); - } catch (final IllegalArgumentException iax) { + } catch (final NullPointerException iax) { // expected } @@ -207,14 +207,14 @@ public class TestRouteTracker { try { rt.tunnelProxy(null, false); Assert.fail("missing proxy argument not detected (tunnel/false)"); - } catch (final IllegalArgumentException iax) { + } catch (final NullPointerException iax) { // expected } try { rt.tunnelProxy(null, true); Assert.fail("missing proxy argument not detected (tunnel/true)"); - } catch (final IllegalArgumentException iax) { + } catch (final NullPointerException iax) { // expected } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java index 4c50d3fd8..eb1be9527 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java @@ -84,14 +84,14 @@ public class TestRequestAddCookies { .build(); } - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testRequestParameterCheck() throws Exception { final HttpClientContext context = HttpClientContext.create(); final HttpRequestInterceptor interceptor = new RequestAddCookies(); interceptor.process(null, null, context); } - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testContextParameterCheck() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpRequestInterceptor interceptor = new RequestAddCookies(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestClientConnControl.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestClientConnControl.java index 2c7f5df29..40086d9cf 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestClientConnControl.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestClientConnControl.java @@ -41,7 +41,7 @@ import org.junit.Test; public class TestRequestClientConnControl { - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testRequestParameterCheck() throws Exception { final HttpClientContext context = HttpClientContext.create(); final HttpRequestInterceptor interceptor = new RequestClientConnControl(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestDefaultHeaders.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestDefaultHeaders.java index 490453b45..b34a59f4b 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestDefaultHeaders.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestDefaultHeaders.java @@ -41,7 +41,7 @@ import org.junit.Test; public class TestRequestDefaultHeaders { - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testRequestParameterCheck() throws Exception { final HttpContext context = new BasicHttpContext(); final HttpRequestInterceptor interceptor = new RequestDefaultHeaders(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestExpectContinue.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestExpectContinue.java index deac305ed..500d1eeda 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestExpectContinue.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestExpectContinue.java @@ -111,8 +111,8 @@ public class TestRequestExpectContinue { final RequestExpectContinue interceptor = new RequestExpectContinue(); try { interceptor.process(null, null, null); - Assert.fail("IllegalArgumentException should have been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException should have been thrown"); + } catch (final NullPointerException ex) { // expected } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestResponseProcessCookies.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestResponseProcessCookies.java index ed4daa521..b34e3d7d7 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestResponseProcessCookies.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestResponseProcessCookies.java @@ -54,14 +54,14 @@ public class TestResponseProcessCookies { this.cookieStore = new BasicCookieStore(); } - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testResponseParameterCheck() throws Exception { final HttpClientContext context = HttpClientContext.create(); final HttpResponseInterceptor interceptor = new ResponseProcessCookies(); interceptor.process(null, null, context); } - @Test(expected=IllegalArgumentException.class) + @Test(expected=NullPointerException.class) public void testContextParameterCheck() throws Exception { final HttpResponse response = new BasicHttpResponse(200, "OK"); final HttpResponseInterceptor interceptor = new ResponseProcessCookies(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/routing/TestHttpRoute.java b/httpclient5/src/test/java/org/apache/hc/client5/http/routing/TestHttpRoute.java index 40893efa4..c5411244c 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/routing/TestHttpRoute.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/routing/TestHttpRoute.java @@ -239,7 +239,7 @@ public class TestHttpRoute { new HttpRoute(null, null, chain1, false, TunnelType.TUNNELLED, LayerType.PLAIN); Assert.fail("missing target not detected"); - } catch (final IllegalArgumentException iax) { + } catch (final NullPointerException iax) { // expected } @@ -532,7 +532,7 @@ public class TestHttpRoute { try { new HttpRoute(TARGET1, LOCAL61, null, false); Assert.fail("missing proxy not detected"); - } catch (final IllegalArgumentException iax) { + } catch (final NullPointerException iax) { // expected } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDateUtils.java b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDateUtils.java index 8f1da941e..4475fe06d 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDateUtils.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDateUtils.java @@ -80,20 +80,20 @@ public class TestDateUtils { public void testInvalidInput() throws Exception { try { DateUtils.parseDate(null, null, null); - Assert.fail("IllegalArgumentException should habe been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException should habe been thrown"); + } catch (final NullPointerException ex) { // expected } try { DateUtils.formatDate(null); - Assert.fail("IllegalArgumentException should habe been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException should habe been thrown"); + } catch (final NullPointerException ex) { // expected } try { DateUtils.formatDate(new Date(), null); - Assert.fail("IllegalArgumentException should habe been thrown"); - } catch (final IllegalArgumentException ex) { + Assert.fail("NullPointerException should habe been thrown"); + } catch (final NullPointerException ex) { // expected } } diff --git a/pom.xml b/pom.xml index cc3e1c038..d116a089f 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ 1.7 1.7 - 5.0-beta10 + 5.0-beta11 2.9.1 1.13 2.2.1