diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/CacheContextBuilder.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/CacheContextBuilder.java index 85f1ab952e..d0a368c17a 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/CacheContextBuilder.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/CacheContextBuilder.java @@ -109,7 +109,7 @@ protected HttpCacheContext createContext() { @Override public HttpCacheContext build() { - final HttpCacheContext context = super.build(); + final HttpCacheContext context = super.build(); context.setRequestCacheControl(cacheControl); return context; } diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HeaderConstants.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HeaderConstants.java index a04352e48e..3182645911 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HeaderConstants.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HeaderConstants.java @@ -165,7 +165,8 @@ public class HeaderConstants { public static final String CACHE_CONTROL_STALE_WHILE_REVALIDATE = "stale-while-revalidate"; public static final String CACHE_CONTROL_ONLY_IF_CACHED = "only-if-cached"; public static final String CACHE_CONTROL_MUST_UNDERSTAND = "must-understand"; - public static final String CACHE_CONTROL_IMMUTABLE= "immutable"; + public static final String CACHE_CONTROL_IMMUTABLE = "immutable"; + /** * @deprecated Use {@link #CACHE_CONTROL_STALE_IF_ERROR} */ diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java index 83941c17d1..a121bb446e 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java @@ -721,7 +721,7 @@ private void handleCacheHit( final AsyncExecChain.Scope scope, final AsyncExecChain chain, final AsyncExecCallback asyncExecCallback) { - final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); + final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); final String exchangeId = scope.exchangeId; if (LOG.isDebugEnabled()) { diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheConfig.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheConfig.java index 4db7fc1a92..8d31913e6a 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheConfig.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheConfig.java @@ -227,7 +227,7 @@ public int getMaxCacheEntries() { /** * Returns the number of times to retry a cache processChallenge on failure */ - public int getMaxUpdateRetries(){ + public int getMaxUpdateRetries() { return maxUpdateRetries; } diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedResponseSuitabilityChecker.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedResponseSuitabilityChecker.java index 6271564aee..069bf406bf 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedResponseSuitabilityChecker.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedResponseSuitabilityChecker.java @@ -198,7 +198,7 @@ public CacheSuitability assessSuitability(final RequestCacheControl requestCache boolean requestMethodMatch(final HttpRequest request, final HttpCacheEntry entry) { return request.getMethod().equalsIgnoreCase(entry.getRequestMethod()) || - (Method.HEAD.isSame(request.getMethod()) && Method.GET.isSame(entry.getRequestMethod())); + Method.HEAD.isSame(request.getMethod()) && Method.GET.isSame(entry.getRequestMethod()); } boolean requestUriMatch(final HttpRequest request, final HttpCacheEntry entry) { @@ -295,10 +295,10 @@ public boolean allConditionalsMatch(final HttpRequest request, final HttpCacheEn return true; } - final boolean etagValidatorMatches = (hasEtagValidator) && etagValidatorMatches(request, entry); - final boolean lastModifiedValidatorMatches = (hasLastModifiedValidator) && lastModifiedValidatorMatches(request, entry, now); + final boolean etagValidatorMatches = hasEtagValidator && etagValidatorMatches(request, entry); + final boolean lastModifiedValidatorMatches = hasLastModifiedValidator && lastModifiedValidatorMatches(request, entry, now); - if ((hasEtagValidator && hasLastModifiedValidator) + if (hasEtagValidator && hasLastModifiedValidator && !(etagValidatorMatches && lastModifiedValidatorMatches)) { return false; } else if (hasEtagValidator && !etagValidatorMatches) { @@ -309,9 +309,9 @@ public boolean allConditionalsMatch(final HttpRequest request, final HttpCacheEn } boolean hasUnsupportedConditionalHeaders(final HttpRequest request) { - return (request.containsHeader(HttpHeaders.IF_RANGE) + return request.containsHeader(HttpHeaders.IF_RANGE) || request.containsHeader(HttpHeaders.IF_MATCH) - || request.containsHeader(HttpHeaders.IF_UNMODIFIED_SINCE)); + || request.containsHeader(HttpHeaders.IF_UNMODIFIED_SINCE); } boolean hasSupportedEtagValidator(final HttpRequest request) { diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java index 6ab1194000..690bed08cb 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java @@ -218,7 +218,7 @@ ClassicHttpResponse callBackend( final HttpHost target, final ClassicHttpRequest request, final ExecChain.Scope scope, - final ExecChain chain) throws IOException, HttpException { + final ExecChain chain) throws IOException, HttpException { final String exchangeId = scope.exchangeId; final Instant requestDate = getCurrentDate(); @@ -244,7 +244,7 @@ private ClassicHttpResponse handleCacheHit( final ExecChain.Scope scope, final ExecChain chain) throws IOException, HttpException { final String exchangeId = scope.exchangeId; - final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); + final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); if (LOG.isDebugEnabled()) { LOG.debug("{} cache hit: {}", exchangeId, new RequestLine(request)); @@ -353,7 +353,7 @@ ClassicHttpResponse revalidateCacheEntry( final ClassicHttpRequest request, final ExecChain.Scope scope, final ExecChain chain) throws IOException, HttpException { - final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); + final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); Instant requestDate = getCurrentDate(); final ClassicHttpRequest conditionalRequest = conditionalRequestBuilder.buildConditionalRequest( responseCacheControl, request, hit.entry); @@ -397,7 +397,7 @@ ClassicHttpResponse revalidateCacheEntryWithoutFallback( final ExecChain.Scope scope, final ExecChain chain) throws HttpException { final String exchangeId = scope.exchangeId; - final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); + final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); try { return revalidateCacheEntry(responseCacheControl, hit, target, request, scope, chain); } catch (final IOException ex) { @@ -418,7 +418,7 @@ ClassicHttpResponse revalidateCacheEntryWithFallback( final ExecChain.Scope scope, final ExecChain chain) throws HttpException, IOException { final String exchangeId = scope.exchangeId; - final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); + final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); final ClassicHttpResponse response; try { response = revalidateCacheEntry(responseCacheControl, hit, target, request, scope, chain); @@ -490,7 +490,7 @@ ClassicHttpResponse cacheAndReturnResponse( final Instant requestSent, final Instant responseReceived) throws IOException { final String exchangeId = scope.exchangeId; - final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); + final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); final int statusCode = backendResponse.getCode(); // handle 304 Not Modified responses if (statusCode == HttpStatus.SC_NOT_MODIFIED) { @@ -573,7 +573,7 @@ private ClassicHttpResponse handleCacheMiss( } cacheMisses.getAndIncrement(); - final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); + final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); if (requestCacheControl.isOnlyIfCached()) { if (LOG.isDebugEnabled()) { LOG.debug("{} request marked only-if-cached", exchangeId); @@ -643,7 +643,7 @@ ClassicHttpResponse negotiateResponseFromVariants( return callBackend(target, unconditional, scope, chain); } - final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); + final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext); context.setCacheResponseStatus(CacheResponseStatus.VALIDATED); cacheUpdates.getAndIncrement(); diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ManagedHttpCacheStorage.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ManagedHttpCacheStorage.java index 4c2a1cd6bd..d6c1668a04 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ManagedHttpCacheStorage.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ManagedHttpCacheStorage.java @@ -240,7 +240,8 @@ public boolean isActive() { return active.get(); } - private boolean compareAndSet(){ + private boolean compareAndSet() { return this.active.compareAndSet(true, false); } + } diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java index e07879509e..e18aef36e8 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java @@ -235,7 +235,7 @@ protected boolean isExplicitlyNonCacheable(final ResponseCacheControl cacheContr // The response is considered explicitly non-cacheable if it contains // "no-store" or (if sharedCache is true) "private" directives. // Note that "no-cache" is considered cacheable but requires validation before use. - return cacheControl.isNoStore() || (sharedCache && cacheControl.isCachePrivate()); + return cacheControl.isNoStore() || sharedCache && cacheControl.isCachePrivate(); } protected boolean isExplicitlyCacheable(final ResponseCacheControl cacheControl, final HttpResponse response) { @@ -371,11 +371,11 @@ private Duration calculateFreshnessLifetime(final ResponseCacheControl cacheCont * @return true if the HTTP status code is understood, false otherwise. */ private boolean understoodStatusCode(final int status) { - return (status >= 200 && status <= 206) || - (status >= 300 && status <= 399) || - (status >= 400 && status <= 417) || - (status == 421) || - (status >= 500 && status <= 505); + return status >= 200 && status <= 206 || + status >= 300 && status <= 399 || + status >= 400 && status <= 417 || + status == 421 || + status >= 500 && status <= 505; } /** 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 b5d9f559ce..2f35a79702 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 @@ -176,7 +176,7 @@ void canGetOriginalHeaders() { entry = makeEntry(Instant.now(), Instant.now(), HttpStatus.SC_OK, headers, mockResource, null); final Header[] result = entry.getHeaders(); assertEquals(headers.length, result.length); - for(int i=0; i httpCacheEntrySerializer.deserialize(bytes1)); Assertions.assertEquals("Unexpected content at the end of cache content", exception1.getMessage()); - final String content2 =HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" + + final String content2 = HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" + "HC-Key: unique-cache-key\n" + - "HC-Request-Instant: 1686210849596\n" + - "HC-Response-Instant: 1686210849596\n" + - "\n" + - "GET /stuff HTTP/1.1\n" + - "\n" + - "HTTP/1.1 200 \n" + - "Content-Type: text/plain; charset=UTF-8\n" + - "Cache-control: public, max-age=31536000\n" + - "\n" + - "Rubbish"; + "HC-Request-Instant: 1686210849596\n" + + "HC-Response-Instant: 1686210849596\n" + + "\n" + + "GET /stuff HTTP/1.1\n" + + "\n" + + "HTTP/1.1 200 \n" + + "Content-Type: text/plain; charset=UTF-8\n" + + "Cache-control: public, max-age=31536000\n" + + "\n" + + "Rubbish"; final byte[] bytes2 = content2.getBytes(StandardCharsets.UTF_8); final ResourceIOException exception2 = Assertions.assertThrows(ResourceIOException.class, () -> httpCacheEntrySerializer.deserialize(bytes2)); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java index 3bdcce7221..3355aa469a 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java @@ -268,7 +268,7 @@ private void testDoesNotReturnStaleResponseOnError(final ClassicHttpRequest req2 ClassicHttpResponse result = null; try { result = execute(req2); - } catch (final IOException acceptable) { + } catch (final IOException expected) { } if (result != null) { @@ -745,8 +745,8 @@ void testSendsAllVariantEtagsInConditionalRequest() throws Exception { final ClassicHttpRequest captured = reqCapture.getValue(); boolean foundEtag1 = false; boolean foundEtag2 = false; - for(final Header h : captured.getHeaders("If-None-Match")) { - for(final String etag : h.getValue().split(",")) { + for (final Header h : captured.getHeaders("If-None-Match")) { + for (final String etag : h.getValue().split(",")) { if ("\"etag1\"".equals(etag.trim())) { foundEtag1 = true; } diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java index 08fb1e2c76..3b1659f033 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java @@ -1212,7 +1212,7 @@ void testCachedEntityBodyIsUsedForResponseAfter304Validation() throws Exception try (final InputStream i1 = resp1.getEntity().getContent(); final InputStream i2 = result.getEntity().getContent()) { int b1, b2; - while((b1 = i1.read()) != -1) { + while ((b1 = i1.read()) != -1) { b2 = i2.read(); Assertions.assertEquals(b1, b2); } @@ -1262,7 +1262,7 @@ void testResponseIncludesCacheEntryEndToEndHeadersForResponseAfter304Validation( "Content-MD5", "Content-Type", "Expires", "Last-Modified", "Location", "Retry-After" }; - for(final String h : endToEndHeaders) { + for (final String h : endToEndHeaders) { Assertions.assertEquals(HttpTestUtils.getCanonicalHeaderValue(resp1, h), HttpTestUtils.getCanonicalHeaderValue(result, h)); } @@ -1306,7 +1306,7 @@ void testUpdatedEndToEndHeadersFrom304ArePassedOnResponseAndUpdatedInCacheEntry( "Content-Location", "Content-Type", "Expires", "Location", "Retry-After" }; - for(final String h : endToEndHeaders) { + for (final String h : endToEndHeaders) { Assertions.assertEquals(HttpTestUtils.getCanonicalHeaderValue(resp2, h), HttpTestUtils.getCanonicalHeaderValue(result1, h)); Assertions.assertEquals(HttpTestUtils.getCanonicalHeaderValue(resp2, h), @@ -2093,7 +2093,7 @@ void testOrderOfMultipleContentEncodingHeaderValuesIsPreserved() throws Exceptio final Iterator it = MessageSupport.iterate(result, HttpHeaders.CONTENT_ENCODING); while (it.hasNext()) { final HeaderElement elt = it.next(); - switch(total_encodings) { + switch (total_encodings) { case 0: Assertions.assertEquals("gzip", elt.getName()); break; @@ -2118,7 +2118,7 @@ void testOrderOfMultipleParametersInContentEncodingHeaderIsPreserved() throws Ex final Iterator it = MessageSupport.iterate(result, HttpHeaders.CONTENT_ENCODING); while (it.hasNext()) { final HeaderElement elt = it.next(); - switch(total_encodings) { + switch (total_encodings) { case 0: Assertions.assertEquals("gzip", elt.getName()); break; diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java index fa77d74876..1e2bca433d 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java @@ -126,8 +126,7 @@ public ClassicHttpResponse execute(final ClassicHttpRequest request) throws IOEx } @Test - void testConsumesErrorResponseWhenServingStale() - throws Exception{ + void testConsumesErrorResponseWhenServingStale() throws Exception { final Instant tenSecondsAgo = Instant.now().minusSeconds(10); final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo, @@ -152,8 +151,7 @@ void testConsumesErrorResponseWhenServingStale() } @Test - void testStaleIfErrorInResponseYieldsToMustRevalidate() - throws Exception{ + void testStaleIfErrorInResponseYieldsToMustRevalidate() throws Exception { final Instant tenSecondsAgo = Instant.now().minusSeconds(10); final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo, @@ -174,8 +172,7 @@ void testStaleIfErrorInResponseYieldsToMustRevalidate() } @Test - void testStaleIfErrorInResponseYieldsToProxyRevalidateForSharedCache() - throws Exception{ + void testStaleIfErrorInResponseYieldsToProxyRevalidateForSharedCache() throws Exception { assertTrue(config.isSharedCache()); final Instant tenSecondsAgo = Instant.now().minusSeconds(10); final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); @@ -197,8 +194,7 @@ void testStaleIfErrorInResponseYieldsToProxyRevalidateForSharedCache() } @Test - void testStaleIfErrorInResponseYieldsToExplicitFreshnessRequest() - throws Exception{ + void testStaleIfErrorInResponseYieldsToExplicitFreshnessRequest() throws Exception { final Instant tenSecondsAgo = Instant.now().minusSeconds(10); final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo, @@ -220,8 +216,7 @@ void testStaleIfErrorInResponseYieldsToExplicitFreshnessRequest() } @Test - void testStaleIfErrorInResponseIsFalseReturnsError() - throws Exception{ + void testStaleIfErrorInResponseIsFalseReturnsError() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); @@ -244,8 +239,7 @@ void testStaleIfErrorInResponseIsFalseReturnsError() } @Test - void testStaleIfErrorInRequestIsFalseReturnsError() - throws Exception{ + void testStaleIfErrorInRequestIsFalseReturnsError() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); 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 6fc653e009..13172fc50c 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 @@ -364,7 +364,7 @@ public Request body(final HttpEntity entity) { return this; } - public Request bodyForm(final Iterable formParams, final Charset charset) { + public Request bodyForm(final Iterable formParams, final Charset charset) { final List paramList = new ArrayList<>(); for (final NameValuePair param : formParams) { paramList.add(param); @@ -375,7 +375,7 @@ public Request bodyForm(final Iterable formParams, fin return bodyString(s, contentType); } - public Request bodyForm(final Iterable formParams) { + public Request bodyForm(final Iterable formParams) { return bodyForm(formParams, StandardCharsets.ISO_8859_1); } diff --git a/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentAsync.java b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentAsync.java index e73fa9abd2..f86f5a6e2b 100644 --- a/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentAsync.java +++ b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentAsync.java @@ -80,11 +80,11 @@ public void cancelled() { queue.add(future); } - while(!queue.isEmpty()) { + while (!queue.isEmpty()) { final Future future = queue.remove(); try { future.get(); - } catch (final ExecutionException ex) { + } catch (final ExecutionException ignore) { } } System.out.println("Done"); diff --git a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AsyncRandomHandler.java b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AsyncRandomHandler.java index 4a3220c227..de144e3ad1 100644 --- a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AsyncRandomHandler.java +++ b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/async/AsyncRandomHandler.java @@ -209,7 +209,7 @@ protected void produceData(final StreamChannel channel) throws IOExc } @Override - public void failed(final Exception cause) { + public void failed(final Exception cause) { } } diff --git a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/classic/RandomHandler.java b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/classic/RandomHandler.java index b68048f53c..5c157dd6b7 100644 --- a/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/classic/RandomHandler.java +++ b/httpclient5-testing/src/main/java/org/apache/hc/client5/testing/classic/RandomHandler.java @@ -48,7 +48,7 @@ /** * A handler that generates random data. */ -public class RandomHandler implements HttpRequestHandler { +public class RandomHandler implements HttpRequestHandler { /** * Handles a request by generating random data. @@ -186,8 +186,8 @@ public InputStream getContent() { public void writeTo(final OutputStream out) throws IOException { final int blocksize = 2048; - int remaining = (int) length; // range checked in constructor - final byte[] data = new byte[Math.min(remaining, blocksize)]; + int remaining = (int) length; // range checked in constructor + final byte[] data = new byte[Math.min(remaining, blocksize)]; while (remaining > 0) { final int end = Math.min(remaining, data.length); @@ -195,7 +195,7 @@ public void writeTo(final OutputStream out) throws IOException { double value = 0.0; for (int i = 0; i < end; i++) { // we get 5 random characters out of one random value - if (i%5 == 0) { + if (i % 5 == 0) { value = Math.random(); } value = value * RANGE.length; diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/BasicTestAuthenticator.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/BasicTestAuthenticator.java index a02a5ce9e8..f4a3132d11 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/BasicTestAuthenticator.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/BasicTestAuthenticator.java @@ -61,7 +61,7 @@ public AuthResult perform(final URIAuthority authority, if (TextUtils.isBlank(credentials)) { return new AuthResult(false); } - final String error = credentials.endsWith("-expired") ? "token expired" : "invalid token"; + final String error = credentials.endsWith("-expired") ? "token expired" : "invalid token"; return new AuthResult(false, new BasicNameValuePair("error", error)); } diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthenticationTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthenticationTest.java index 543ef5a1f0..2bcb6709e8 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthenticationTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthenticationTest.java @@ -76,7 +76,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -abstract class AbstractHttpAsyncClientAuthenticationTest extends AbstractIntegrationTestBase { +abstract class AbstractHttpAsyncClientAuthenticationTest extends AbstractIntegrationTestBase { public AbstractHttpAsyncClientAuthenticationTest(final URIScheme scheme, final ClientProtocolLevel clientProtocolLevel, final ServerProtocolLevel serverProtocolLevel) { super(scheme, clientProtocolLevel, serverProtocolLevel); @@ -240,7 +240,7 @@ void testBasicAuthenticationCredentialsCaching() throws Exception { configureServer(bootstrap -> bootstrap.register("*", AsyncEchoHandler::new)); final DefaultAuthenticationStrategy authStrategy = Mockito.spy(new DefaultAuthenticationStrategy()); - configureClient(builder -> builder.setTargetAuthenticationStrategy(authStrategy)); + configureClient(builder -> builder.setTargetAuthenticationStrategy(authStrategy)); final TestAsyncClient client = startClient(); final HttpClientContext context = HttpClientContext.create(); 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 1f38c166c5..aa18ed4162 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 @@ -58,7 +58,7 @@ import org.hamcrest.CoreMatchers; import org.junit.jupiter.api.Test; -abstract class AbstractHttpAsyncFundamentalsTest extends AbstractIntegrationTestBase { +abstract class AbstractHttpAsyncFundamentalsTest extends AbstractIntegrationTestBase { protected AbstractHttpAsyncFundamentalsTest(final URIScheme scheme, final ClientProtocolLevel clientProtocolLevel, final ServerProtocolLevel serverProtocolLevel) { super(scheme, clientProtocolLevel, serverProtocolLevel); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java index 77e42504a2..9071ea5230 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java @@ -66,7 +66,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -abstract class AbstractHttpAsyncRedirectsTest extends AbstractIntegrationTestBase { +abstract class AbstractHttpAsyncRedirectsTest extends AbstractIntegrationTestBase { public AbstractHttpAsyncRedirectsTest(final URIScheme scheme, final ClientProtocolLevel clientProtocolLevel, final ServerProtocolLevel serverProtocolLevel) { super(scheme, clientProtocolLevel, serverProtocolLevel); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpReactiveFundamentalsTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpReactiveFundamentalsTest.java index 1ff6f97cc1..ad8e93d9ba 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpReactiveFundamentalsTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpReactiveFundamentalsTest.java @@ -77,7 +77,7 @@ import org.junit.jupiter.api.Timeout; import org.reactivestreams.Publisher; -abstract class AbstractHttpReactiveFundamentalsTest extends AbstractIntegrationTestBase { +abstract class AbstractHttpReactiveFundamentalsTest extends AbstractIntegrationTestBase { public AbstractHttpReactiveFundamentalsTest(final URIScheme scheme, final ClientProtocolLevel clientProtocolLevel, final ServerProtocolLevel serverProtocolLevel) { super(scheme, clientProtocolLevel, serverProtocolLevel); @@ -85,7 +85,7 @@ public AbstractHttpReactiveFundamentalsTest(final URIScheme scheme, final Client @Test @Timeout(value = 60_000, unit = MILLISECONDS) - public void testSequentialGetRequests() throws Exception { + void testSequentialGetRequests() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", () -> new ReactiveServerExchangeHandler(new ReactiveRandomProcessor()))); final HttpHost target = startServer(); @@ -108,7 +108,7 @@ public void testSequentialGetRequests() throws Exception { @Test @Timeout(value = 2000, unit = MILLISECONDS) - public void testSequentialHeadRequests() throws Exception { + void testSequentialHeadRequests() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", () -> new ReactiveServerExchangeHandler(new ReactiveRandomProcessor()))); final HttpHost target = startServer(); @@ -130,7 +130,7 @@ public void testSequentialHeadRequests() throws Exception { @Test @Timeout(value = 60_000, unit = MILLISECONDS) - public void testSequentialPostRequests() throws Exception { + void testSequentialPostRequests() throws Exception { configureServer(bootstrap -> bootstrap.register("/echo/*", () -> new ReactiveServerExchangeHandler(new ReactiveEchoProcessor()))); final HttpHost target = startServer(); @@ -160,7 +160,7 @@ public void testSequentialPostRequests() throws Exception { @Test @Timeout(value = 60_000, unit = MILLISECONDS) - public void testConcurrentPostRequests() throws Exception { + void testConcurrentPostRequests() throws Exception { configureServer(bootstrap -> bootstrap.register("/echo/*", () -> new ReactiveServerExchangeHandler(new ReactiveEchoProcessor()))); final HttpHost target = startServer(); @@ -209,7 +209,7 @@ public void cancelled() { } @Test @Timeout(value = 60_000, unit = MILLISECONDS) - public void testRequestExecutionFromCallback() throws Exception { + void testRequestExecutionFromCallback() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", () -> new ReactiveServerExchangeHandler(new ReactiveRandomProcessor()))); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractIntegrationTestBase.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractIntegrationTestBase.java index 8df05f1112..afafb21594 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractIntegrationTestBase.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractIntegrationTestBase.java @@ -42,7 +42,7 @@ import org.apache.hc.core5.util.Timeout; import org.junit.jupiter.api.extension.RegisterExtension; -abstract class AbstractIntegrationTestBase { +abstract class AbstractIntegrationTestBase { public static final Timeout TIMEOUT = Timeout.ofMinutes(1); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Async.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Async.java index e661e060cc..ea188e7d69 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Async.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Async.java @@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ServerProtocolLevel; import org.apache.hc.core5.http.URIScheme; -abstract class TestH2Async extends AbstractHttpAsyncFundamentalsTest { +abstract class TestH2Async extends AbstractHttpAsyncFundamentalsTest { public TestH2Async(final URIScheme scheme) { super(scheme, ClientProtocolLevel.H2_ONLY, ServerProtocolLevel.H2_ONLY); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncMinimal.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncMinimal.java index bb6e204c5b..f3c1f1d098 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncMinimal.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncMinimal.java @@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ServerProtocolLevel; import org.apache.hc.core5.http.URIScheme; -abstract class TestH2AsyncMinimal extends AbstractHttpAsyncFundamentalsTest { +abstract class TestH2AsyncMinimal extends AbstractHttpAsyncFundamentalsTest { public TestH2AsyncMinimal(final URIScheme scheme) { super(scheme, ClientProtocolLevel.MINIMAL_H2_ONLY, ServerProtocolLevel.H2_ONLY); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncRedirect.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncRedirect.java index 0eede8e152..36085dde15 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncRedirect.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncRedirect.java @@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ServerProtocolLevel; import org.apache.hc.core5.http.URIScheme; -abstract class TestH2AsyncRedirect extends AbstractHttpAsyncRedirectsTest { +abstract class TestH2AsyncRedirect extends AbstractHttpAsyncRedirectsTest { public TestH2AsyncRedirect(final URIScheme scheme) { super(scheme, ClientProtocolLevel.H2_ONLY, ServerProtocolLevel.H2_ONLY); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ClientAuthentication.java index 7f929e6917..0c4c9c06b8 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ClientAuthentication.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ClientAuthentication.java @@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ServerProtocolLevel; import org.apache.hc.core5.http.URIScheme; -abstract class TestH2ClientAuthentication extends AbstractHttpAsyncClientAuthenticationTest { +abstract class TestH2ClientAuthentication extends AbstractHttpAsyncClientAuthenticationTest { public TestH2ClientAuthentication(final URIScheme scheme) { super(scheme, ClientProtocolLevel.H2_ONLY, ServerProtocolLevel.H2_ONLY); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Reactive.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Reactive.java index 24152bada3..73aa6e2bb9 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Reactive.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Reactive.java @@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ServerProtocolLevel; import org.apache.hc.core5.http.URIScheme; -abstract class TestH2Reactive extends AbstractHttpReactiveFundamentalsTest { +abstract class TestH2Reactive extends AbstractHttpReactiveFundamentalsTest { public TestH2Reactive(final URIScheme scheme) { super(scheme, ClientProtocolLevel.H2_ONLY, ServerProtocolLevel.H2_ONLY); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ReactiveMinimal.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ReactiveMinimal.java index 310cf4c1f2..127313c611 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ReactiveMinimal.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ReactiveMinimal.java @@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ServerProtocolLevel; import org.apache.hc.core5.http.URIScheme; -abstract class TestH2ReactiveMinimal extends AbstractHttpReactiveFundamentalsTest { +abstract class TestH2ReactiveMinimal extends AbstractHttpReactiveFundamentalsTest { public TestH2ReactiveMinimal(final URIScheme scheme) { super(scheme, ClientProtocolLevel.MINIMAL_H2_ONLY, ServerProtocolLevel.H2_ONLY); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Async.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Async.java index ac914deb84..2318f5de6d 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Async.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Async.java @@ -52,7 +52,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -abstract class TestHttp1Async extends AbstractHttpAsyncFundamentalsTest { +abstract class TestHttp1Async extends AbstractHttpAsyncFundamentalsTest { public TestHttp1Async(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD, ServerProtocolLevel.STANDARD); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncMinimal.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncMinimal.java index e4a08c0ccb..ba90657c3d 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncMinimal.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncMinimal.java @@ -52,7 +52,7 @@ import org.hamcrest.CoreMatchers; import org.junit.jupiter.api.Test; -abstract class TestHttp1AsyncMinimal extends AbstractHttpAsyncFundamentalsTest { +abstract class TestHttp1AsyncMinimal extends AbstractHttpAsyncFundamentalsTest { public TestHttp1AsyncMinimal(final URIScheme scheme) { super(scheme, ClientProtocolLevel.MINIMAL, ServerProtocolLevel.STANDARD); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java index 9dc9c59a58..1e3c564c8a 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java @@ -52,7 +52,7 @@ /** * Redirection test cases. */ -abstract class TestHttp1AsyncRedirects extends AbstractHttpAsyncRedirectsTest { +abstract class TestHttp1AsyncRedirects extends AbstractHttpAsyncRedirectsTest { public TestHttp1AsyncRedirects(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD, ServerProtocolLevel.STANDARD); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ClientAuthentication.java index 11a4e9fe72..9baa619e7f 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ClientAuthentication.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ClientAuthentication.java @@ -49,7 +49,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -abstract class TestHttp1ClientAuthentication extends AbstractHttpAsyncClientAuthenticationTest { +abstract class TestHttp1ClientAuthentication extends AbstractHttpAsyncClientAuthenticationTest { public TestHttp1ClientAuthentication(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD, ServerProtocolLevel.STANDARD); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Reactive.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Reactive.java index 9de0a34565..66d1e6c37f 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Reactive.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Reactive.java @@ -57,7 +57,7 @@ import org.junit.jupiter.params.provider.ValueSource; import org.reactivestreams.Publisher; -abstract class TestHttp1Reactive extends AbstractHttpReactiveFundamentalsTest { +abstract class TestHttp1Reactive extends AbstractHttpReactiveFundamentalsTest { public TestHttp1Reactive(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD, ServerProtocolLevel.STANDARD); @@ -99,7 +99,7 @@ public void testSequentialGetRequestsCloseConnection(final int concurrentConns) @Test @Timeout(value = 60_000, unit = MILLISECONDS) - public void testSharedPool() throws Exception { + void testSharedPool() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", () -> new ReactiveServerExchangeHandler(new ReactiveRandomProcessor()))); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ReactiveMinimal.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ReactiveMinimal.java index 6d0c1cdbfd..113b51188f 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ReactiveMinimal.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ReactiveMinimal.java @@ -54,7 +54,7 @@ import org.hamcrest.CoreMatchers; import org.junit.jupiter.api.Test; -abstract class TestHttp1ReactiveMinimal extends AbstractHttpReactiveFundamentalsTest { +abstract class TestHttp1ReactiveMinimal extends AbstractHttpReactiveFundamentalsTest { public TestHttp1ReactiveMinimal(final URIScheme scheme) { super(scheme, ClientProtocolLevel.MINIMAL, ServerProtocolLevel.STANDARD); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1RequestReExecution.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1RequestReExecution.java index f743871da2..7524a23418 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1RequestReExecution.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1RequestReExecution.java @@ -47,7 +47,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -abstract class TestHttp1RequestReExecution extends AbstractIntegrationTestBase { +abstract class TestHttp1RequestReExecution extends AbstractIntegrationTestBase { public TestHttp1RequestReExecution(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD, ServerProtocolLevel.STANDARD); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncProtocolPolicy.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncProtocolPolicy.java index cfefde58e3..4c0613c08a 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncProtocolPolicy.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncProtocolPolicy.java @@ -45,7 +45,7 @@ import org.hamcrest.CoreMatchers; import org.junit.jupiter.api.Test; -abstract class TestHttpAsyncProtocolPolicy extends AbstractIntegrationTestBase { +abstract class TestHttpAsyncProtocolPolicy extends AbstractIntegrationTestBase { private final HttpVersion version; diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/sync/TestClientBuilder.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/sync/TestClientBuilder.java index 4489b265fc..1c13339978 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/sync/TestClientBuilder.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/sync/TestClientBuilder.java @@ -94,7 +94,7 @@ default TestClientBuilder addExecInterceptorFirst(String name, ExecChainHandler throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel()); } - default TestClientBuilder addExecInterceptorLast(String name, ExecChainHandler interceptor) { + default TestClientBuilder addExecInterceptorLast(String name, ExecChainHandler interceptor) { throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel()); } 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 68e0d151c8..683286dfd6 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 @@ -107,7 +107,7 @@ void shutdown() throws Exception { client.close(); } - enum TestResult {OK, NOK} + enum TestResult { OK, NOK } private void logResult(final TestResult result, final HttpRequest request, @@ -186,7 +186,7 @@ void execute() throws InterruptedException { final Throwable cause = ex.getCause(); logResult(TestResult.NOK, httpGet1, null, "(" + cause.getMessage() + ")"); } catch (final TimeoutException ex) { - logResult(TestResult.NOK, httpGet1, null,"(time out)"); + logResult(TestResult.NOK, httpGet1, null, "(time out)"); } final SimpleHttpRequest httpGet2 = SimpleRequestBuilder.get() @@ -207,7 +207,7 @@ void execute() throws InterruptedException { final Throwable cause = ex.getCause(); logResult(TestResult.NOK, httpGet2, null, "(" + cause.getMessage() + ")"); } catch (final TimeoutException ex) { - logResult(TestResult.NOK, httpGet2, null,"(time out)"); + logResult(TestResult.NOK, httpGet2, null, "(time out)"); } Thread.sleep(2000); @@ -231,7 +231,7 @@ void execute() throws InterruptedException { final Throwable cause = ex.getCause(); logResult(TestResult.NOK, httpGet3, null, "(" + cause.getMessage() + ")"); } catch (final TimeoutException ex) { - logResult(TestResult.NOK, httpGet3, null,"(time out)"); + logResult(TestResult.NOK, httpGet3, null, "(time out)"); } } } 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 59a7e8af81..c24a4c1fc5 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 @@ -92,7 +92,7 @@ void shutdown() throws Exception { client.close(); } - enum TestResult {OK, NOK} + enum TestResult { OK, NOK } private void logResult(final TestResult result, final HttpRequest request, final String message) { final StringBuilder buf = new StringBuilder(); 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 ee3317be0d..acc3d7fc5b 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 @@ -155,7 +155,7 @@ void shutdown() throws Exception { client.close(); } - enum TestResult {OK, NOK} + enum TestResult { OK, NOK } private void logResult(final TestResult result, final HttpRequest request, 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 bd8c7f4a66..0b73e9997c 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 @@ -115,7 +115,7 @@ void shutdown() throws Exception { client.close(); } - enum TestResult {OK, NOK} + enum TestResult { OK, NOK } private void logResult(final TestResult result, final HttpRequest request, final String message) { final StringBuilder buf = new StringBuilder(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/AbstractIntegrationTestBase.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/AbstractIntegrationTestBase.java index daa5836ffe..eb83f3dcdd 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/AbstractIntegrationTestBase.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/AbstractIntegrationTestBase.java @@ -41,7 +41,7 @@ import org.apache.hc.core5.util.Timeout; import org.junit.jupiter.api.extension.RegisterExtension; -abstract class AbstractIntegrationTestBase { +abstract class AbstractIntegrationTestBase { public static final Timeout TIMEOUT = Timeout.ofMinutes(1); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java index c3b0987b5a..84eabde95e 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java @@ -92,7 +92,7 @@ /** * Unit tests for automatic client authentication. */ -abstract class TestClientAuthentication extends AbstractIntegrationTestBase { +abstract class TestClientAuthentication extends AbstractIntegrationTestBase { protected TestClientAuthentication(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java index fc850e92e5..8e88fd79b5 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java @@ -71,7 +71,7 @@ /** * Client protocol handling tests. */ -abstract class TestClientRequestExecution extends AbstractIntegrationTestBase { +abstract class TestClientRequestExecution extends AbstractIntegrationTestBase { public TestClientRequestExecution(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD); @@ -313,7 +313,7 @@ void testAbsoluteRequestURIWithFragment() throws Exception { } @Test @Disabled("Fails intermittently with GitHub Actions") - public void testRequestCancellation() throws Exception { + void testRequestCancellation() throws Exception { startServer(); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java index 74f8a06946..7e47520563 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java @@ -350,8 +350,8 @@ public void process( final EntityDetails entityDetails, final HttpContext context) { final Header connection = response.getFirstHeader(HttpHeaders.CONNECTION); - if(connection != null) { - if(!connection.getValue().equalsIgnoreCase("Close")) { + if (connection != null) { + if (!connection.getValue().equalsIgnoreCase("Close")) { response.addHeader(HeaderElements.KEEP_ALIVE, "timeout=1"); } } diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java index 0ec2f70c83..44f46d10b0 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java @@ -63,7 +63,7 @@ * require no intervention from the user of HttpClient, but we still want to let clients do their * own thing if they so wish. */ -abstract class TestContentCodings extends AbstractIntegrationTestBase { +abstract class TestContentCodings extends AbstractIntegrationTestBase { protected TestContentCodings(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestFutureRequestExecutionService.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestFutureRequestExecutionService.java index 089c31f6f4..da24362367 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestFutureRequestExecutionService.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestFutureRequestExecutionService.java @@ -74,7 +74,7 @@ void before() throws Exception { .setCanonicalHostName("localhost") .register("/wait", (request, response, context) -> { try { - while(blocked.get()) { + while (blocked.get()) { Thread.sleep(10); } } catch (final InterruptedException e) { @@ -133,7 +133,7 @@ void shouldTimeout() { void shouldExecuteMultipleCalls() throws Exception { final int reqNo = 100; final Queue> tasks = new LinkedList<>(); - for(int i = 0; i < reqNo; i++) { + for (int i = 0; i < reqNo; i++) { final Future task = httpAsyncClientWithFuture.execute( new HttpGet(uri), HttpClientContext.create(), new OkidokiHandler()); tasks.add(task); @@ -150,7 +150,7 @@ void shouldExecuteMultipleCallsAndCallback() throws Exception { final int reqNo = 100; final Queue> tasks = new LinkedList<>(); final CountDownLatch latch = new CountDownLatch(reqNo); - for(int i = 0; i < reqNo; i++) { + for (int i = 0; i < reqNo; i++) { final Future task = httpAsyncClientWithFuture.execute( new HttpGet(uri), HttpClientContext.create(), new OkidokiHandler(), new CountingCallback(latch)); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java index b15669a57d..53fad418af 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java @@ -51,7 +51,7 @@ /** * Client protocol handling tests. */ -abstract class TestMinimalClientRequestExecution extends AbstractIntegrationTestBase { +abstract class TestMinimalClientRequestExecution extends AbstractIntegrationTestBase { protected TestMinimalClientRequestExecution(final URIScheme scheme) { super(scheme, ClientProtocolLevel.MINIMAL); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java index 7d27efb00c..2ba0926bb6 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java @@ -84,7 +84,7 @@ /** * Redirection test cases. */ -abstract class TestRedirects extends AbstractIntegrationTestBase { +abstract class TestRedirects extends AbstractIntegrationTestBase { protected TestRedirects(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java b/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java index 6def13992b..2edca7820f 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java @@ -94,9 +94,9 @@ public final class HttpRoute implements RouteInfo, Cloneable { if (tunnelled == TunnelType.TUNNELLED) { Args.check(this.proxyChain != null, "Proxy required if tunnelled"); } - this.secure = secure; - this.tunnelled = tunnelled != null ? tunnelled : TunnelType.PLAIN; - this.layered = layered != null ? layered : LayerType.PLAIN; + this.secure = secure; + this.tunnelled = tunnelled != null ? tunnelled : TunnelType.PLAIN; + this.layered = layered != null ? layered : LayerType.PLAIN; } /** @@ -221,8 +221,8 @@ public HttpRoute(final HttpHost target) { public HttpRoute(final HttpHost target, final NamedEndpoint targetName, final InetAddress local, final HttpHost proxy, final boolean secure) { this(target, targetName, local, Collections.singletonList(Args.notNull(proxy, "Proxy host")), secure, - secure ? TunnelType.TUNNELLED : TunnelType.PLAIN, - secure ? LayerType.LAYERED : LayerType.PLAIN); + secure ? TunnelType.TUNNELLED : TunnelType.PLAIN, + secure ? LayerType.LAYERED : LayerType.PLAIN); } /** @@ -242,7 +242,7 @@ public HttpRoute(final HttpHost target, final InetAddress local, final HttpHost final boolean secure) { this(target, null, local, Collections.singletonList(Args.notNull(proxy, "Proxy host")), secure, secure ? TunnelType.TUNNELLED : TunnelType.PLAIN, - secure ? LayerType.LAYERED : LayerType.PLAIN); + secure ? LayerType.LAYERED : LayerType.PLAIN); } /** @@ -307,7 +307,7 @@ public TunnelType getTunnelType() { @Override public boolean isTunnelled() { - return (this.tunnelled == TunnelType.TUNNELLED); + return this.tunnelled == TunnelType.TUNNELLED; } @Override @@ -317,7 +317,7 @@ public LayerType getLayerType() { @Override public boolean isLayered() { - return (this.layered == LayerType.LAYERED); + return this.layered == LayerType.LAYERED; } @Override @@ -341,14 +341,14 @@ public boolean equals(final Object obj) { if (obj instanceof HttpRoute) { final HttpRoute that = (HttpRoute) obj; return - // Do the cheapest tests first - (this.secure == that.secure) && - (this.tunnelled == that.tunnelled) && - (this.layered == that.layered) && - Objects.equals(this.targetHost, that.targetHost) && - Objects.equals(this.targetName, that.targetName) && - Objects.equals(this.localAddress, that.localAddress) && - Objects.equals(this.proxyChain, that.proxyChain); + // Do the cheapest tests first + this.secure == that.secure && + this.tunnelled == that.tunnelled && + this.layered == that.layered && + Objects.equals(this.targetHost, that.targetHost) && + Objects.equals(this.targetName, that.targetName) && + Objects.equals(this.localAddress, that.localAddress) && + Objects.equals(this.proxyChain, that.proxyChain); } return false; } @@ -383,7 +383,7 @@ public int hashCode() { */ @Override public String toString() { - final StringBuilder cab = new StringBuilder(50 + getHopCount()*30); + final StringBuilder cab = new StringBuilder(50 + getHopCount() * 30); if (this.localAddress != null) { cab.append(this.localAddress); cab.append("->"); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/RouteInfo.java b/httpclient5/src/main/java/org/apache/hc/client5/http/RouteInfo.java index e44499cd7c..4d3ba116a5 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/RouteInfo.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/RouteInfo.java @@ -63,7 +63,7 @@ enum TunnelType { PLAIN, TUNNELLED } * But we don't want to exclude that use case. *

*/ - enum LayerType { PLAIN, LAYERED } + enum LayerType { PLAIN, LAYERED } /** * Obtains the target host. diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/RouteTracker.java b/httpclient5/src/main/java/org/apache/hc/client5/http/RouteTracker.java index 0ebfb1dbc8..4857bb465c 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/RouteTracker.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/RouteTracker.java @@ -79,10 +79,10 @@ public final class RouteTracker implements RouteInfo, Cloneable { */ public RouteTracker(final HttpHost target, final InetAddress local) { Args.notNull(target, "Target host"); - this.targetHost = target; + this.targetHost = target; this.localAddress = local; - this.tunnelled = TunnelType.PLAIN; - this.layered = LayerType.PLAIN; + this.tunnelled = TunnelType.PLAIN; + this.layered = LayerType.PLAIN; } /** @@ -129,9 +129,9 @@ public void connectTarget(final boolean secure) { public void connectProxy(final HttpHost proxy, final boolean secure) { Args.notNull(proxy, "Proxy host"); Asserts.check(!this.connected, "Already connected"); - this.connected = true; - this.proxyChain = new HttpHost[]{ proxy }; - this.secure = secure; + this.connected = true; + this.proxyChain = new HttpHost[]{proxy}; + this.secure = secure; } /** @@ -144,7 +144,7 @@ public void tunnelTarget(final boolean secure) { Asserts.check(this.connected, "No tunnel unless connected"); Asserts.notNull(this.proxyChain, "No tunnel without proxy"); this.tunnelled = TunnelType.TUNNELLED; - this.secure = secure; + this.secure = secure; } /** @@ -161,13 +161,13 @@ public void tunnelProxy(final HttpHost proxy, final boolean secure) { Asserts.check(this.connected, "No tunnel unless connected"); Asserts.notNull(this.proxyChain, "No tunnel without proxy"); // prepare an extended proxy chain - final HttpHost[] proxies = new HttpHost[this.proxyChain.length+1]; + final HttpHost[] proxies = new HttpHost[this.proxyChain.length + 1]; System.arraycopy(this.proxyChain, 0, - proxies, 0, this.proxyChain.length); - proxies[proxies.length-1] = proxy; + proxies, 0, this.proxyChain.length); + proxies[proxies.length - 1] = proxy; this.proxyChain = proxies; - this.secure = secure; + this.secure = secure; } /** @@ -181,7 +181,7 @@ public void layerProtocol(final boolean secure) { // although this case is probably not considered elsewhere Asserts.check(this.connected, "No layered protocol unless connected"); this.layered = LayerType.LAYERED; - this.secure = secure; + this.secure = secure; } @Override @@ -213,7 +213,7 @@ public HttpHost getHopTarget(final int hop) { final int hopcount = getHopCount(); Args.check(hop < hopcount, "Hop index exceeds tracked route length"); HttpHost result = null; - if (hop < hopcount-1) { + if (hop < hopcount - 1) { result = this.proxyChain[hop]; } else { result = this.targetHost; @@ -224,7 +224,7 @@ public HttpHost getHopTarget(final int hop) { @Override public HttpHost getProxyHost() { - return (this.proxyChain == null) ? null : this.proxyChain[0]; + return this.proxyChain == null ? null : this.proxyChain[0]; } public boolean isConnected() { @@ -238,7 +238,7 @@ public TunnelType getTunnelType() { @Override public boolean isTunnelled() { - return (this.tunnelled == TunnelType.TUNNELLED); + return this.tunnelled == TunnelType.TUNNELLED; } @Override @@ -248,7 +248,7 @@ public LayerType getLayerType() { @Override public boolean isLayered() { - return (this.layered == LayerType.LAYERED); + return this.layered == LayerType.LAYERED; } @Override @@ -290,14 +290,14 @@ public boolean equals(final Object o) { final RouteTracker that = (RouteTracker) o; return - // Do the cheapest checks first - (this.connected == that.connected) && - (this.secure == that.secure) && - (this.tunnelled == that.tunnelled) && - (this.layered == that.layered) && - Objects.equals(this.targetHost, that.targetHost) && - Objects.equals(this.localAddress, that.localAddress) && - Objects.equals(this.proxyChain, that.proxyChain); + // Do the cheapest checks first + this.connected == that.connected && + this.secure == that.secure && + this.tunnelled == that.tunnelled && + this.layered == that.layered && + Objects.equals(this.targetHost, that.targetHost) && + Objects.equals(this.localAddress, that.localAddress) && + Objects.equals(this.proxyChain, that.proxyChain); } /** @@ -332,7 +332,7 @@ public int hashCode() { */ @Override public String toString() { - final StringBuilder cab = new StringBuilder(50 + getHopCount()*30); + final StringBuilder cab = new StringBuilder(50 + getHopCount() * 30); cab.append("RouteTracker["); if (this.localAddress != null) { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleResponseBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleResponseBuilder.java index 0a2f941c08..a536c5aa4d 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleResponseBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleResponseBuilder.java @@ -96,7 +96,7 @@ public SimpleResponseBuilder addHeader(final Header header) { } @Override - public SimpleResponseBuilder addHeader(final String name, final String value) { + public SimpleResponseBuilder addHeader(final String name, final String value) { super.addHeader(name, value); return this; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java index 35c309b3cd..cd4593f297 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java @@ -74,7 +74,7 @@ public AuthScope( final String schemeName) { this.protocol = protocol != null ? protocol.toLowerCase(Locale.ROOT) : null; this.host = host != null ? host.toLowerCase(Locale.ROOT) : null; - this.port = port >= 0 ? port: -1; + this.port = port >= 0 ? port : -1; this.realm = realm; this.schemeName = schemeName != null ? schemeName.toUpperCase(Locale.ROOT) : null; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java index b9a965ac91..c877155673 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java @@ -101,7 +101,7 @@ public NTCredentials( final String workstation, final String domain, final String netbiosDomain) { - this(password, userName, domain, netbiosDomain); + this(password, userName, domain, netbiosDomain); } /** diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/Cookie.java b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/Cookie.java index 2eae943643..3782a51131 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/Cookie.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/Cookie.java @@ -40,12 +40,12 @@ */ public interface Cookie { - String PATH_ATTR = "path"; - String DOMAIN_ATTR = "domain"; - String MAX_AGE_ATTR = "max-age"; - String SECURE_ATTR = "secure"; - String EXPIRES_ATTR = "expires"; - String HTTP_ONLY_ATTR = "httpOnly"; + String PATH_ATTR = "path"; + String DOMAIN_ATTR = "domain"; + String MAX_AGE_ATTR = "max-age"; + String SECURE_ATTR = "secure"; + String EXPIRES_ATTR = "expires"; + String HTTP_ONLY_ATTR = "httpOnly"; /** * @since 5.0 @@ -164,7 +164,9 @@ default boolean isExpired(final Instant date) { /** * Returns creation time of the cookie. */ - default Instant getCreationInstant() { return null; } + default Instant getCreationInstant() { + return null; + } /** * Checks whether this Cookie has been marked as {@code httpOnly}. @@ -175,7 +177,7 @@ default boolean isExpired(final Instant date) { * * @since 5.2 */ - default boolean isHttpOnly(){ + default boolean isHttpOnly() { return false; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/SetCookie.java b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/SetCookie.java index 39ccefe097..1edfc66e66 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/SetCookie.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/SetCookie.java @@ -112,7 +112,7 @@ default void setExpiryDate(Instant expiryDate) { * * @since 5.2 */ - default void setHttpOnly (final boolean httpOnly){ + default void setHttpOnly(final boolean httpOnly) { } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/UrlEncodedFormEntity.java b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/UrlEncodedFormEntity.java index 156663aded..31fa7a976b 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/UrlEncodedFormEntity.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/UrlEncodedFormEntity.java @@ -66,7 +66,7 @@ public UrlEncodedFormEntity( * * @param parameters list of name/value pairs */ - public UrlEncodedFormEntity (final List parameters){ + public UrlEncodedFormEntity(final List parameters) { this(parameters, null); } @@ -78,8 +78,8 @@ public UrlEncodedFormEntity (final List parameters){ * * @since 4.2 */ - public UrlEncodedFormEntity ( - final Iterable parameters) { + public UrlEncodedFormEntity( + final Iterable parameters) { this(parameters, null); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/MimeConsts.java b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/MimeConsts.java index d2b00965ff..aa4dd0bde1 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/MimeConsts.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/MimeConsts.java @@ -29,11 +29,11 @@ final class MimeConsts { - public static final String CONTENT_TYPE = "Content-Type"; - public static final String CONTENT_DISPOSITION = "Content-Disposition"; + public static final String CONTENT_TYPE = "Content-Type"; + public static final String CONTENT_DISPOSITION = "Content-Disposition"; - public static final String FIELD_PARAM_NAME = "name"; - public static final String FIELD_PARAM_FILENAME = "filename"; - public static final String FIELD_PARAM_FILENAME_START = "filename*"; + public static final String FIELD_PARAM_NAME = "name"; + public static final String FIELD_PARAM_FILENAME = "filename"; + public static final String FIELD_PARAM_FILENAME_START = "filename*"; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/CookieSpecSupport.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/CookieSpecSupport.java index bd233f240e..4af87f968a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/CookieSpecSupport.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/CookieSpecSupport.java @@ -27,8 +27,8 @@ package org.apache.hc.client5.http.impl; -import org.apache.hc.client5.http.cookie.StandardCookieSpec; import org.apache.hc.client5.http.cookie.CookieSpecFactory; +import org.apache.hc.client5.http.cookie.StandardCookieSpec; import org.apache.hc.client5.http.impl.cookie.IgnoreCookieSpecFactory; import org.apache.hc.client5.http.impl.cookie.RFC6265CookieSpecFactory; import org.apache.hc.client5.http.psl.PublicSuffixMatcher; @@ -78,6 +78,7 @@ public static Lookup createDefault(final PublicSuffixMatcher return createDefaultBuilder(publicSuffixMatcher).build(); } - private CookieSpecSupport() {} + private CookieSpecSupport() { + } } 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 657fd20c26..d43b781ae4 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 @@ -70,7 +70,7 @@ public TimeValue getKeepAliveDuration(final HttpResponse response, final HttpCon if (value != null && param.equalsIgnoreCase("timeout")) { try { return TimeValue.ofSeconds(Long.parseLong(value)); - } catch(final NumberFormatException ignore) { + } catch (final NumberFormatException ignore) { } } } 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 eeddc9a5b2..18ad48759c 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 @@ -65,7 +65,7 @@ public IdleConnectionEvictor(final ConnPoolControl connectionManager, final T } } catch (final InterruptedException ex) { Thread.currentThread().interrupt(); - } catch (final Exception ex) { + } catch (final Exception ignore) { } }); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/InMemoryDnsResolver.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/InMemoryDnsResolver.java index 040f9ca4ec..4ecc2be00d 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/InMemoryDnsResolver.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/InMemoryDnsResolver.java @@ -89,7 +89,7 @@ public InetAddress[] resolve(final String host) throws UnknownHostException { if (LOG.isInfoEnabled()) { LOG.info("Resolving {} to {}", host, Arrays.deepToString(resolvedAddresses)); } - if(resolvedAddresses == null){ + if (resolvedAddresses == null) { throw new UnknownHostException(host); } return resolvedAddresses; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ProtocolSwitchStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ProtocolSwitchStrategy.java index eed4bcc579..6e5133fe74 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ProtocolSwitchStrategy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ProtocolSwitchStrategy.java @@ -47,7 +47,7 @@ public final class ProtocolSwitchStrategy { enum ProtocolSwitch { FAILURE, TLS } - public ProtocolVersion switchProtocol(final HttpMessage response) throws ProtocolException { + public ProtocolVersion switchProtocol(final HttpMessage response) throws ProtocolException { final Iterator it = MessageSupport.iterateTokens(response, HttpHeaders.UPGRADE); ProtocolVersion tlsUpgrade = null; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Wire.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Wire.java index db3b36cc9c..343f212156 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Wire.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Wire.java @@ -91,7 +91,7 @@ private void wire(final String header, final byte[] b, final int pos, final int buffer.insert(0, header); log.debug("{} {}", this.id, buffer); buffer.setLength(0); - } else if ((ch < 32) || (ch >= 127)) { + } else if (ch < 32 || ch >= 127) { buffer.append("[0x"); buffer.append(Integer.toHexString(ch)); buffer.append("]"); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java index c78a7db29a..16afc6518a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java @@ -105,7 +105,7 @@ public AsyncConnectExec( Args.notNull(proxyHttpProcessor, "Proxy HTTP processor"); Args.notNull(proxyAuthStrategy, "Proxy authentication strategy"); this.proxyHttpProcessor = proxyHttpProcessor; - this.proxyAuthStrategy = proxyAuthStrategy; + this.proxyAuthStrategy = proxyAuthStrategy; this.authenticator = new HttpAuthenticator(); this.authCacheKeeper = authCachingDisabled ? null : new AuthCacheKeeper(schemePortResolver); this.routeDirector = BasicRouteDirector.INSTANCE; @@ -232,7 +232,7 @@ public void cancelled() { @Override public void completed(final AsyncExecRuntime execRuntime) { - final HttpHost proxy = route.getProxyHost(); + final HttpHost proxy = route.getProxyHost(); tracker.connectProxy(proxy, route.isSecure() && !route.isTunnelled()); if (LOG.isDebugEnabled()) { LOG.debug("{} connected to proxy", exchangeId); @@ -356,7 +356,7 @@ public void cancelled() { break; default: - throw new IllegalStateException("Unknown step indicator " + step + " from RouteDirector."); + throw new IllegalStateException("Unknown step indicator " + step + " from RouteDirector."); } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/H2AsyncClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/H2AsyncClientBuilder.java index 15d5b395e0..d7dc5cccb5 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/H2AsyncClientBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/H2AsyncClientBuilder.java @@ -975,7 +975,7 @@ public IdleConnectionEvictor(final InternalH2ConnPool connPool, final TimeValue } } catch (final InterruptedException ex) { Thread.currentThread().interrupt(); - } catch (final Exception ex) { + } catch (final Exception ignore) { } }); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java index ebd3418726..5a8b3e81fe 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java @@ -1038,7 +1038,7 @@ public CloseableHttpAsyncClient build() { if (evictExpiredConnections || evictIdleConnections) { if (connManagerCopy instanceof ConnPoolControl) { final IdleConnectionEvictor connectionEvictor = new IdleConnectionEvictor((ConnPoolControl) connManagerCopy, - maxIdleTime, maxIdleTime); + maxIdleTime, maxIdleTime); closeablesCopy.add(connectionEvictor::shutdown); connectionEvictor.start(); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/AuthChallengeParser.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/AuthChallengeParser.java index ae191bd775..aafb34de32 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/AuthChallengeParser.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/AuthChallengeParser.java @@ -53,9 +53,9 @@ public class AuthChallengeParser { private final Tokenizer tokenParser = Tokenizer.INSTANCE; - private final static char BLANK = ' '; - private final static char COMMA_CHAR = ','; - private final static char EQUAL_CHAR = '='; + private final static char BLANK = ' '; + private final static char COMMA_CHAR = ','; + private final static char EQUAL_CHAR = '='; private static final Tokenizer.Delimiter TERMINATORS = Tokenizer.delimiters(BLANK, EQUAL_CHAR, COMMA_CHAR); private static final Tokenizer.Delimiter DELIMITER = Tokenizer.delimiters(COMMA_CHAR); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/CredentialsMatcher.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/CredentialsMatcher.java index ea334f3554..d84356225a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/CredentialsMatcher.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/CredentialsMatcher.java @@ -47,8 +47,8 @@ static Credentials matchCredentials(final Map map, final if (creds == null) { // Nope. // Do a full scan - int bestMatchFactor = -1; - AuthScope bestMatch = null; + int bestMatchFactor = -1; + AuthScope bestMatch = null; for (final AuthScope current: map.keySet()) { final int factor = authScope.match(current); if (factor > bestMatchFactor) { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/DigestScheme.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/DigestScheme.java index 84ae79585f..a12ad272a4 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/DigestScheme.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/DigestScheme.java @@ -141,7 +141,7 @@ private enum QualityOfProtection { private UsernamePasswordCredentials credentials; public DigestScheme() { - this.defaultCharset = StandardCharsets.UTF_8; + this.defaultCharset = StandardCharsets.UTF_8; this.paramMap = new HashMap<>(); this.complete = false; } @@ -474,8 +474,8 @@ private String createDigestResponse(final HttpRequest request) throws Authentica buffer.append(", "); } final String name = param.getName(); - final boolean noQuotes = ("nc".equals(name) || "qop".equals(name) - || "algorithm".equals(name)); + final boolean noQuotes = "nc".equals(name) || "qop".equals(name) + || "algorithm".equals(name); BasicHeaderValueFormatter.INSTANCE.formatNameValuePair(buffer, param, !noQuotes); } return buffer.toString(); @@ -514,8 +514,8 @@ static String formatHex(final byte[] binaryData) { final int n = binaryData.length; final char[] buffer = new char[n * 2]; for (int i = 0; i < n; i++) { - final int low = (binaryData[i] & 0x0f); - final int high = ((binaryData[i] & 0xf0) >> 4); + final int low = binaryData[i] & 0x0f; + final int high = (binaryData[i] & 0xf0) >> 4; buffer[i * 2] = HEXADECIMAL[high]; buffer[(i * 2) + 1] = HEXADECIMAL[low]; } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/GGSSchemeBase.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/GGSSchemeBase.java index aa3bb94114..773746b612 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/GGSSchemeBase.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/GGSSchemeBase.java @@ -211,10 +211,10 @@ public String generateAuthResponse( try { final String authServer; String hostname = host.getHostName(); - if (config.getUseCanonicalHostname() != org.apache.hc.client5.http.auth.KerberosConfig.Option.DISABLE){ + if (config.getUseCanonicalHostname() != org.apache.hc.client5.http.auth.KerberosConfig.Option.DISABLE) { try { - hostname = dnsResolver.resolveCanonicalHostname(host.getHostName()); - } catch (final UnknownHostException ignore){ + hostname = dnsResolver.resolveCanonicalHostname(host.getHostName()); + } catch (final UnknownHostException ignore) { } } if (config.getStripPort() != org.apache.hc.client5.http.auth.KerberosConfig.Option.DISABLE) { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMEngineImpl.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMEngineImpl.java index d057efb646..6c962cd252 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMEngineImpl.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMEngineImpl.java @@ -1224,7 +1224,7 @@ byte[] getBytes() { } void buildMessage() { - throw new RuntimeException("Message builder not implemented for "+getClass().getName()); + throw new RuntimeException("Message builder not implemented for " + getClass().getName()); } } @@ -1241,7 +1241,7 @@ static class Type1Message extends NTLMMessage { Type1Message(final String domain, final String host, final Integer flags) { super(); - this.flags = ((flags == null)?getDefaultFlags(): flags.intValue()); + this.flags = flags == null ? getDefaultFlags() : flags.intValue(); // See HTTPCLIENT-1662 final String unqualifiedHost = host; @@ -1541,7 +1541,7 @@ static class Type3Message extends NTLMMessage { try { // This conditional may not work on Windows Server 2008 R2 and above, where it has not yet // been tested - if (((type2Flags & FLAG_TARGETINFO_PRESENT) != 0) && + if ((type2Flags & FLAG_TARGETINFO_PRESENT) != 0 && targetInformation != null && target != null) { // NTLMv2 ntResp = gen.getNTLMv2Response(); @@ -1621,7 +1621,7 @@ void buildMessage() { final int lmRespLen = lmResp.length; final int domainLen = domainBytes != null ? domainBytes.length : 0; - final int hostLen = hostBytes != null ? hostBytes.length: 0; + final int hostLen = hostBytes != null ? hostBytes.length : 0; final int userLen = userBytes.length; final int sessionKeyLen; if (sessionKey != null) { @@ -1808,26 +1808,26 @@ static void writeULong(final byte[] buffer, final int value, final int offset) { } static int F(final int x, final int y, final int z) { - return ((x & y) | (~x & z)); + return (x & y) | (~x & z); } static int G(final int x, final int y, final int z) { - return ((x & y) | (x & z) | (y & z)); + return (x & y) | (x & z) | (y & z); } static int H(final int x, final int y, final int z) { - return (x ^ y ^ z); + return x ^ y ^ z; } static int rotintlft(final int val, final int numbits) { - return ((val << numbits) | (val >>> (32 - numbits))); + return (val << numbits) | (val >>> (32 - numbits)); } static MessageDigest getMD5() { try { return MessageDigest.getInstance("MD5"); } catch (final NoSuchAlgorithmException ex) { - throw new RuntimeException("MD5 message digest doesn't seem to exist - fatal error: "+ex.getMessage(), ex); + throw new RuntimeException("MD5 message digest doesn't seem to exist - fatal error: " + ex.getMessage(), ex); } } @@ -1929,70 +1929,70 @@ void processBuffer() { } void round1(final int[] d) { - A = rotintlft((A + F(B, C, D) + d[0]), 3); - D = rotintlft((D + F(A, B, C) + d[1]), 7); - C = rotintlft((C + F(D, A, B) + d[2]), 11); - B = rotintlft((B + F(C, D, A) + d[3]), 19); + A = rotintlft(A + F(B, C, D) + d[0], 3); + D = rotintlft(D + F(A, B, C) + d[1], 7); + C = rotintlft(C + F(D, A, B) + d[2], 11); + B = rotintlft(B + F(C, D, A) + d[3], 19); - A = rotintlft((A + F(B, C, D) + d[4]), 3); - D = rotintlft((D + F(A, B, C) + d[5]), 7); - C = rotintlft((C + F(D, A, B) + d[6]), 11); - B = rotintlft((B + F(C, D, A) + d[7]), 19); + A = rotintlft(A + F(B, C, D) + d[4], 3); + D = rotintlft(D + F(A, B, C) + d[5], 7); + C = rotintlft(C + F(D, A, B) + d[6], 11); + B = rotintlft(B + F(C, D, A) + d[7], 19); - A = rotintlft((A + F(B, C, D) + d[8]), 3); - D = rotintlft((D + F(A, B, C) + d[9]), 7); - C = rotintlft((C + F(D, A, B) + d[10]), 11); - B = rotintlft((B + F(C, D, A) + d[11]), 19); + A = rotintlft(A + F(B, C, D) + d[8], 3); + D = rotintlft(D + F(A, B, C) + d[9], 7); + C = rotintlft(C + F(D, A, B) + d[10], 11); + B = rotintlft(B + F(C, D, A) + d[11], 19); - A = rotintlft((A + F(B, C, D) + d[12]), 3); - D = rotintlft((D + F(A, B, C) + d[13]), 7); - C = rotintlft((C + F(D, A, B) + d[14]), 11); - B = rotintlft((B + F(C, D, A) + d[15]), 19); + A = rotintlft(A + F(B, C, D) + d[12], 3); + D = rotintlft(D + F(A, B, C) + d[13], 7); + C = rotintlft(C + F(D, A, B) + d[14], 11); + B = rotintlft(B + F(C, D, A) + d[15], 19); } void round2(final int[] d) { - A = rotintlft((A + G(B, C, D) + d[0] + 0x5a827999), 3); - D = rotintlft((D + G(A, B, C) + d[4] + 0x5a827999), 5); - C = rotintlft((C + G(D, A, B) + d[8] + 0x5a827999), 9); - B = rotintlft((B + G(C, D, A) + d[12] + 0x5a827999), 13); + A = rotintlft(A + G(B, C, D) + d[0] + 0x5a827999, 3); + D = rotintlft(D + G(A, B, C) + d[4] + 0x5a827999, 5); + C = rotintlft(C + G(D, A, B) + d[8] + 0x5a827999, 9); + B = rotintlft(B + G(C, D, A) + d[12] + 0x5a827999, 13); - A = rotintlft((A + G(B, C, D) + d[1] + 0x5a827999), 3); - D = rotintlft((D + G(A, B, C) + d[5] + 0x5a827999), 5); - C = rotintlft((C + G(D, A, B) + d[9] + 0x5a827999), 9); - B = rotintlft((B + G(C, D, A) + d[13] + 0x5a827999), 13); + A = rotintlft(A + G(B, C, D) + d[1] + 0x5a827999, 3); + D = rotintlft(D + G(A, B, C) + d[5] + 0x5a827999, 5); + C = rotintlft(C + G(D, A, B) + d[9] + 0x5a827999, 9); + B = rotintlft(B + G(C, D, A) + d[13] + 0x5a827999, 13); - A = rotintlft((A + G(B, C, D) + d[2] + 0x5a827999), 3); - D = rotintlft((D + G(A, B, C) + d[6] + 0x5a827999), 5); - C = rotintlft((C + G(D, A, B) + d[10] + 0x5a827999), 9); - B = rotintlft((B + G(C, D, A) + d[14] + 0x5a827999), 13); + A = rotintlft(A + G(B, C, D) + d[2] + 0x5a827999, 3); + D = rotintlft(D + G(A, B, C) + d[6] + 0x5a827999, 5); + C = rotintlft(C + G(D, A, B) + d[10] + 0x5a827999, 9); + B = rotintlft(B + G(C, D, A) + d[14] + 0x5a827999, 13); - A = rotintlft((A + G(B, C, D) + d[3] + 0x5a827999), 3); - D = rotintlft((D + G(A, B, C) + d[7] + 0x5a827999), 5); - C = rotintlft((C + G(D, A, B) + d[11] + 0x5a827999), 9); - B = rotintlft((B + G(C, D, A) + d[15] + 0x5a827999), 13); + A = rotintlft(A + G(B, C, D) + d[3] + 0x5a827999, 3); + D = rotintlft(D + G(A, B, C) + d[7] + 0x5a827999, 5); + C = rotintlft(C + G(D, A, B) + d[11] + 0x5a827999, 9); + B = rotintlft(B + G(C, D, A) + d[15] + 0x5a827999, 13); } void round3(final int[] d) { - A = rotintlft((A + H(B, C, D) + d[0] + 0x6ed9eba1), 3); - D = rotintlft((D + H(A, B, C) + d[8] + 0x6ed9eba1), 9); - C = rotintlft((C + H(D, A, B) + d[4] + 0x6ed9eba1), 11); - B = rotintlft((B + H(C, D, A) + d[12] + 0x6ed9eba1), 15); - - A = rotintlft((A + H(B, C, D) + d[2] + 0x6ed9eba1), 3); - D = rotintlft((D + H(A, B, C) + d[10] + 0x6ed9eba1), 9); - C = rotintlft((C + H(D, A, B) + d[6] + 0x6ed9eba1), 11); - B = rotintlft((B + H(C, D, A) + d[14] + 0x6ed9eba1), 15); - - A = rotintlft((A + H(B, C, D) + d[1] + 0x6ed9eba1), 3); - D = rotintlft((D + H(A, B, C) + d[9] + 0x6ed9eba1), 9); - C = rotintlft((C + H(D, A, B) + d[5] + 0x6ed9eba1), 11); - B = rotintlft((B + H(C, D, A) + d[13] + 0x6ed9eba1), 15); - - A = rotintlft((A + H(B, C, D) + d[3] + 0x6ed9eba1), 3); - D = rotintlft((D + H(A, B, C) + d[11] + 0x6ed9eba1), 9); - C = rotintlft((C + H(D, A, B) + d[7] + 0x6ed9eba1), 11); - B = rotintlft((B + H(C, D, A) + d[15] + 0x6ed9eba1), 15); + A = rotintlft(A + H(B, C, D) + d[0] + 0x6ed9eba1, 3); + D = rotintlft(D + H(A, B, C) + d[8] + 0x6ed9eba1, 9); + C = rotintlft(C + H(D, A, B) + d[4] + 0x6ed9eba1, 11); + B = rotintlft(B + H(C, D, A) + d[12] + 0x6ed9eba1, 15); + + A = rotintlft(A + H(B, C, D) + d[2] + 0x6ed9eba1, 3); + D = rotintlft(D + H(A, B, C) + d[10] + 0x6ed9eba1, 9); + C = rotintlft(C + H(D, A, B) + d[6] + 0x6ed9eba1, 11); + B = rotintlft(B + H(C, D, A) + d[14] + 0x6ed9eba1, 15); + + A = rotintlft(A + H(B, C, D) + d[1] + 0x6ed9eba1, 3); + D = rotintlft(D + H(A, B, C) + d[9] + 0x6ed9eba1, 9); + C = rotintlft(C + H(D, A, B) + d[5] + 0x6ed9eba1, 11); + B = rotintlft(B + H(C, D, A) + d[13] + 0x6ed9eba1, 15); + + A = rotintlft(A + H(B, C, D) + d[3] + 0x6ed9eba1, 3); + D = rotintlft(D + H(A, B, C) + d[11] + 0x6ed9eba1, 9); + C = rotintlft(C + H(D, A, B) + d[7] + 0x6ed9eba1, 11); + B = rotintlft(B + H(C, D, A) + d[15] + 0x6ed9eba1, 15); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java index 5086e01a0e..c8736445d5 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/SystemDefaultCredentialsProvider.java @@ -162,7 +162,7 @@ private static PasswordAuthentication getProxyCredentials(final String protocol, return new PasswordAuthentication(proxyUser, proxyPassword != null ? proxyPassword.toCharArray() : new char[] {}); } - } catch (final NumberFormatException ex) { + } catch (final NumberFormatException ignore) { } return null; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java index 1c5cbab752..482d6be154 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ConnectExec.java @@ -146,7 +146,7 @@ public ClassicHttpResponse execute( break; case HttpRouteDirector.CONNECT_PROXY: execRuntime.connectEndpoint(context); - final HttpHost proxy = route.getProxyHost(); + final HttpHost proxy = route.getProxyHost(); tracker.connectProxy(proxy, route.isSecure() && !route.isTunnelled()); break; case HttpRouteDirector.TUNNEL_TARGET: { @@ -159,20 +159,22 @@ public ClassicHttpResponse execute( LOG.debug("{} tunnel to target created.", exchangeId); } tracker.tunnelTarget(false); - } break; + } + break; case HttpRouteDirector.TUNNEL_PROXY: { // The most simple example for this case is a proxy chain // of two proxies, where P1 must be tunnelled to P2. // route: Source -> P1 -> P2 -> Target (3 hops) // fact: Source -> P1 -> Target (2 hops) - final int hop = fact.getHopCount()-1; // the hop to establish + final int hop = fact.getHopCount() - 1; // the hop to establish final boolean secure = createTunnelToProxy(route, hop, context); if (LOG.isDebugEnabled()) { LOG.debug("{} tunnel to proxy created.", exchangeId); } tracker.tunnelProxy(route.getHopTarget(hop), secure); - } break; + } + break; case HttpRouteDirector.LAYER_PROTOCOL: execRuntime.upgradeTls(context); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/FutureRequestExecutionService.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/FutureRequestExecutionService.java index 209cf42b4d..a5e4262a34 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/FutureRequestExecutionService.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/FutureRequestExecutionService.java @@ -112,7 +112,7 @@ public FutureTask execute( final HttpContext context, final HttpClientResponseHandler HttpClientResponseHandler, final FutureCallback callback) { - if(closed.get()) { + if (closed.get()) { throw new IllegalStateException("Close has been called on this httpclient instance."); } metrics.getScheduledConnections().incrementAndGet(); 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 49568b7ec2..7813bc171d 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 @@ -117,14 +117,14 @@ public void acquireEndpoint( if (log.isDebugEnabled()) { log.debug("{} acquired endpoint {}", id, ConnPoolSupport.getId(connectionEndpoint)); } - } catch(final TimeoutException ex) { + } catch (final TimeoutException ex) { connRequest.cancel(); throw new ConnectionRequestTimeoutException(ex.getMessage()); - } catch(final InterruptedException interrupted) { + } catch (final InterruptedException interrupted) { connRequest.cancel(); Thread.currentThread().interrupt(); throw new RequestFailedException("Request aborted", interrupted); - } catch(final ExecutionException ex) { + } catch (final ExecutionException ex) { connRequest.cancel(); Throwable cause = ex.getCause(); if (cause == null) { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalHttpClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalHttpClient.java index 4215d4285f..87b3ff864f 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalHttpClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/InternalHttpClient.java @@ -117,7 +117,7 @@ public InternalHttpClient( this.credentialsProvider = credentialsProvider; this.contextAdaptor = contextAdaptor; this.defaultConfig = defaultConfig; - this.closeables = closeables != null ? new ConcurrentLinkedQueue<>(closeables) : null; + this.closeables = closeables != null ? new ConcurrentLinkedQueue<>(closeables) : null; } private HttpRoute determineRoute(final HttpHost target, final HttpRequest request, final HttpContext context) throws HttpException { 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 3c21d28e50..e3d6547695 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 @@ -118,7 +118,7 @@ public ClassicHttpResponse execute( return response; } if (redirectCount >= maxRedirects) { - throw new RedirectException("Maximum redirects ("+ maxRedirects + ") exceeded"); + throw new RedirectException("Maximum redirects (" + maxRedirects + ") exceeded"); } redirectCount++; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RequestEntityProxy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RequestEntityProxy.java index 29c861f6a7..b006bf80b4 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RequestEntityProxy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RequestEntityProxy.java @@ -37,7 +37,7 @@ import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HttpEntity; -class RequestEntityProxy implements HttpEntity { +class RequestEntityProxy implements HttpEntity { static void enhance(final ClassicHttpRequest request) { final HttpEntity entity = request.getEntity(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ResponseEntityProxy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ResponseEntityProxy.java index 4c7612c718..5e6b91da88 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ResponseEntityProxy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ResponseEntityProxy.java @@ -190,7 +190,8 @@ public void close() throws IOException { private static final class NullOutputStream extends OutputStream { private static final NullOutputStream INSTANCE = new NullOutputStream(); - private NullOutputStream() {} + private NullOutputStream() { + } @Override public void write(@SuppressWarnings("unused") final int byteValue) { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicClientCookie.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicClientCookie.java index 004df60a2e..95c65fd9b4 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicClientCookie.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicClientCookie.java @@ -159,7 +159,7 @@ public void setExpiryDate (final Instant expiryInstant) { */ @Override public boolean isPersistent() { - return (null != cookieExpiryDate); + return null != cookieExpiryDate; } @@ -268,8 +268,8 @@ public void setHttpOnly(final boolean httpOnly) { @Override public boolean isExpired(final Date date) { Args.notNull(date, "Date"); - return (cookieExpiryDate != null - && cookieExpiryDate.compareTo(DateUtils.toInstant(date)) <= 0); + return cookieExpiryDate != null + && cookieExpiryDate.compareTo(DateUtils.toInstant(date)) <= 0; } /** @@ -281,8 +281,8 @@ public boolean isExpired(final Date date) { @Override public boolean isExpired(final Instant instant) { Args.notNull(instant, "Instant"); - return (cookieExpiryDate != null - && cookieExpiryDate.compareTo(instant) <= 0); + return cookieExpiryDate != null + && cookieExpiryDate.compareTo(instant) <= 0; } /** @@ -391,7 +391,7 @@ public String toString() { private String value; /** Domain attribute. */ - private String cookieDomain; + private String cookieDomain; /** Expiration {@link Instant}. */ private Instant cookieExpiryDate; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java index 8286f5d875..462c6b38ce 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java @@ -132,7 +132,7 @@ public boolean match(final Cookie cookie, final CookieOrigin origin) { if (host.equals(domain)) { return true; } - if ((cookie.containsAttribute(Cookie.DOMAIN_ATTR))) { + if (cookie.containsAttribute(Cookie.DOMAIN_ATTR)) { return domainMatch(domain, host); } return false; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java index 88bf7be6e1..2e66745c87 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java @@ -139,7 +139,7 @@ public void parse(final SetCookie cookie, final String value) throws MalformedCo foundTime = true; hour = Integer.parseInt(matcher.group(1)); minute = Integer.parseInt(matcher.group(2)); - second =Integer.parseInt(matcher.group(3)); + second = Integer.parseInt(matcher.group(3)); continue; } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpec.java index 956b37f52a..c15c78808d 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpec.java @@ -61,11 +61,11 @@ @Contract(threading = ThreadingBehavior.SAFE) public class RFC6265CookieSpec implements CookieSpec { - private final static char PARAM_DELIMITER = ';'; - private final static char COMMA_CHAR = ','; - private final static char EQUAL_CHAR = '='; - private final static char DQUOTE_CHAR = '"'; - private final static char ESCAPE_CHAR = '\\'; + private final static char PARAM_DELIMITER = ';'; + private final static char COMMA_CHAR = ','; + private final static char EQUAL_CHAR = '='; + private final static char DQUOTE_CHAR = '"'; + private final static char ESCAPE_CHAR = '\\'; // IMPORTANT! // These private static variables must be treated as immutable and never exposed outside this class diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java index 8dcbc10ea5..7239fa9332 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/ManagedHttpClientConnectionFactory.java @@ -170,7 +170,7 @@ public ManagedHttpClientConnection createConnection(final Socket socket) throws * * @since 5.1 */ - public static Builder builder() { + public static Builder builder() { return new Builder(); } @@ -189,7 +189,8 @@ public static final class Builder { private HttpMessageWriterFactory requestWriterFactory; private HttpMessageParserFactory responseParserFactory; - private Builder() {} + private Builder() { + } public Builder http1Config(final Http1Config http1Config) { this.http1Config = http1Config; 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 c456dfa7ac..b9c13f7d08 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 @@ -301,7 +301,7 @@ public void completed(final PoolEntry p final ProtocolVersion protocolVersion = connection.getProtocolVersion(); if (protocolVersion != null && protocolVersion.greaterEquals(HttpVersion.HTTP_2_0)) { connection.submitCommand(new PingCommand(new BasicPingHandler(result -> { - if (result == null || !result) { + if (result == null || !result) { if (LOG.isDebugEnabled()) { LOG.debug("{} connection {} is stale", id, ConnPoolSupport.getId(connection)); } @@ -443,7 +443,7 @@ public Future connect( } final PoolEntry poolEntry = internalEndpoint.getPoolEntry(); final HttpRoute route = poolEntry.getRoute(); - final HttpHost firstHop = route.getProxyHost() != null ? route.getProxyHost(): route.getTargetHost(); + final HttpHost firstHop = route.getProxyHost() != null ? route.getProxyHost() : route.getTargetHost(); final ConnectionConfig connectionConfig = resolveConnectionConfig(route); final Timeout connectTimeout = timeout != null ? timeout : connectionConfig.getConnectTimeout(); @@ -638,7 +638,7 @@ public void setTlsConfigResolver(final Resolver tlsConfigRe this.tlsConfigResolver = tlsConfigResolver; } - void closeIfExpired(final PoolEntry entry) { + void closeIfExpired(final PoolEntry entry) { final long now = System.currentTimeMillis(); if (entry.getExpiryDeadline().isBefore(now)) { entry.discardConnection(CloseMode.GRACEFUL); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/BasicRouteDirector.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/BasicRouteDirector.java index 142b3e9aed..28cda188b4 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/BasicRouteDirector.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/routing/BasicRouteDirector.java @@ -65,7 +65,7 @@ public int nextStep(final RouteInfo plan, final RouteInfo fact) { int step = UNREACHABLE; - if ((fact == null) || (fact.getHopCount() < 1)) { + if (fact == null || fact.getHopCount() < 1) { step = firstStep(plan); } else if (plan.getHopCount() > 1) { step = proxiedStep(plan, fact); @@ -122,9 +122,8 @@ protected int directStep(final RouteInfo plan, final RouteInfo fact) { } // Local address has to match only if the plan specifies one. - if ((plan.getLocalAddress() != null) && - !plan.getLocalAddress().equals(fact.getLocalAddress()) - ) { + if (plan.getLocalAddress() != null && + !plan.getLocalAddress().equals(fact.getLocalAddress())) { return UNREACHABLE; } @@ -155,7 +154,7 @@ protected int proxiedStep(final RouteInfo plan, final RouteInfo fact) { return UNREACHABLE; } - for (int i=0; i proxies) { Proxy result = null; // check the list for one we can use - for (int i=0; (result == null) && (i < proxies.size()); i++) { + for (int i = 0; result == null && i < proxies.size(); i++) { final Proxy p = proxies.get(i); switch (p.type()) { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpClientContext.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpClientContext.java index 6551d3dfdd..f58a8042b2 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpClientContext.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/HttpClientContext.java @@ -70,7 +70,7 @@ public class HttpClientContext extends HttpCoreContext { * @deprecated Use getter methods */ @Deprecated - public static final String HTTP_ROUTE = "http.route"; + public static final String HTTP_ROUTE = "http.route"; /** * @deprecated Use getter methods @@ -82,55 +82,55 @@ public class HttpClientContext extends HttpCoreContext { * @deprecated Use getter methods */ @Deprecated - public static final String COOKIESPEC_REGISTRY = "http.cookiespec-registry"; + public static final String COOKIESPEC_REGISTRY = "http.cookiespec-registry"; /** * @deprecated Use getter methods */ @Deprecated - public static final String COOKIE_SPEC = "http.cookie-spec"; + public static final String COOKIE_SPEC = "http.cookie-spec"; /** * @deprecated Use getter methods */ @Deprecated - public static final String COOKIE_ORIGIN = "http.cookie-origin"; + public static final String COOKIE_ORIGIN = "http.cookie-origin"; /** * @deprecated Use getter methods */ @Deprecated - public static final String COOKIE_STORE = "http.cookie-store"; + public static final String COOKIE_STORE = "http.cookie-store"; /** * @deprecated Use getter methods */ @Deprecated - public static final String CREDS_PROVIDER = "http.auth.credentials-provider"; + public static final String CREDS_PROVIDER = "http.auth.credentials-provider"; /** * @deprecated Use getter methods */ @Deprecated - public static final String AUTH_CACHE = "http.auth.auth-cache"; + public static final String AUTH_CACHE = "http.auth.auth-cache"; /** * @deprecated Use getter methods */ @Deprecated - public static final String AUTH_EXCHANGE_MAP = "http.auth.exchanges"; + public static final String AUTH_EXCHANGE_MAP = "http.auth.exchanges"; /** * @deprecated Use getter methods */ @Deprecated - public static final String USER_TOKEN = "http.user-token"; + public static final String USER_TOKEN = "http.user-token"; /** * @deprecated Use getter methods */ @Deprecated - public static final String AUTHSCHEME_REGISTRY = "http.authscheme-registry"; + public static final String AUTHSCHEME_REGISTRY = "http.authscheme-registry"; /** * @deprecated Use getter methods diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestDefaultHeaders.java b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestDefaultHeaders.java index 3e68b0978f..ea008acc21 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestDefaultHeaders.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/protocol/RequestDefaultHeaders.java @@ -82,7 +82,7 @@ public void process(final HttpRequest request, final EntityDetails entity, final if (this.defaultHeaders != null) { for (final Header defHeader : this.defaultHeaders) { - if(!request.containsHeader(defHeader.getName())) { + if (!request.containsHeader(defHeader.getName())) { request.addHeader(defHeader); } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java index 37c03c7852..a78f29826d 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java @@ -63,8 +63,8 @@ public PublicSuffixMatcher(final Collection rules, final Collection rules, final Collection exceptions) { - Args.notNull(domainType, "Domain type"); - Args.notNull(rules, "Domain suffix rules"); + Args.notNull(domainType, "Domain type"); + Args.notNull(rules, "Domain suffix rules"); this.rules = new ConcurrentHashMap<>(rules.size()); for (final String rule: rules) { this.rules.put(rule, domainType); @@ -81,7 +81,7 @@ public PublicSuffixMatcher( * @since 4.5 */ public PublicSuffixMatcher(final Collection lists) { - Args.notNull(lists, "Domain suffix lists"); + Args.notNull(lists, "Domain suffix lists"); this.rules = new ConcurrentHashMap<>(); this.exceptions = new ConcurrentHashMap<>(); for (final PublicSuffixList list: lists) { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java b/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java index 7db6933d1b..f0b589bfda 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/routing/RoutingSupport.java @@ -71,7 +71,7 @@ public static HttpHost normalize(final HttpHost host, final SchemePortResolver s return null; } if (host.getPort() < 0) { - final int port = (schemePortResolver != null ? schemePortResolver: DefaultSchemePortResolver.INSTANCE).resolve(host); + final int port = (schemePortResolver != null ? schemePortResolver : DefaultSchemePortResolver.INSTANCE).resolve(host); if (port > 0) { return new HttpHost(host.getSchemeName(), host.getAddress(), host.getHostName(), port); } 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 8718703108..e9a7721aeb 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 @@ -100,7 +100,7 @@ public Socket connectSocket( return null; }); } catch (final PrivilegedActionException e) { - Asserts.check(e.getCause() instanceof IOException, + Asserts.check(e.getCause() instanceof IOException, "method contract violation only checked exceptions are wrapped: " + e.getCause()); // only checked exceptions are wrapped - error and RTExceptions are rethrown by doPrivileged throw (IOException) e.getCause(); 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 c18a144e46..e4f6481f6e 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 @@ -226,7 +226,7 @@ private void executeHandshake( if (supportedProtocols != null) { sslParameters.setProtocols(supportedProtocols); } else { - sslParameters.setProtocols((TLS.excludeWeak(upgradedSocket.getEnabledProtocols()))); + sslParameters.setProtocols(TLS.excludeWeak(upgradedSocket.getEnabledProtocols())); } if (supportedCipherSuites != null) { sslParameters.setCipherSuites(supportedCipherSuites); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DistinguishedNameParser.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DistinguishedNameParser.java index 21f27708da..a6fb7bf044 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DistinguishedNameParser.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DistinguishedNameParser.java @@ -114,7 +114,7 @@ public void copyUnquotedContent( dst.append(current); escaped = false; } else { - if ((delimiters != null && delimiters.test(current)) + if (delimiters != null && delimiters.test(current) || Tokenizer.isWhitespace(current) || current == '\"') { break; } else if (current == '\\') { 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 3ffe908e39..118f3e81fe 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 @@ -328,7 +328,7 @@ private void executeHandshake( if (supportedProtocols != null) { sslsock.setEnabledProtocols(supportedProtocols); } else { - sslsock.setEnabledProtocols((TLS.excludeWeak(sslsock.getEnabledProtocols()))); + sslsock.setEnabledProtocols(TLS.excludeWeak(sslsock.getEnabledProtocols())); } if (supportedCipherSuites != null) { sslsock.setEnabledCipherSuites(supportedCipherSuites); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/utils/ByteArrayBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/utils/ByteArrayBuilder.java index d8a8b6400d..8f8bed748c 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/utils/ByteArrayBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/utils/ByteArrayBuilder.java @@ -126,8 +126,8 @@ public ByteArrayBuilder append(final byte[] b, final int off, final int len) { if (b == null) { return this; } - if ((off < 0) || (off > b.length) || (len < 0) || - ((off + len) < 0) || ((off + len) > b.length)) { + if (off < 0 || off > b.length || len < 0 || + off + len < 0 || off + len > b.length) { throw new IndexOutOfBoundsException("off: " + off + " len: " + len + " b.length: " + b.length); } ensureFreeCapacity(len); @@ -154,8 +154,8 @@ public ByteArrayBuilder append(final char[] b, final int off, final int len) { if (b == null) { return this; } - if ((off < 0) || (off > b.length) || (len < 0) || - ((off + len) < 0) || ((off + len) > b.length)) { + if (off < 0 || off > b.length || len < 0 || + off + len < 0 || off + len > b.length) { throw new IndexOutOfBoundsException("off: " + off + " len: " + len + " b.length: " + b.length); } return append(CharBuffer.wrap(b, off, len)); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java b/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java index 6614f4236a..7be5443057 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java @@ -340,29 +340,29 @@ void testEqualsHashcodeClone() throws CloneNotSupportedException { void testHopping() { // test getHopCount() and getHopTarget() with different proxy chains final HttpHost[] proxies = null; - final HttpRoute route = new HttpRoute(TARGET1, null, proxies, true, - TunnelType.PLAIN, LayerType.PLAIN); + final HttpRoute route = new HttpRoute(TARGET1, null, proxies, true, + TunnelType.PLAIN, LayerType.PLAIN); Assertions.assertEquals(1, route.getHopCount(), "A: hop count"); Assertions.assertEquals(TARGET1, route.getHopTarget(0), "A: hop 0"); Assertions.assertThrows(IllegalArgumentException.class, () -> route.getHopTarget(1)); - Assertions.assertThrows(IllegalArgumentException.class, () -> route.getHopTarget(-1)); + Assertions.assertThrows(IllegalArgumentException.class, () -> route.getHopTarget(-1)); - final HttpHost[] proxies2 = new HttpHost[]{ PROXY3 }; - final HttpRoute route2 = new HttpRoute(TARGET1, LOCAL62, proxies2, false, - TunnelType.TUNNELLED, LayerType.PLAIN); + final HttpHost[] proxies2 = new HttpHost[]{PROXY3}; + final HttpRoute route2 = new HttpRoute(TARGET1, LOCAL62, proxies2, false, + TunnelType.TUNNELLED, LayerType.PLAIN); Assertions.assertEquals(2, route2.getHopCount(), "B: hop count"); Assertions.assertEquals(PROXY3, route2.getHopTarget(0), "B: hop 0"); Assertions.assertEquals(TARGET1, route2.getHopTarget(1), "B: hop 1"); Assertions.assertThrows(IllegalArgumentException.class, () -> route2.getHopTarget(2)); Assertions.assertThrows(IllegalArgumentException.class, () -> route2.getHopTarget(-2)); - final HttpHost[] proxies3 = new HttpHost[]{ PROXY3, PROXY1, PROXY2 }; - final HttpRoute route3 = new HttpRoute(TARGET1, LOCAL42, proxies3, false, - TunnelType.PLAIN, LayerType.LAYERED); + final HttpHost[] proxies3 = new HttpHost[]{PROXY3, PROXY1, PROXY2}; + final HttpRoute route3 = new HttpRoute(TARGET1, LOCAL42, proxies3, false, + TunnelType.PLAIN, LayerType.LAYERED); Assertions.assertEquals(4, route3.getHopCount(), "C: hop count"); - Assertions.assertEquals(PROXY3 , route3.getHopTarget(0), "C: hop 0"); - Assertions.assertEquals(PROXY1 , route3.getHopTarget(1), "C: hop 1"); - Assertions.assertEquals(PROXY2 , route3.getHopTarget(2), "C: hop 2"); + Assertions.assertEquals(PROXY3, route3.getHopTarget(0), "C: hop 0"); + Assertions.assertEquals(PROXY1, route3.getHopTarget(1), "C: hop 1"); + Assertions.assertEquals(PROXY2, route3.getHopTarget(2), "C: hop 2"); Assertions.assertEquals(TARGET1, route3.getHopTarget(3), "C: hop 3"); Assertions.assertThrows(IllegalArgumentException.class, () -> route3.getHopTarget(4)); Assertions.assertThrows(IllegalArgumentException.class, () -> route3.getHopTarget(Integer.MIN_VALUE)); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestCredentials.java b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestCredentials.java index 51896c0976..496314c12b 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestCredentials.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestCredentials.java @@ -64,7 +64,7 @@ void testNTCredentialsBasics() { Assertions.assertEquals(new NTUserPrincipal("DOMAIN", "name"), creds1.getUserPrincipal()); Assertions.assertArrayEquals("pwd".toCharArray(), creds1.getPassword()); - Assertions.assertEquals("[principal: DOMAIN\\name][workstation: "+ creds1.getWorkstation() +"][netbiosDomain: DOMAIN]", + Assertions.assertEquals("[principal: DOMAIN\\name][workstation: " + creds1.getWorkstation() + "][netbiosDomain: DOMAIN]", creds1.toString()); final NTCredentials creds2 = new NTCredentials( "name", null, null, null); @@ -72,7 +72,7 @@ void testNTCredentialsBasics() { Assertions.assertEquals(new NTUserPrincipal(null, "name"), creds2.getUserPrincipal()); Assertions.assertNull(creds2.getPassword()); - Assertions.assertEquals("[principal: name][workstation: "+creds1.getWorkstation() +"][netbiosDomain: null]", + Assertions.assertEquals("[principal: name][workstation: " + creds1.getWorkstation() + "][netbiosDomain: null]", creds2.toString()); } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/FormBodyPartTest.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/FormBodyPartTest.java index 109d529dc7..c66f6e17db 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/FormBodyPartTest.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/FormBodyPartTest.java @@ -37,9 +37,10 @@ class FormBodyPartTest { @Test void testConstructorCompat() throws Exception { - final File tmp= File.createTempFile("test", "test"); + final File tmp = File.createTempFile("test", "test"); tmp.deleteOnExit(); final FileBody obj = new FileBody(tmp, ContentType.APPLICATION_OCTET_STREAM); Assertions.assertEquals(tmp.getName(), obj.getFilename()); } + } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java index bdba6c093c..b96c59fb81 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java @@ -153,7 +153,7 @@ void testMultipartCustomContentTypeUsingAddParameter() { eb.addParameter(new BasicNameValuePair("charset", "ascii")); eb.addParameter(new BasicNameValuePair("my", "stuff")); eb.buildEntity(); - final MultipartFormEntity entity = eb.buildEntity(); + final MultipartFormEntity entity = eb.buildEntity(); Assertions.assertNotNull(entity); Assertions.assertEquals("multipart/related; boundary=yada-yada; charset=ascii; my=stuff", entity.getContentType()); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientConnectionConfig.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientConnectionConfig.java index 2cf9ed2e75..2dd160cb82 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientConnectionConfig.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientConnectionConfig.java @@ -58,7 +58,6 @@ public static void main(final String[] args) throws Exception { final PoolingAsyncClientConnectionManager cm = PoolingAsyncClientConnectionManagerBuilder.create() .setConnectionConfigResolver(route -> { // Use different settings for all secure (TLS) connections - final HttpHost targetHost = route.getTargetHost(); if (route.isSecure()) { return ConnectionConfig.custom() .setConnectTimeout(Timeout.ofMinutes(2)) diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java index b51c50e436..64504fd5a2 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java @@ -43,7 +43,7 @@ public class ClientChunkEncodedPost { public static void main(final String[] args) throws Exception { - if (args.length != 1) { + if (args.length != 1) { System.out.println("File path not given"); System.exit(1); } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConnectionConfig.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConnectionConfig.java index 543a5c2429..0f9dcd35b1 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConnectionConfig.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConnectionConfig.java @@ -52,7 +52,6 @@ public final static void main(final String[] args) throws Exception { final PoolingHttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder.create() .setConnectionConfigResolver(route -> { // Use different settings for all secure (TLS) connections - final HttpHost targetHost = route.getTargetHost(); if (route.isSecure()) { return ConnectionConfig.custom() .setConnectTimeout(Timeout.ofMinutes(2)) diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java index 79f382ff1e..189c139d73 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java @@ -45,7 +45,7 @@ public class ClientMultipartFormPost { public static void main(final String[] args) throws Exception { - if (args.length != 1) { + if (args.length != 1) { System.out.println("File path not given"); System.exit(1); } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicScheme.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicScheme.java index 57674be663..efd32e4be5 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicScheme.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicScheme.java @@ -78,7 +78,7 @@ void testBasicAuthentication() throws Exception { final BasicScheme authscheme = new BasicScheme(); authscheme.processChallenge(authChallenge, null); - final HttpHost host = new HttpHost("somehost", 80); + final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() .add(new AuthScope(host, "test", null), "testuser", "testpass".toCharArray()) .build(); @@ -87,7 +87,7 @@ void testBasicAuthentication() throws Exception { Assertions.assertTrue(authscheme.isResponseReady(host, credentialsProvider, null)); final String authResponse = authscheme.generateAuthResponse(host, request, null); - final byte[] testCreds = "testuser:testpass".getBytes(StandardCharsets.US_ASCII); + final byte[] testCreds = "testuser:testpass".getBytes(StandardCharsets.US_ASCII); final String expected = "Basic " + BASE64_ENC.encodeToString(testCreds); @@ -101,7 +101,7 @@ void testBasicAuthentication() throws Exception { @Test void testBasicAuthenticationDefaultCharset() throws Exception { - final HttpHost host = new HttpHost("somehost", 80); + final HttpHost host = new HttpHost("somehost", 80); final UsernamePasswordCredentials creds = new UsernamePasswordCredentials("test", TEST_UTF8_PASSWORD.toCharArray()); final BasicScheme authscheme = new BasicScheme(); final HttpRequest request = new BasicHttpRequest("GET", "/"); @@ -112,7 +112,7 @@ void testBasicAuthenticationDefaultCharset() throws Exception { @Test void testBasicAuthenticationDefaultCharsetUTF8() throws Exception { - final HttpHost host = new HttpHost("somehost", 80); + final HttpHost host = new HttpHost("somehost", 80); final UsernamePasswordCredentials creds = new UsernamePasswordCredentials("test", TEST_UTF8_PASSWORD.toCharArray()); final BasicScheme authscheme = new BasicScheme(); final HttpRequest request = new BasicHttpRequest("GET", "/"); @@ -128,7 +128,7 @@ void testBasicAuthenticationWithCharset() throws Exception { final BasicScheme authscheme = new BasicScheme(); authscheme.processChallenge(authChallenge, null); - final HttpHost host = new HttpHost("somehost", 80); + final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() .add(new AuthScope(host, "test", null), "test", TEST_UTF8_PASSWORD.toCharArray()) .build(); @@ -161,7 +161,7 @@ void testSerialization() throws Exception { @Test void testBasicAuthenticationUserCredentialsMissing() { final BasicScheme authscheme = new BasicScheme(); - final HttpHost host = new HttpHost("somehost", 80); + final HttpHost host = new HttpHost("somehost", 80); final HttpRequest request = new BasicHttpRequest("GET", "/"); Assertions.assertThrows(AuthenticationException.class, () -> authscheme.generateAuthResponse(host, request, null)); } @@ -169,7 +169,7 @@ void testBasicAuthenticationUserCredentialsMissing() { @Test void testBasicAuthenticationUsernameWithBlank() throws Exception { final BasicScheme authscheme = new BasicScheme(); - final HttpHost host = new HttpHost("somehost", 80); + final HttpHost host = new HttpHost("somehost", 80); final HttpRequest request = new BasicHttpRequest("GET", "/"); authscheme.initPreemptive(new UsernamePasswordCredentials("blah blah", null)); authscheme.generateAuthResponse(host, request, null); @@ -178,7 +178,7 @@ void testBasicAuthenticationUsernameWithBlank() throws Exception { @Test void testBasicAuthenticationUsernameWithTab() { final BasicScheme authscheme = new BasicScheme(); - final HttpHost host = new HttpHost("somehost", 80); + final HttpHost host = new HttpHost("somehost", 80); final HttpRequest request = new BasicHttpRequest("GET", "/"); authscheme.initPreemptive(new UsernamePasswordCredentials("blah\tblah", null)); Assertions.assertThrows(AuthenticationException.class, () -> authscheme.generateAuthResponse(host, request, null)); @@ -187,7 +187,7 @@ void testBasicAuthenticationUsernameWithTab() { @Test void testBasicAuthenticationUsernameWithColon() { final BasicScheme authscheme = new BasicScheme(); - final HttpHost host = new HttpHost("somehost", 80); + final HttpHost host = new HttpHost("somehost", 80); final HttpRequest request = new BasicHttpRequest("GET", "/"); authscheme.initPreemptive(new UsernamePasswordCredentials("blah:blah", null)); Assertions.assertThrows(AuthenticationException.class, () -> authscheme.generateAuthResponse(host, request, null)); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBearerScheme.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBearerScheme.java index 175a357e82..a2ebdea344 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBearerScheme.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBearerScheme.java @@ -60,7 +60,7 @@ void testBearerAuthentication() throws Exception { final AuthScheme authscheme = new BearerScheme(); authscheme.processChallenge(authChallenge, null); - final HttpHost host = new HttpHost("somehost", 80); + final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() .add(new AuthScope(host, "test", null), new BearerToken("some token")) .build(); 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 98b9747ea1..5aa3c9a9cf 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 @@ -296,10 +296,10 @@ void testDigestAuthenticationMD5Algorithm() throws Exception { void testDigestAuthenticationMD5Sess() throws Exception { // Example using Digest auth with MD5-sess - final String realm="realm"; - final String username="username"; - final String password="password"; - final String nonce="e273f1776275974f1a120d8b92c5b3cb"; + final String realm = "realm"; + final String username = "username"; + final String password = "password"; + final String nonce = "e273f1776275974f1a120d8b92c5b3cb"; final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); @@ -307,7 +307,7 @@ void testDigestAuthenticationMD5Sess() throws Exception { .add(new AuthScope(host, realm, null), username, password.toCharArray()) .build(); - final String challenge=StandardAuthScheme.DIGEST + " realm=\"" + realm + "\", " + final String challenge = StandardAuthScheme.DIGEST + " realm=\"" + realm + "\", " + "nonce=\"" + nonce + "\", " + "opaque=\"SomeString\", " + "stale=false, " @@ -331,7 +331,7 @@ void testDigestAuthenticationMD5Sess() throws Exception { Assertions.assertEquals("MD5-sess", table.get("algorithm")); Assertions.assertEquals("/", table.get("uri")); Assertions.assertEquals(nonce, table.get("nonce")); - Assertions.assertEquals(1, Integer.parseInt(table.get("nc"),16)); + Assertions.assertEquals(1, Integer.parseInt(table.get("nc"), 16)); Assertions.assertNotNull(table.get("cnonce")); Assertions.assertEquals("SomeString", table.get("opaque")); Assertions.assertEquals("auth", table.get("qop")); @@ -346,10 +346,10 @@ void testDigestAuthenticationMD5Sess() throws Exception { void testDigestAuthenticationMD5SessNoQop() throws Exception { // Example using Digest auth with MD5-sess - final String realm="realm"; - final String username="username"; - final String password="password"; - final String nonce="e273f1776275974f1a120d8b92c5b3cb"; + final String realm = "realm"; + final String username = "username"; + final String password = "password"; + final String nonce = "e273f1776275974f1a120d8b92c5b3cb"; final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); @@ -357,7 +357,7 @@ void testDigestAuthenticationMD5SessNoQop() throws Exception { .add(new AuthScope(host, realm, null), username, password.toCharArray()) .build(); - final String challenge=StandardAuthScheme.DIGEST + " realm=\"" + realm + "\", " + final String challenge = StandardAuthScheme.DIGEST + " realm=\"" + realm + "\", " + "nonce=\"" + nonce + "\", " + "opaque=\"SomeString\", " + "stale=false, " @@ -390,10 +390,10 @@ void testDigestAuthenticationMD5SessNoQop() throws Exception { void testDigestAuthenticationMD5SessUnknownQop() throws Exception { // Example using Digest auth with MD5-sess - final String realm="realm"; - final String username="username"; - final String password="password"; - final String nonce="e273f1776275974f1a120d8b92c5b3cb"; + final String realm = "realm"; + final String username = "username"; + final String password = "password"; + final String nonce = "e273f1776275974f1a120d8b92c5b3cb"; final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); @@ -401,7 +401,7 @@ void testDigestAuthenticationMD5SessUnknownQop() throws Exception { .add(new AuthScope(host, realm, null), username, password.toCharArray()) .build(); - final String challenge=StandardAuthScheme.DIGEST + " realm=\"" + realm + "\", " + final String challenge = StandardAuthScheme.DIGEST + " realm=\"" + realm + "\", " + "nonce=\"" + nonce + "\", " + "opaque=\"SomeString\", " + "stale=false, " @@ -425,10 +425,10 @@ void testDigestAuthenticationMD5SessUnknownQop() throws Exception { void testDigestAuthenticationUnknownAlgo() throws Exception { // Example using Digest auth with MD5-sess - final String realm="realm"; - final String username="username"; - final String password="password"; - final String nonce="e273f1776275974f1a120d8b92c5b3cb"; + final String realm = "realm"; + final String username = "username"; + final String password = "password"; + final String nonce = "e273f1776275974f1a120d8b92c5b3cb"; final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); @@ -436,7 +436,7 @@ void testDigestAuthenticationUnknownAlgo() throws Exception { .add(new AuthScope(host, realm, null), username, password.toCharArray()) .build(); - final String challenge=StandardAuthScheme.DIGEST + " realm=\"" + realm + "\", " + final String challenge = StandardAuthScheme.DIGEST + " realm=\"" + realm + "\", " + "nonce=\"" + nonce + "\", " + "opaque=\"SomeString\", " + "stale=false, " @@ -554,7 +554,7 @@ void testDigestMD5SessA1AndCnonceConsistency() throws Exception { Assertions.assertEquals(sessionKey1, sessionKey2); final String challenge2 = StandardAuthScheme.DIGEST + " qop=\"auth\", algorithm=MD5-sess, nonce=\"1234567890abcdef\", " + - "charset=utf-8, realm=\"subnet.domain.com\""; + "charset=utf-8, realm=\"subnet.domain.com\""; final AuthChallenge authChallenge2 = parse(challenge2); authscheme.processChallenge(authChallenge2, null); Assertions.assertTrue(authscheme.isResponseReady(host, credentialsProvider, null)); @@ -569,7 +569,7 @@ void testDigestMD5SessA1AndCnonceConsistency() throws Exception { Assertions.assertEquals(sessionKey1, sessionKey3); final String challenge3 = StandardAuthScheme.DIGEST + " qop=\"auth\", algorithm=MD5-sess, nonce=\"fedcba0987654321\", " + - "charset=utf-8, realm=\"subnet.domain.com\""; + "charset=utf-8, realm=\"subnet.domain.com\""; final AuthChallenge authChallenge3 = parse(challenge3); authscheme.processChallenge(authChallenge3, null); Assertions.assertTrue(authscheme.isResponseReady(host, credentialsProvider, null)); @@ -594,12 +594,12 @@ void testHttpEntityDigest() throws Exception { digester.write(0xe4); digester.write(0xf6); digester.write(0xfc); - digester.write(new byte[] { 'a', 'b', 'c'}); + digester.write(new byte[]{'a', 'b', 'c'}); Assertions.assertNull(digester.getDigest()); digester.close(); Assertions.assertEquals("acd2b59cd01c7737d8069015584c6cac", DigestScheme.formatHex(digester.getDigest())); Assertions.assertThrows(IOException.class, () -> digester.write('a')); - Assertions.assertThrows(IOException.class, () -> digester.write(new byte[] { 'a', 'b', 'c'})); + Assertions.assertThrows(IOException.class, () -> digester.write(new byte[]{'a', 'b', 'c'})); } @Test @@ -658,7 +658,7 @@ void testDigestAuthenticationQopAuthIntNullEntity() throws Exception { @Test void testDigestAuthenticationQopAuthOrAuthIntNonRepeatableEntity() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest("Post", "/"); - request.setEntity(new InputStreamEntity(new ByteArrayInputStream(new byte[] {'a'}), -1, ContentType.DEFAULT_TEXT)); + request.setEntity(new InputStreamEntity(new ByteArrayInputStream(new byte[]{'a'}), -1, ContentType.DEFAULT_TEXT)); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() .add(new AuthScope(host, "realm1", null), "username", "password".toCharArray()) @@ -705,7 +705,7 @@ void testParameterCaseSensitivity() throws Exception { @Test void testDigestAuthenticationQopIntOnlyNonRepeatableEntity() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest("Post", "/"); - request.setEntity(new InputStreamEntity(new ByteArrayInputStream(new byte[] {'a'}), -1, ContentType.DEFAULT_TEXT)); + request.setEntity(new InputStreamEntity(new ByteArrayInputStream(new byte[]{'a'}), -1, ContentType.DEFAULT_TEXT)); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() .add(new AuthScope(host, "realm1", null), "username", "password".toCharArray()) @@ -768,7 +768,7 @@ void testDigestAuthenticationWithUserHash() throws Exception { // Generate expected userhash final MessageDigest md = MessageDigest.getInstance("MD5"); - md.update(("username:realm1").getBytes(StandardCharsets.UTF_8)); + md.update("username:realm1".getBytes(StandardCharsets.UTF_8)); final String expectedUserhash = bytesToHex(md.digest()); Assertions.assertEquals(expectedUserhash, table.get("username")); @@ -819,6 +819,7 @@ void testDigestAuthenticationWithQuotedStringsAndWhitespace() throws Exception { final String response = table.get("response"); Assertions.assertNotNull(response); } + @Test void testDigestAuthenticationWithInvalidUsernameAndValidUsernameStar() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestNTLMEngineImpl.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestNTLMEngineImpl.java index f5773f96f2..d40c3fc8ef 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestNTLMEngineImpl.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestNTLMEngineImpl.java @@ -252,7 +252,7 @@ void testType3Message() throws Exception { "me", "mypassword", "myhost", "mydomain".toCharArray(), toBytes("0001020304050607"), 0xffffffff, - null,null).getBytes(); + null, null).getBytes(); checkArraysMatch(toBytes("4E544C4D53535000030000001800180048000000180018006000000004000400780000000C000C007C0000001400140088000000100010009C000000FFFFFFFF0501280A0000000FA86886A5D297814200000000000000000000000000000000EEC7568E00798491244959B9C942F4F367C5CBABEEF546F74D0045006D00790068006F00730074006D007900700061007300730077006F007200640094DDAB1EBB82C9A1AB914CAE6F199644"), bytes); final byte[] bytes2 = new NTLMEngineImpl.Type3Message( @@ -268,22 +268,22 @@ void testType3Message() throws Exception { } private static final String cannedCert = - "-----BEGIN CERTIFICATE-----\n"+ - "MIIDIDCCAgigAwIBAgIEOqKaWTANBgkqhkiG9w0BAQsFADBSMQswCQYDVQQGEwJVUzEQMA4GA1UEBxMH\n"+ - "TXkgQ2l0eTEYMBYGA1UEChMPTXkgT3JnYW5pemF0aW9uMRcwFQYDVQQDEw5NeSBBcHBsaWNhdGlvbjAe\n"+ - "Fw0xNzAzMTcxNDAyMzRaFw0yNzAzMTUxNDAyMzRaMFIxCzAJBgNVBAYTAlVTMRAwDgYDVQQHEwdNeSBD\n"+ - "aXR5MRgwFgYDVQQKEw9NeSBPcmdhbml6YXRpb24xFzAVBgNVBAMTDk15IEFwcGxpY2F0aW9uMIIBIjAN\n"+ - "BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArc+mbViBaHeRSt82KrJ5IF+62b/Qob95Lca4DJIislTY\n"+ - "vLPIo0R1faBV8BkEeUQwo01srkf3RaGLCHNZnFal4KEzbtiUy6W+n08G5E9w9YG+WSwW2dmjvEI7k2a2\n"+ - "xqlaM4NdMKL4ONPXcxfZsMDqxDgpdkaNPKpZ10NDq6rmBTkQw/OSG0z1KLtwLkF1ZQ/3mXdjVzvP83V2\n"+ - "g17AqBazb0Z1YHsVKmkGjPqnq3niJH/6Oke4N+5k/1cE5lSJcQNGP0nqeGdJfvqQZ+gk6gH/sOngZL9X\n"+ - "hPVkpseAwHa+xuPneDSjibLgLmMt3XGDK6jGfjdp5FWqFvAD5E3LHbW9gwIDAQABMA0GCSqGSIb3DQEB\n"+ - "CwUAA4IBAQCpUXUHhl5LyMSO5Q0OktEc9AaFjZtVfknpPde6Zeh35Pqd2354ErvJSBWgzFAphda0oh2s\n"+ - "OIAFkM6LJQEnVDTbXDXN+YY8e3gb9ryfh85hkhC0XI9qp17WPSkmw8XgDfvRd6YQgKm1AnLxjOCwG2jg\n"+ - "i09iZBIWkW3ZeRAMvWPHHjvq44iZB5ZrEl0apgumS6MxpUzKOr5Pcq0jxJDw2UCj5YloFMNl+UINv2vV\n"+ - "aL/DR6ivc61dOfN1E/VNBGkkCk/AogNyucGiFMCq9hd25Y9EbkBBqObYTH1XMX+ufsJh+6hG7KDQ1e/F\n"+ - "nRrlhKwM2uRe+aSH0D6/erjDBT7tXvwn\n"+ - "-----END CERTIFICATE-----"; + "-----BEGIN CERTIFICATE-----\n" + + "MIIDIDCCAgigAwIBAgIEOqKaWTANBgkqhkiG9w0BAQsFADBSMQswCQYDVQQGEwJVUzEQMA4GA1UEBxMH\n" + + "TXkgQ2l0eTEYMBYGA1UEChMPTXkgT3JnYW5pemF0aW9uMRcwFQYDVQQDEw5NeSBBcHBsaWNhdGlvbjAe\n" + + "Fw0xNzAzMTcxNDAyMzRaFw0yNzAzMTUxNDAyMzRaMFIxCzAJBgNVBAYTAlVTMRAwDgYDVQQHEwdNeSBD\n" + + "aXR5MRgwFgYDVQQKEw9NeSBPcmdhbml6YXRpb24xFzAVBgNVBAMTDk15IEFwcGxpY2F0aW9uMIIBIjAN\n" + + "BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArc+mbViBaHeRSt82KrJ5IF+62b/Qob95Lca4DJIislTY\n" + + "vLPIo0R1faBV8BkEeUQwo01srkf3RaGLCHNZnFal4KEzbtiUy6W+n08G5E9w9YG+WSwW2dmjvEI7k2a2\n" + + "xqlaM4NdMKL4ONPXcxfZsMDqxDgpdkaNPKpZ10NDq6rmBTkQw/OSG0z1KLtwLkF1ZQ/3mXdjVzvP83V2\n" + + "g17AqBazb0Z1YHsVKmkGjPqnq3niJH/6Oke4N+5k/1cE5lSJcQNGP0nqeGdJfvqQZ+gk6gH/sOngZL9X\n" + + "hPVkpseAwHa+xuPneDSjibLgLmMt3XGDK6jGfjdp5FWqFvAD5E3LHbW9gwIDAQABMA0GCSqGSIb3DQEB\n" + + "CwUAA4IBAQCpUXUHhl5LyMSO5Q0OktEc9AaFjZtVfknpPde6Zeh35Pqd2354ErvJSBWgzFAphda0oh2s\n" + + "OIAFkM6LJQEnVDTbXDXN+YY8e3gb9ryfh85hkhC0XI9qp17WPSkmw8XgDfvRd6YQgKm1AnLxjOCwG2jg\n" + + "i09iZBIWkW3ZeRAMvWPHHjvq44iZB5ZrEl0apgumS6MxpUzKOr5Pcq0jxJDw2UCj5YloFMNl+UINv2vV\n" + + "aL/DR6ivc61dOfN1E/VNBGkkCk/AogNyucGiFMCq9hd25Y9EbkBBqObYTH1XMX+ufsJh+6hG7KDQ1e/F\n" + + "nRrlhKwM2uRe+aSH0D6/erjDBT7tXvwn\n" + + "-----END CERTIFICATE-----"; @Test void testType3MessageWithCert() throws Exception { @@ -318,9 +318,9 @@ void testRC4() throws Exception { /* Byte array check helper */ static void checkArraysMatch(final byte[] a1, final byte[] a2) { - Assertions.assertEquals(a1.length,a2.length); + Assertions.assertEquals(a1.length, a2.length); for (int i = 0; i < a1.length; i++) { - Assertions.assertEquals(a1[i],a2[i]); + Assertions.assertEquals(a1[i], a2[i]); } } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestDefaultBackoffStrategy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestDefaultBackoffStrategy.java index d2d6d4be1a..2fa94b298e 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestDefaultBackoffStrategy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestDefaultBackoffStrategy.java @@ -79,8 +79,8 @@ void backsOffForTooManyRequests() { @Test void doesNotBackOffForNon429And503StatusCodes() { - for(int i = 100; i <= 599; i++) { - if (i== HttpStatus.SC_TOO_MANY_REQUESTS || i == HttpStatus.SC_SERVICE_UNAVAILABLE) { + for (int i = 100; i <= 599; i++) { + if (i == HttpStatus.SC_TOO_MANY_REQUESTS || i == HttpStatus.SC_SERVICE_UNAVAILABLE) { continue; } final HttpResponse resp = new BasicHttpResponse(i, "Foo"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityProxy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityProxy.java index a37cefe4e2..a376fa3d68 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityProxy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityProxy.java @@ -77,7 +77,8 @@ void testGetTrailersWithNoChunkedInputStream() throws Exception { final HttpEntity wrappedEntity = httpEntityArgumentCaptor.getValue(); final InputStream is = wrappedEntity.getContent(); - while (is.read() != -1) {} // read until the end + while (is.read() != -1) { + } // read until the end final Supplier> trailers = wrappedEntity.getTrailers(); Assertions.assertTrue(trailers.get().isEmpty()); @@ -98,7 +99,8 @@ void testGetTrailersWithChunkedInputStream() throws Exception { final HttpEntity wrappedEntity = httpEntityArgumentCaptor.getValue(); final InputStream is = wrappedEntity.getContent(); - while (is.read() != -1) {} // consume the stream so it can reach to trailers and parse + while (is.read() != -1) { + } // consume the stream so it can reach to trailers and parse final Supplier> trailers = wrappedEntity.getTrailers(); final List headers = trailers.get(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieStore.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieStore.java index 9544a8ed83..fc75916655 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieStore.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieStore.java @@ -66,7 +66,7 @@ void testExpiredCookie() { final BasicCookieStore store = new BasicCookieStore(); final BasicClientCookie cookie = new BasicClientCookie("name1", "value1"); - final Instant minus_10_days = Instant.now().minus(10, ChronoUnit.DAYS); + final Instant minus_10_days = Instant.now().minus(10, ChronoUnit.DAYS); cookie.setExpiryDate(minus_10_days); store.addCookie(cookie); final List list = store.getCookies(); 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 4de226b67f..941a1ec395 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 @@ -43,20 +43,15 @@ class TestRouteDirector { // a selection of constants for generating routes - public final static - HttpHost TARGET1 = new HttpHost("target1.test.invalid", 80); - public final static - HttpHost TARGET2 = new HttpHost("target2.test.invalid", 8080); + public final static HttpHost TARGET1 = new HttpHost("target1.test.invalid", 80); + public final static HttpHost TARGET2 = new HttpHost("target2.test.invalid", 8080); // It is not necessary to have extra targets for https. // The 'layered' and 'secure' flags are specified explicitly // for routes, they will not be determined from the scheme. - public final static - HttpHost PROXY1 = new HttpHost("proxy1.test.invalid", 80); - public final static - HttpHost PROXY2 = new HttpHost("proxy2.test.invalid", 1080); - public final static - HttpHost PROXY3 = new HttpHost("proxy3.test.invalid", 88); + public final static HttpHost PROXY1 = new HttpHost("proxy1.test.invalid", 80); + public final static HttpHost PROXY2 = new HttpHost("proxy2.test.invalid", 1080); + public final static HttpHost PROXY3 = new HttpHost("proxy3.test.invalid", 88); public final static InetAddress LOCAL41; public final static InetAddress LOCAL42; @@ -66,14 +61,14 @@ class TestRouteDirector { // need static initializer to deal with exceptions static { try { - LOCAL41 = InetAddress.getByAddress(new byte[]{ 127, 0, 0, 1 }); - LOCAL42 = InetAddress.getByAddress(new byte[]{ 127, 0, 0, 2 }); + LOCAL41 = InetAddress.getByAddress(new byte[]{127, 0, 0, 1}); + LOCAL42 = InetAddress.getByAddress(new byte[]{127, 0, 0, 2}); LOCAL61 = InetAddress.getByAddress(new byte[]{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }); LOCAL62 = InetAddress.getByAddress(new byte[]{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }); } catch (final Exception x) { @@ -93,8 +88,8 @@ void testIllegal() { void testDirect() { final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE; - final HttpRoute route1 = new HttpRoute(TARGET1); - final HttpRoute route2 = new HttpRoute(TARGET2); + final HttpRoute route1 = new HttpRoute(TARGET1); + final HttpRoute route2 = new HttpRoute(TARGET2); final HttpRoute route1p1 = new HttpRoute(TARGET1, null, PROXY1, false); int step = rowdy.nextStep(route1, null); @@ -123,8 +118,8 @@ void testProxy() { final HttpRoute route1p1 = new HttpRoute(TARGET1, null, PROXY1, false); final HttpRoute route1p2 = new HttpRoute(TARGET1, null, PROXY2, false); final HttpRoute route2p1 = new HttpRoute(TARGET2, null, PROXY1, false); - final HttpRoute route0 = new HttpRoute(PROXY1); - final HttpRoute route1 = new HttpRoute(TARGET1); + final HttpRoute route0 = new HttpRoute(PROXY1); + final HttpRoute route1 = new HttpRoute(TARGET1); int step = rowdy.nextStep(route1p1, null); Assertions.assertEquals(HttpRouteDirector.CONNECT_PROXY, step, "wrong step to route1p1"); @@ -156,19 +151,19 @@ void testProxy() { @Test void testProxyChain() { - final HttpHost[] chainA = { PROXY1 }; - final HttpHost[] chainB = { PROXY1, PROXY2 }; - final HttpHost[] chainC = { PROXY2, PROXY1 }; + final HttpHost[] chainA = {PROXY1}; + final HttpHost[] chainB = {PROXY1, PROXY2}; + final HttpHost[] chainC = {PROXY2, PROXY1}; final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE; - final HttpRoute route1cA = new HttpRoute(TARGET1, null, chainA, false, - TunnelType.PLAIN, LayerType.PLAIN); - final HttpRoute route1cB = new HttpRoute(TARGET1, null, chainB, false, - TunnelType.PLAIN, LayerType.PLAIN); - final HttpRoute route1cC = new HttpRoute(TARGET1, null, chainC, false, - TunnelType.PLAIN, LayerType.PLAIN); - final HttpRoute route1cD = new HttpRoute(TARGET1, null, chainC, false, - TunnelType.PLAIN, LayerType.PLAIN); + final HttpRoute route1cA = new HttpRoute(TARGET1, null, chainA, false, + TunnelType.PLAIN, LayerType.PLAIN); + final HttpRoute route1cB = new HttpRoute(TARGET1, null, chainB, false, + TunnelType.PLAIN, LayerType.PLAIN); + final HttpRoute route1cC = new HttpRoute(TARGET1, null, chainC, false, + TunnelType.PLAIN, LayerType.PLAIN); + final HttpRoute route1cD = new HttpRoute(TARGET1, null, chainC, false, + TunnelType.PLAIN, LayerType.PLAIN); int step = rowdy.nextStep(route1cA, null); Assertions.assertEquals(HttpRouteDirector.CONNECT_PROXY, step, "wrong step to route1cA"); @@ -258,8 +253,8 @@ void testLocalDirect() { void testDirectSecure() { final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE; - final HttpRoute route1u = new HttpRoute(TARGET1, null, false); - final HttpRoute route1s = new HttpRoute(TARGET1, null, true); + final HttpRoute route1u = new HttpRoute(TARGET1, null, false); + final HttpRoute route1s = new HttpRoute(TARGET1, null, true); final HttpRoute route1p1u = new HttpRoute(TARGET1, null, PROXY1, false); final HttpRoute route1p1s = new HttpRoute(TARGET1, null, PROXY1, true); @@ -278,7 +273,6 @@ void testDirectSecure() { Assertions.assertEquals(HttpRouteDirector.UNREACHABLE, step, "unreachable route 1s from 1u not detected"); - step = rowdy.nextStep(route1s, route1p1u); Assertions.assertEquals(HttpRouteDirector.UNREACHABLE, step, "unreachable route 1s from 1p1u not detected"); @@ -290,24 +284,24 @@ void testDirectSecure() { void testProxyTLS() { final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE; - final HttpRoute route1 = new HttpRoute - (TARGET1, null, PROXY1, false, - TunnelType.PLAIN, LayerType.PLAIN); - final HttpRoute route1t = new HttpRoute - (TARGET1, null, PROXY1, false, - TunnelType.TUNNELLED, LayerType.PLAIN); - final HttpRoute route1tl = new HttpRoute - (TARGET1, null, PROXY1, false, - TunnelType.TUNNELLED, LayerType.LAYERED); - final HttpRoute route1s = new HttpRoute - (TARGET1, null, PROXY1, true, - TunnelType.PLAIN, LayerType.PLAIN); - final HttpRoute route1ts = new HttpRoute - (TARGET1, null, PROXY1, true, - TunnelType.TUNNELLED, LayerType.PLAIN); + final HttpRoute route1 = new HttpRoute + (TARGET1, null, PROXY1, false, + TunnelType.PLAIN, LayerType.PLAIN); + final HttpRoute route1t = new HttpRoute + (TARGET1, null, PROXY1, false, + TunnelType.TUNNELLED, LayerType.PLAIN); + final HttpRoute route1tl = new HttpRoute + (TARGET1, null, PROXY1, false, + TunnelType.TUNNELLED, LayerType.LAYERED); + final HttpRoute route1s = new HttpRoute + (TARGET1, null, PROXY1, true, + TunnelType.PLAIN, LayerType.PLAIN); + final HttpRoute route1ts = new HttpRoute + (TARGET1, null, PROXY1, true, + TunnelType.TUNNELLED, LayerType.PLAIN); final HttpRoute route1tls = new HttpRoute - (TARGET1, null, PROXY1, true, - TunnelType.TUNNELLED, LayerType.LAYERED); + (TARGET1, null, PROXY1, true, + TunnelType.TUNNELLED, LayerType.LAYERED); // we don't consider a route that is layered but not tunnelled @@ -349,7 +343,6 @@ void testProxyTLS() { Assertions.assertEquals(HttpRouteDirector.COMPLETE, step, "complete route1tls not detected"); - step = rowdy.nextStep(route1, route1t); Assertions.assertEquals(HttpRouteDirector.UNREACHABLE, step, "unreachable route1 from 1t not detected"); 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 f738122868..093da5c912 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 @@ -47,20 +47,15 @@ class TestRouteTracker { // a selection of constants for generating routes - public final static - HttpHost TARGET1 = new HttpHost("target1.test.invalid", 80); - public final static - HttpHost TARGET2 = new HttpHost("target2.test.invalid", 8080); + public final static HttpHost TARGET1 = new HttpHost("target1.test.invalid", 80); + public final static HttpHost TARGET2 = new HttpHost("target2.test.invalid", 8080); // It is not necessary to have extra targets for https. // The 'layered' and 'secure' flags are specified explicitly // for routes, they will not be determined from the scheme. - public final static - HttpHost PROXY1 = new HttpHost("proxy1.test.invalid", 80); - public final static - HttpHost PROXY2 = new HttpHost("proxy2.test.invalid", 1080); - public final static - HttpHost PROXY3 = new HttpHost("proxy3.test.invalid", 88); + public final static HttpHost PROXY1 = new HttpHost("proxy1.test.invalid", 80); + public final static HttpHost PROXY2 = new HttpHost("proxy2.test.invalid", 1080); + public final static HttpHost PROXY3 = new HttpHost("proxy3.test.invalid", 88); public final static InetAddress LOCAL41; public final static InetAddress LOCAL42; @@ -70,14 +65,14 @@ class TestRouteTracker { // need static initializer to deal with exceptions static { try { - LOCAL41 = InetAddress.getByAddress(new byte[]{ 127, 0, 0, 1 }); - LOCAL42 = InetAddress.getByAddress(new byte[]{ 127, 0, 0, 2 }); + LOCAL41 = InetAddress.getByAddress(new byte[]{127, 0, 0, 1}); + LOCAL42 = InetAddress.getByAddress(new byte[]{127, 0, 0, 2}); LOCAL61 = InetAddress.getByAddress(new byte[]{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }); LOCAL62 = InetAddress.getByAddress(new byte[]{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }); } catch (final Exception x) { @@ -113,7 +108,7 @@ void testCstrTargetLocal() { @Test void testCstrRoute() { - HttpRoute r = new HttpRoute(TARGET1); + HttpRoute r = new HttpRoute(TARGET1); RouteTracker rt = new RouteTracker(r); Assertions.assertEquals(TARGET1, rt.getTargetHost(), "wrong target (r1)"); Assertions.assertNull(rt.getLocalAddress(), "wrong local address (r1)"); @@ -122,7 +117,7 @@ void testCstrRoute() { Assertions.assertNull(rt.toRoute(), "wrong route (r1)"); checkCTLS(rt, false, false, false, false); - r = new HttpRoute(TARGET2, LOCAL61, true); + r = new HttpRoute(TARGET2, LOCAL61, true); rt = new RouteTracker(r); Assertions.assertEquals(TARGET2, rt.getTargetHost(), "wrong target (r2)"); Assertions.assertEquals(LOCAL61, rt.getLocalAddress(), "wrong local address (r2)"); @@ -132,7 +127,7 @@ void testCstrRoute() { checkCTLS(rt, false, false, false, false); - r = new HttpRoute(TARGET1, LOCAL42, PROXY3, true); + r = new HttpRoute(TARGET1, LOCAL42, PROXY3, true); rt = new RouteTracker(r); Assertions.assertEquals(TARGET1, rt.getTargetHost(), "wrong target (r3)"); Assertions.assertEquals(LOCAL42, rt.getLocalAddress(), "wrong local address (r3)"); @@ -204,14 +199,14 @@ void testProxyRoutes() { // tunnelled, but neither secure nor layered r = new HttpRoute(TARGET1, LOCAL61, PROXY3, false, - TunnelType.TUNNELLED, LayerType.PLAIN); + TunnelType.TUNNELLED, LayerType.PLAIN); rt = new RouteTracker(r); complete = checkVia(rt, r, rd, 3); Assertions.assertTrue(complete, "incomplete route 2"); // tunnelled, layered, but not secure r = new HttpRoute(TARGET1, LOCAL61, PROXY3, false, - TunnelType.TUNNELLED, LayerType.LAYERED); + TunnelType.TUNNELLED, LayerType.LAYERED); rt = new RouteTracker(r); complete = checkVia(rt, r, rd, 4); Assertions.assertTrue(complete, "incomplete route 3"); @@ -229,31 +224,31 @@ void testProxyChainRoutes() { final HttpRouteDirector rd = BasicRouteDirector.INSTANCE; HttpHost[] proxies = { PROXY1, PROXY2 }; HttpRoute r = new HttpRoute(TARGET2, LOCAL42, proxies, false, - TunnelType.PLAIN, LayerType.PLAIN); + TunnelType.PLAIN, LayerType.PLAIN); RouteTracker rt = new RouteTracker(r); boolean complete = checkVia(rt, r, rd, 3); Assertions.assertTrue(complete, "incomplete route 1"); // tunnelled, but neither secure nor layered - proxies = new HttpHost[]{ PROXY3, PROXY2 }; + proxies = new HttpHost[]{PROXY3, PROXY2}; r = new HttpRoute(TARGET1, null, proxies, false, - TunnelType.TUNNELLED, LayerType.PLAIN); + TunnelType.TUNNELLED, LayerType.PLAIN); rt = new RouteTracker(r); complete = checkVia(rt, r, rd, 4); Assertions.assertTrue(complete, "incomplete route 2"); // tunnelled, layered, but not secure - proxies = new HttpHost[]{ PROXY3, PROXY2, PROXY1 }; + proxies = new HttpHost[]{PROXY3, PROXY2, PROXY1}; r = new HttpRoute(TARGET2, LOCAL61, proxies, false, - TunnelType.TUNNELLED, LayerType.LAYERED); + TunnelType.TUNNELLED, LayerType.LAYERED); rt = new RouteTracker(r); complete = checkVia(rt, r, rd, 6); Assertions.assertTrue(complete, "incomplete route 3"); // tunnelled, layered, secure - proxies = new HttpHost[]{ PROXY1, PROXY3 }; + proxies = new HttpHost[]{PROXY1, PROXY3}; r = new HttpRoute(TARGET1, LOCAL61, proxies, true, - TunnelType.TUNNELLED, LayerType.LAYERED); + TunnelType.TUNNELLED, LayerType.LAYERED); rt = new RouteTracker(r); complete = checkVia(rt, r, rd, 5); Assertions.assertTrue(complete, "incomplete route 4"); @@ -261,7 +256,7 @@ void testProxyChainRoutes() { @Test void testEqualsHashcodeCloneToString() - throws CloneNotSupportedException { + throws CloneNotSupportedException { final RouteTracker rt0 = new RouteTracker(TARGET1, null); final RouteTracker rt1 = new RouteTracker(TARGET2, null); @@ -438,7 +433,7 @@ void testEqualsHashcodeCloneToString() // check that all toString are OK and different final Set rtstrings = new HashSet<>(); - for (final RouteTracker current: hs) { + for (final RouteTracker current : hs) { final String rts = checkToString(current); Assertions.assertTrue(rtstrings.add(rts), "duplicate toString: " + rts); } @@ -453,10 +448,10 @@ public final static void checkCTLS(final RouteTracker rt, Assertions.assertEquals(c, rt.isConnected(), "wrong flag connected: " + rts); Assertions.assertEquals(t, rt.isTunnelled(), "wrong flag tunnelled: " + rts); Assertions.assertEquals(t ? TunnelType.TUNNELLED : TunnelType.PLAIN, - rt.getTunnelType(), "wrong enum tunnelled: " + rts); - Assertions.assertEquals(l, rt.isLayered(), "wrong flag layered: " + rts); + rt.getTunnelType(), "wrong enum tunnelled: " + rts); + Assertions.assertEquals(l, rt.isLayered(), "wrong flag layered: " + rts); Assertions.assertEquals(l ? LayerType.LAYERED : LayerType.PLAIN, - rt.getLayerType(), "wrong enum layered: " + rts); + rt.getLayerType(), "wrong enum layered: " + rts); Assertions.assertEquals(s, rt.isSecure(), "wrong flag secure: " + rts); } @@ -480,77 +475,82 @@ public final static boolean checkVia(final RouteTracker rt, final HttpRoute r, boolean complete = false; int n = steps; - while (!complete && (n > 0)) { + while (!complete && n > 0) { final int action = rd.nextStep(r, rt.toRoute()); switch (action) { - case HttpRouteDirector.COMPLETE: - complete = true; - Assertions.assertEquals(r, rt.toRoute()); + case HttpRouteDirector.COMPLETE: + complete = true; + Assertions.assertEquals(r, rt.toRoute()); + break; + + case HttpRouteDirector.CONNECT_TARGET: { + final boolean sec = r.isSecure(); + rt.connectTarget(sec); + checkCTLS(rt, true, false, false, sec); + Assertions.assertEquals(1, rt.getHopCount(), "wrong hop count " + msg); + Assertions.assertEquals(r.getTargetHost(), rt.getHopTarget(0), "wrong hop0 " + msg); + } break; - case HttpRouteDirector.CONNECT_TARGET: { - final boolean sec = r.isSecure(); - rt.connectTarget(sec); - checkCTLS(rt, true, false, false, sec); - Assertions.assertEquals(1, rt.getHopCount(), "wrong hop count "+msg); - Assertions.assertEquals(r.getTargetHost(), rt.getHopTarget(0), "wrong hop0 "+msg); - } break; - - case HttpRouteDirector.CONNECT_PROXY: { - // we assume an insecure proxy connection - final boolean sec = false; - rt.connectProxy(r.getProxyHost(), sec); - checkCTLS(rt, true, false, false, sec); - Assertions.assertEquals(2, rt.getHopCount(), "wrong hop count "+msg); - Assertions.assertEquals(r.getProxyHost(), rt.getHopTarget(0), "wrong hop0 "+msg); - Assertions.assertEquals(r.getTargetHost(), rt.getHopTarget(1), "wrong hop1 "+msg); - } break; - - case HttpRouteDirector.TUNNEL_TARGET: { - final int hops = rt.getHopCount(); - // we assume an insecure tunnel - final boolean sec = false; - rt.tunnelTarget(sec); - checkCTLS(rt, true, true, false, sec); - Assertions.assertEquals(hops, rt.getHopCount(), "wrong hop count "+msg); - Assertions.assertEquals(r.getProxyHost(), rt.getHopTarget(0), "wrong hop0 "+msg); - Assertions.assertEquals(r.getTargetHost(), rt.getHopTarget(hops-1), "wrong hopN "+msg); - } break; - - case HttpRouteDirector.TUNNEL_PROXY: { - final int hops = rt.getHopCount(); // before tunnelling - // we assume an insecure tunnel - final boolean sec = false; - final HttpHost pxy = r.getHopTarget(hops-1); - rt.tunnelProxy(pxy, sec); - // Since we're tunnelling to a proxy and not the target, - // the 'tunelling' flag is false: no end-to-end tunnel. - checkCTLS(rt, true, false, false, sec); - Assertions.assertEquals(hops+1, rt.getHopCount(), "wrong hop count "+msg); - Assertions.assertEquals(r.getProxyHost(), rt.getHopTarget(0), "wrong hop0 "+msg); - Assertions.assertEquals(pxy, rt.getHopTarget(hops-1), "wrong hop"+hops+" "+msg); - Assertions.assertEquals(r.getTargetHost(), rt.getHopTarget(hops), "wrong hopN "+msg); - } break; - - case HttpRouteDirector.LAYER_PROTOCOL: { - final int hops = rt.getHopCount(); - final boolean tun = rt.isTunnelled(); - final boolean sec = r.isSecure(); - rt.layerProtocol(sec); - checkCTLS(rt, true, tun, true, sec); - Assertions.assertEquals(hops, rt.getHopCount(), "wrong hop count "+msg); - Assertions.assertEquals(r.getProxyHost(), rt.getProxyHost(), "wrong proxy "+msg); - Assertions.assertEquals(r.getTargetHost(), rt.getTargetHost(), "wrong target "+msg); - } break; - - - // UNREACHABLE - default: - Assertions.fail("unexpected action " + action + " from director, "+msg); + case HttpRouteDirector.CONNECT_PROXY: { + // we assume an insecure proxy connection + final boolean sec = false; + rt.connectProxy(r.getProxyHost(), sec); + checkCTLS(rt, true, false, false, sec); + Assertions.assertEquals(2, rt.getHopCount(), "wrong hop count " + msg); + Assertions.assertEquals(r.getProxyHost(), rt.getHopTarget(0), "wrong hop0 " + msg); + Assertions.assertEquals(r.getTargetHost(), rt.getHopTarget(1), "wrong hop1 " + msg); + } break; + case HttpRouteDirector.TUNNEL_TARGET: { + final int hops = rt.getHopCount(); + // we assume an insecure tunnel + final boolean sec = false; + rt.tunnelTarget(sec); + checkCTLS(rt, true, true, false, sec); + Assertions.assertEquals(hops, rt.getHopCount(), "wrong hop count " + msg); + Assertions.assertEquals(r.getProxyHost(), rt.getHopTarget(0), "wrong hop0 " + msg); + Assertions.assertEquals(r.getTargetHost(), rt.getHopTarget(hops - 1), "wrong hopN " + msg); + } + break; + + case HttpRouteDirector.TUNNEL_PROXY: { + final int hops = rt.getHopCount(); // before tunnelling + // we assume an insecure tunnel + final boolean sec = false; + final HttpHost pxy = r.getHopTarget(hops - 1); + rt.tunnelProxy(pxy, sec); + // Since we're tunnelling to a proxy and not the target, + // the 'tunelling' flag is false: no end-to-end tunnel. + checkCTLS(rt, true, false, false, sec); + Assertions.assertEquals(hops + 1, rt.getHopCount(), "wrong hop count " + msg); + Assertions.assertEquals(r.getProxyHost(), rt.getHopTarget(0), "wrong hop0 " + msg); + Assertions.assertEquals(pxy, rt.getHopTarget(hops - 1), "wrong hop" + hops + " " + msg); + Assertions.assertEquals(r.getTargetHost(), rt.getHopTarget(hops), "wrong hopN " + msg); + } + break; + + case HttpRouteDirector.LAYER_PROTOCOL: { + final int hops = rt.getHopCount(); + final boolean tun = rt.isTunnelled(); + final boolean sec = r.isSecure(); + rt.layerProtocol(sec); + checkCTLS(rt, true, tun, true, sec); + Assertions.assertEquals(hops, rt.getHopCount(), "wrong hop count " + msg); + Assertions.assertEquals(r.getProxyHost(), rt.getProxyHost(), "wrong proxy " + msg); + Assertions.assertEquals(r.getTargetHost(), rt.getTargetHost(), "wrong target " + msg); + } + break; + + + // UNREACHABLE + default: + Assertions.fail("unexpected action " + action + " from director, " + msg); + break; + } // switch n--; } @@ -578,7 +578,7 @@ public final static String checkToString(final RouteTracker rt) { Assertions.assertTrue(rts.contains(las), "no local address in toString(): " + rts); } - for (int i=0; icreate() .register(StandardCookieSpec.RELAXED, new RFC6265CookieSpecFactory( RFC6265CookieSpecFactory.CompatibilityLevel.RELAXED, null)) - .register(StandardCookieSpec.STRICT, new RFC6265CookieSpecFactory( + .register(StandardCookieSpec.STRICT, new RFC6265CookieSpecFactory( RFC6265CookieSpecFactory.CompatibilityLevel.STRICT, null)) .register(StandardCookieSpec.IGNORE, new IgnoreCookieSpecFactory()) .build(); @@ -389,9 +389,9 @@ void testCookieOrder() throws Exception { this.cookieStore.clear(); cookieStore.addCookie(makeCookie("nomatch", "value", "localhost.local", "/noway")); - cookieStore.addCookie(makeCookie("name2", "value", "localhost.local", "/foobar/yada")); - cookieStore.addCookie(makeCookie("name3", "value", "localhost.local", "/foobar")); - cookieStore.addCookie(makeCookie("name1", "value", "localhost.local", "/foobar/yada/yada")); + cookieStore.addCookie(makeCookie("name2", "value", "localhost.local", "/foobar/yada")); + cookieStore.addCookie(makeCookie("name3", "value", "localhost.local", "/foobar")); + cookieStore.addCookie(makeCookie("name1", "value", "localhost.local", "/foobar/yada/yada")); final HttpRoute route = new HttpRoute(this.target, null, false); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcherLoader.java b/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcherLoader.java index 29a19fa3a3..566f6e6ea7 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcherLoader.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcherLoader.java @@ -34,10 +34,11 @@ /** * Tests {@link PublicSuffixMatcherLoader}. */ -public class TestPublicSuffixMatcherLoader { +class TestPublicSuffixMatcherLoader { @Test - public void testGetDefault() { + void testGetDefault() { assertNotNull(PublicSuffixMatcherLoader.getDefault()); } + } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategyTest.java b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategyTest.java index b121feaa7f..20a2bbd407 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategyTest.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/AbstractClientTlsStrategyTest.java @@ -43,10 +43,10 @@ import org.apache.hc.core5.ssl.SSLContexts; import org.junit.jupiter.api.Test; -public class AbstractClientTlsStrategyTest { +class AbstractClientTlsStrategyTest { @Test - public void testToEscapedString_withControlCharacters() { + void testToEscapedString_withControlCharacters() { // Create a X500Principal with control characters final X500Principal principal = new X500Principal("CN=Test\b\bName\n,O=TestOrg"); @@ -75,7 +75,7 @@ TlsDetails createTlsDetails(final SSLEngine sslEngine) { } @Test - public void testVerifySession_escapedPeerAndIssuer() throws Exception { + void testVerifySession_escapedPeerAndIssuer() throws Exception { // Mock SSLSession and X509Certificate final SSLSession mockSession = mock(SSLSession.class); final X509Certificate mockCert = mock(X509Certificate.class); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDefaultHostnameVerifier.java b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDefaultHostnameVerifier.java index b68a233b6a..51501e4eaf 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDefaultHostnameVerifier.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDefaultHostnameVerifier.java @@ -300,24 +300,24 @@ void testHTTPCLIENT_1997_ANY() { // Only True on all domains String domain; // Unknown domain = "dev.b.cloud.a"; - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher)); // ICANN domain = "dev.b.cloud.com"; - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher)); // PRIVATE domain = "dev.b.cloud.lan"; - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher)); } @Test @@ -325,18 +325,18 @@ void testHTTPCLIENT_1997_ICANN() { // Only True on ICANN domains String domain; // Unknown domain = "dev.b.cloud.a"; - Assertions.assertFalse(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.ICANN)); - Assertions.assertFalse(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.ICANN)); + Assertions.assertFalse(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.ICANN)); + Assertions.assertFalse(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.ICANN)); // ICANN domain = "dev.b.cloud.com"; - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.ICANN)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.ICANN)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.ICANN)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.ICANN)); // PRIVATE domain = "dev.b.cloud.lan"; - Assertions.assertFalse(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.ICANN)); - Assertions.assertFalse(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.ICANN)); + Assertions.assertFalse(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.ICANN)); + Assertions.assertFalse(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.ICANN)); } @Test @@ -344,18 +344,18 @@ void testHTTPCLIENT_1997_PRIVATE() { // Only True on PRIVATE domains String domain; // Unknown domain = "dev.b.cloud.a"; - Assertions.assertFalse(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.PRIVATE)); - Assertions.assertFalse(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.PRIVATE)); + Assertions.assertFalse(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.PRIVATE)); + Assertions.assertFalse(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.PRIVATE)); // ICANN domain = "dev.b.cloud.com"; - Assertions.assertFalse(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.PRIVATE)); - Assertions.assertFalse(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.PRIVATE)); + Assertions.assertFalse(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.PRIVATE)); + Assertions.assertFalse(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.PRIVATE)); // PRIVATE domain = "dev.b.cloud.lan"; - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.PRIVATE)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.PRIVATE)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.PRIVATE)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.PRIVATE)); } @Test @@ -363,22 +363,23 @@ void testHTTPCLIENT_1997_UNKNOWN() { // Only True on all domains (same as ANY) String domain; // Unknown domain = "dev.b.cloud.a"; - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.UNKNOWN)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.UNKNOWN)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.UNKNOWN)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.UNKNOWN)); // ICANN domain = "dev.b.cloud.com"; - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.UNKNOWN)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.UNKNOWN)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.UNKNOWN)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.UNKNOWN)); // PRIVATE domain = "dev.b.cloud.lan"; - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.UNKNOWN)); - Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict( "service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.UNKNOWN)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.UNKNOWN)); + Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("service.apps." + domain, "*.apps." + domain, publicSuffixMatcher, DomainType.UNKNOWN)); } - @Test // Check compressed IPv6 hostname matching - void testHTTPCLIENT_1316() throws Exception{ + // Check compressed IPv6 hostname matching + @Test + void testHTTPCLIENT_1316() throws Exception { final String host1 = "2001:0db8:aaaa:bbbb:cccc:0:0:0001"; DefaultHostnameVerifier.matchIPv6Address(host1, Collections.singletonList(SubjectName.IP("2001:0db8:aaaa:bbbb:cccc:0:0:0001"))); DefaultHostnameVerifier.matchIPv6Address(host1, Collections.singletonList(SubjectName.IP("2001:0db8:aaaa:bbbb:cccc::1"))); @@ -460,10 +461,10 @@ void testMatchDNSName() throws Exception { Collections.singletonList(SubjectName.DNS("*.ec2.compute-1.amazonaws.com")), publicSuffixMatcher); Assertions.assertThrows(SSLException.class, () -> - DefaultHostnameVerifier.matchDNSName( - "ec2.compute-1.amazonaws.com", - Collections.singletonList(SubjectName.DNS("ec2.compute-1.amazonaws.com")), - publicSuffixMatcher)); + DefaultHostnameVerifier.matchDNSName( + "ec2.compute-1.amazonaws.com", + Collections.singletonList(SubjectName.DNS("ec2.compute-1.amazonaws.com")), + publicSuffixMatcher)); Assertions.assertThrows(SSLException.class, () -> DefaultHostnameVerifier.matchDNSName( "ec2.compute-1.amazonaws.com", diff --git a/pom.xml b/pom.xml index acbf6b935f..02593269e6 100644 --- a/pom.xml +++ b/pom.xml @@ -219,6 +219,14 @@ org.apache.maven.plugins maven-checkstyle-plugin + 3.3.1 + + + org.apache.httpcomponents + hc-stylecheck + 3 + + validate-main