Upgraded HC StyleCheck to version 3; fixed style-check violations (no functional changes)

This commit is contained in:
Oleg Kalnichevski 2024-09-26 16:32:16 +02:00
parent db623f8854
commit 9941fde19e
125 changed files with 616 additions and 609 deletions

View File

@ -109,7 +109,7 @@ public class CacheContextBuilder extends AbstractClientContextBuilder<HttpCacheC
@Override
public HttpCacheContext build() {
final HttpCacheContext context = super.build();
final HttpCacheContext context = super.build();
context.setRequestCacheControl(cacheControl);
return context;
}

View File

@ -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}
*/

View File

@ -721,7 +721,7 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
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()) {

View File

@ -227,7 +227,7 @@ public class CacheConfig implements Cloneable {
/**
* Returns the number of times to retry a cache processChallenge on failure
*/
public int getMaxUpdateRetries(){
public int getMaxUpdateRetries() {
return maxUpdateRetries;
}

View File

@ -198,7 +198,7 @@ class CachedResponseSuitabilityChecker {
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 @@ class CachedResponseSuitabilityChecker {
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 @@ class CachedResponseSuitabilityChecker {
}
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) {

View File

@ -218,7 +218,7 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
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 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
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 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
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 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
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 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
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 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
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 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
}
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 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
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();

View File

@ -240,7 +240,8 @@ public class ManagedHttpCacheStorage implements HttpCacheStorage, Closeable {
return active.get();
}
private boolean compareAndSet(){
private boolean compareAndSet() {
return this.active.compareAndSet(true, false);
}
}

View File

@ -235,7 +235,7 @@ class ResponseCachingPolicy {
// 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 @@ class ResponseCachingPolicy {
* @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;
}
/**

View File

@ -176,7 +176,7 @@ class TestHttpCacheEntry {
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<headers.length; i++) {
for (int i = 0; i < headers.length; i++) {
assertEquals(headers[i], result[i]);
}
}

View File

@ -80,7 +80,7 @@ public class HttpTestUtils {
return false;
}
}
return (-1 == i2.read());
return -1 == i2.read();
}
/*

View File

@ -73,7 +73,7 @@ class TestAbstractSerializingAsyncCacheStorage {
@BeforeEach
@SuppressWarnings("unchecked")
public void setUp() {
void setUp() {
MockitoAnnotations.openMocks(this);
impl = Mockito.mock(AbstractBinaryAsyncCacheStorage.class,
Mockito.withSettings().defaultAnswer(Answers.CALLS_REAL_METHODS).useConstructor(3));

View File

@ -61,7 +61,7 @@ class TestAbstractSerializingCacheStorage {
@BeforeEach
@SuppressWarnings("unchecked")
public void setUp() {
void setUp() {
impl = Mockito.mock(AbstractBinaryCacheStorage.class,
Mockito.withSettings().defaultAnswer(Answers.CALLS_REAL_METHODS).useConstructor(3));
}
@ -125,7 +125,7 @@ class TestAbstractSerializingCacheStorage {
}
@Test
void testCacheRemove() throws Exception{
void testCacheRemove() throws Exception {
final String key = "foo";
when(impl.digestToStorageKey(key)).thenReturn("bar");

View File

@ -80,7 +80,7 @@ class TestCacheValidityPolicy {
@Test
void testNegativeApparentAgeIsBroughtUpToZero() {
final Header[] headers = new Header[] { new BasicHeader("Date", DateUtils.formatStandardDate(sixSecondsAgo)) };
final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, tenSecondsAgo, headers);
final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, tenSecondsAgo, headers);
assertEquals(TimeValue.ofSeconds(0), impl.getApparentAge(entry));
}

View File

@ -399,36 +399,36 @@ class TestHttpByteArrayCacheEntrySerializer {
*/
@Test
void testDeserializeCacheEntryWithTrailingGarbage() {
final String content1 =HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" +
final String content1 = HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" +
"HC-Key: unique-cache-key\n" +
"HC-Resource-Length: 11\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" +
"Hello World..... Rubbish";
"HC-Resource-Length: 11\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" +
"Hello World..... Rubbish";
final byte[] bytes1 = content1.getBytes(StandardCharsets.UTF_8);
final ResourceIOException exception1 = Assertions.assertThrows(ResourceIOException.class, () ->
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));

View File

@ -268,7 +268,7 @@ class TestProtocolRecommendations {
ClassicHttpResponse result = null;
try {
result = execute(req2);
} catch (final IOException acceptable) {
} catch (final IOException expected) {
}
if (result != null) {
@ -745,8 +745,8 @@ class TestProtocolRecommendations {
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;
}

View File

@ -1212,7 +1212,7 @@ class TestProtocolRequirements {
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 @@ class TestProtocolRequirements {
"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 @@ class TestProtocolRequirements {
"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 @@ class TestProtocolRequirements {
final Iterator<HeaderElement> 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 @@ class TestProtocolRequirements {
final Iterator<HeaderElement> 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;

View File

@ -126,8 +126,7 @@ class TestRFC5861Compliance {
}
@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 @@ class TestRFC5861Compliance {
}
@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 @@ class TestRFC5861Compliance {
}
@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 @@ class TestRFC5861Compliance {
}
@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 @@ class TestRFC5861Compliance {
}
@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 @@ class TestRFC5861Compliance {
}
@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();

View File

@ -364,7 +364,7 @@ public class Request {
return this;
}
public Request bodyForm(final Iterable <? extends NameValuePair> formParams, final Charset charset) {
public Request bodyForm(final Iterable<? extends NameValuePair> formParams, final Charset charset) {
final List<NameValuePair> paramList = new ArrayList<>();
for (final NameValuePair param : formParams) {
paramList.add(param);
@ -375,7 +375,7 @@ public class Request {
return bodyString(s, contentType);
}
public Request bodyForm(final Iterable <? extends NameValuePair> formParams) {
public Request bodyForm(final Iterable<? extends NameValuePair> formParams) {
return bodyForm(formParams, StandardCharsets.ISO_8859_1);
}

View File

@ -80,11 +80,11 @@ public class FluentAsync {
queue.add(future);
}
while(!queue.isEmpty()) {
while (!queue.isEmpty()) {
final Future<Content> future = queue.remove();
try {
future.get();
} catch (final ExecutionException ex) {
} catch (final ExecutionException ignore) {
}
}
System.out.println("Done");

View File

@ -209,7 +209,7 @@ public class AsyncRandomHandler implements AsyncServerExchangeHandler {
}
@Override
public void failed(final Exception cause) {
public void failed(final Exception cause) {
}
}

View File

@ -48,7 +48,7 @@ import org.apache.hc.core5.http.protocol.HttpContext;
/**
* 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 class RandomHandler implements HttpRequestHandler {
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 class RandomHandler implements HttpRequestHandler {
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;

View File

@ -61,7 +61,7 @@ public class BasicTestAuthenticator implements Authenticator {
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));
}

View File

@ -76,7 +76,7 @@ import org.junit.jupiter.api.Assertions;
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 @@ abstract class AbstractHttpAsyncClientAuthenticationTest extends AbstractIntegr
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();

View File

@ -58,7 +58,7 @@ import org.apache.hc.core5.http.nio.support.BasicResponseConsumer;
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);

View File

@ -66,7 +66,7 @@ import org.hamcrest.CoreMatchers;
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);

View File

@ -77,7 +77,7 @@ import org.junit.jupiter.api.Test;
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 @@ abstract class AbstractHttpReactiveFundamentalsTest extends AbstractIntegration
@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 @@ abstract class AbstractHttpReactiveFundamentalsTest extends AbstractIntegration
@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 @@ abstract class AbstractHttpReactiveFundamentalsTest extends AbstractIntegration
@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 @@ abstract class AbstractHttpReactiveFundamentalsTest extends AbstractIntegration
@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 @@ abstract class AbstractHttpReactiveFundamentalsTest extends AbstractIntegration
@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();

View File

@ -42,7 +42,7 @@ import org.apache.hc.core5.http.URIScheme;
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);

View File

@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ClientProtocolLevel;
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);

View File

@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ClientProtocolLevel;
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);

View File

@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ClientProtocolLevel;
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);

View File

@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ClientProtocolLevel;
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);

View File

@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ClientProtocolLevel;
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);

View File

@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ClientProtocolLevel;
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);

View File

@ -52,7 +52,7 @@ import org.junit.jupiter.api.Test;
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);

View File

@ -52,7 +52,7 @@ import org.apache.hc.core5.http.nio.support.BasicResponseConsumer;
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);

View File

@ -52,7 +52,7 @@ import org.junit.jupiter.api.Test;
/**
* Redirection test cases.
*/
abstract class TestHttp1AsyncRedirects extends AbstractHttpAsyncRedirectsTest {
abstract class TestHttp1AsyncRedirects extends AbstractHttpAsyncRedirectsTest {
public TestHttp1AsyncRedirects(final URIScheme scheme) {
super(scheme, ClientProtocolLevel.STANDARD, ServerProtocolLevel.STANDARD);

View File

@ -49,7 +49,7 @@ import org.junit.jupiter.api.Assertions;
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);

View File

@ -57,7 +57,7 @@ import org.junit.jupiter.params.ParameterizedTest;
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 @@ abstract class TestHttp1Reactive extends AbstractHttpReactiveFundamentalsTest {
@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();

View File

@ -54,7 +54,7 @@ import org.apache.hc.core5.testing.reactive.ReactiveEchoProcessor;
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);

View File

@ -47,7 +47,7 @@ import org.hamcrest.CoreMatchers;
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);

View File

@ -45,7 +45,7 @@ import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.Test;
abstract class TestHttpAsyncProtocolPolicy extends AbstractIntegrationTestBase {
abstract class TestHttpAsyncProtocolPolicy extends AbstractIntegrationTestBase {
private final HttpVersion version;

View File

@ -94,7 +94,7 @@ public interface TestClientBuilder {
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());
}

View File

@ -107,7 +107,7 @@ public class CachingHttpAsyncClientCompatibilityTest {
client.close();
}
enum TestResult {OK, NOK}
enum TestResult { OK, NOK }
private void logResult(final TestResult result,
final HttpRequest request,
@ -186,7 +186,7 @@ public class CachingHttpAsyncClientCompatibilityTest {
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 @@ public class CachingHttpAsyncClientCompatibilityTest {
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 @@ public class CachingHttpAsyncClientCompatibilityTest {
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)");
}
}
}

View File

@ -92,7 +92,7 @@ public class CachingHttpClientCompatibilityTest {
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();

View File

@ -155,7 +155,7 @@ public class HttpAsyncClientCompatibilityTest {
client.close();
}
enum TestResult {OK, NOK}
enum TestResult { OK, NOK }
private void logResult(final TestResult result,
final HttpRequest request,

View File

@ -115,7 +115,7 @@ public class HttpClientCompatibilityTest {
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();

View File

@ -41,7 +41,7 @@ import org.apache.hc.core5.http.URIScheme;
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);

View File

@ -92,7 +92,7 @@ import org.mockito.Mockito;
/**
* 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);

View File

@ -71,7 +71,7 @@ import org.junit.jupiter.api.Test;
/**
* 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 @@ abstract class TestClientRequestExecution extends AbstractIntegrationTestBase {
}
@Test @Disabled("Fails intermittently with GitHub Actions")
public void testRequestCancellation() throws Exception {
void testRequestCancellation() throws Exception {
startServer();
final HttpHost target = startServer();

View File

@ -350,8 +350,8 @@ class TestConnectionReuse extends AbstractIntegrationTestBase {
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");
}
}

View File

@ -63,7 +63,7 @@ import org.junit.jupiter.api.Test;
* 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);

View File

@ -74,7 +74,7 @@ class TestFutureRequestExecutionService {
.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 @@ class TestFutureRequestExecutionService {
void shouldExecuteMultipleCalls() throws Exception {
final int reqNo = 100;
final Queue<Future<Boolean>> tasks = new LinkedList<>();
for(int i = 0; i < reqNo; i++) {
for (int i = 0; i < reqNo; i++) {
final Future<Boolean> task = httpAsyncClientWithFuture.execute(
new HttpGet(uri), HttpClientContext.create(), new OkidokiHandler());
tasks.add(task);
@ -150,7 +150,7 @@ class TestFutureRequestExecutionService {
final int reqNo = 100;
final Queue<Future<Boolean>> 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<Boolean> task = httpAsyncClientWithFuture.execute(
new HttpGet(uri), HttpClientContext.create(),
new OkidokiHandler(), new CountingCallback(latch));

View File

@ -51,7 +51,7 @@ import org.junit.jupiter.api.Test;
/**
* Client protocol handling tests.
*/
abstract class TestMinimalClientRequestExecution extends AbstractIntegrationTestBase {
abstract class TestMinimalClientRequestExecution extends AbstractIntegrationTestBase {
protected TestMinimalClientRequestExecution(final URIScheme scheme) {
super(scheme, ClientProtocolLevel.MINIMAL);

View File

@ -84,7 +84,7 @@ import org.junit.jupiter.api.Test;
/**
* Redirection test cases.
*/
abstract class TestRedirects extends AbstractIntegrationTestBase {
abstract class TestRedirects extends AbstractIntegrationTestBase {
protected TestRedirects(final URIScheme scheme) {
super(scheme, ClientProtocolLevel.STANDARD);

View File

@ -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 final class HttpRoute implements RouteInfo, Cloneable {
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 final class HttpRoute implements RouteInfo, Cloneable {
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 final class HttpRoute implements RouteInfo, Cloneable {
@Override
public boolean isTunnelled() {
return (this.tunnelled == TunnelType.TUNNELLED);
return this.tunnelled == TunnelType.TUNNELLED;
}
@Override
@ -317,7 +317,7 @@ public final class HttpRoute implements RouteInfo, Cloneable {
@Override
public boolean isLayered() {
return (this.layered == LayerType.LAYERED);
return this.layered == LayerType.LAYERED;
}
@Override
@ -341,14 +341,14 @@ public final class HttpRoute implements RouteInfo, Cloneable {
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 final class HttpRoute implements RouteInfo, Cloneable {
*/
@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("->");

View File

@ -63,7 +63,7 @@ public interface RouteInfo {
* But we don't want to exclude that use case.
* </p>
*/
enum LayerType { PLAIN, LAYERED }
enum LayerType { PLAIN, LAYERED }
/**
* Obtains the target host.

View File

@ -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 final class RouteTracker implements RouteInfo, Cloneable {
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 final class RouteTracker implements RouteInfo, Cloneable {
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 final class RouteTracker implements RouteInfo, Cloneable {
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 final class RouteTracker implements RouteInfo, Cloneable {
// 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 final class RouteTracker implements RouteInfo, Cloneable {
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 final class RouteTracker implements RouteInfo, Cloneable {
@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 final class RouteTracker implements RouteInfo, Cloneable {
@Override
public boolean isTunnelled() {
return (this.tunnelled == TunnelType.TUNNELLED);
return this.tunnelled == TunnelType.TUNNELLED;
}
@Override
@ -248,7 +248,7 @@ public final class RouteTracker implements RouteInfo, Cloneable {
@Override
public boolean isLayered() {
return (this.layered == LayerType.LAYERED);
return this.layered == LayerType.LAYERED;
}
@Override
@ -290,14 +290,14 @@ public final class RouteTracker implements RouteInfo, Cloneable {
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 final class RouteTracker implements RouteInfo, Cloneable {
*/
@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) {

View File

@ -96,7 +96,7 @@ public class SimpleResponseBuilder extends AbstractResponseBuilder<SimpleHttpRes
}
@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;
}

View File

@ -74,7 +74,7 @@ public class 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;
}

View File

@ -101,7 +101,7 @@ public class NTCredentials implements Credentials, Serializable {
final String workstation,
final String domain,
final String netbiosDomain) {
this(password, userName, domain, netbiosDomain);
this(password, userName, domain, netbiosDomain);
}
/**

View File

@ -40,12 +40,12 @@ import java.util.Date;
*/
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 @@ public interface Cookie {
/**
* 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 @@ public interface Cookie {
*
* @since 5.2
*/
default boolean isHttpOnly(){
default boolean isHttpOnly() {
return false;
}

View File

@ -112,7 +112,7 @@ public interface SetCookie extends Cookie {
*
* @since 5.2
*/
default void setHttpOnly (final boolean httpOnly){
default void setHttpOnly(final boolean httpOnly) {
}
}

View File

@ -66,7 +66,7 @@ public class UrlEncodedFormEntity extends StringEntity {
*
* @param parameters list of name/value pairs
*/
public UrlEncodedFormEntity (final List <? extends NameValuePair> parameters){
public UrlEncodedFormEntity(final List<? extends NameValuePair> parameters) {
this(parameters, null);
}
@ -78,8 +78,8 @@ public class UrlEncodedFormEntity extends StringEntity {
*
* @since 4.2
*/
public UrlEncodedFormEntity (
final Iterable <? extends NameValuePair> parameters) {
public UrlEncodedFormEntity(
final Iterable<? extends NameValuePair> parameters) {
this(parameters, null);
}

View File

@ -29,11 +29,11 @@ package org.apache.hc.client5.http.entity.mime;
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*";
}

View File

@ -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 final class CookieSpecSupport {
return createDefaultBuilder(publicSuffixMatcher).build();
}
private CookieSpecSupport() {}
private CookieSpecSupport() {
}
}

View File

@ -70,7 +70,7 @@ public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveSt
if (value != null && param.equalsIgnoreCase("timeout")) {
try {
return TimeValue.ofSeconds(Long.parseLong(value));
} catch(final NumberFormatException ignore) {
} catch (final NumberFormatException ignore) {
}
}
}

View File

@ -65,7 +65,7 @@ public final class IdleConnectionEvictor {
}
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
} catch (final Exception ex) {
} catch (final Exception ignore) {
}
});

View File

@ -89,7 +89,7 @@ public class InMemoryDnsResolver implements DnsResolver {
if (LOG.isInfoEnabled()) {
LOG.info("Resolving {} to {}", host, Arrays.deepToString(resolvedAddresses));
}
if(resolvedAddresses == null){
if (resolvedAddresses == null) {
throw new UnknownHostException(host);
}
return resolvedAddresses;

View File

@ -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<String> it = MessageSupport.iterateTokens(response, HttpHeaders.UPGRADE);
ProtocolVersion tlsUpgrade = null;

View File

@ -91,7 +91,7 @@ public class Wire {
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("]");

View File

@ -105,7 +105,7 @@ public final class AsyncConnectExec implements AsyncExecChainHandler {
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 final class AsyncConnectExec implements AsyncExecChainHandler {
@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 final class AsyncConnectExec implements AsyncExecChainHandler {
break;
default:
throw new IllegalStateException("Unknown step indicator " + step + " from RouteDirector.");
throw new IllegalStateException("Unknown step indicator " + step + " from RouteDirector.");
}
}

View File

@ -975,7 +975,7 @@ public class H2AsyncClientBuilder {
}
} catch (final InterruptedException ex) {
Thread.currentThread().interrupt();
} catch (final Exception ex) {
} catch (final Exception ignore) {
}
});

View File

@ -1038,7 +1038,7 @@ public class HttpAsyncClientBuilder {
if (evictExpiredConnections || evictIdleConnections) {
if (connManagerCopy instanceof ConnPoolControl) {
final IdleConnectionEvictor connectionEvictor = new IdleConnectionEvictor((ConnPoolControl<?>) connManagerCopy,
maxIdleTime, maxIdleTime);
maxIdleTime, maxIdleTime);
closeablesCopy.add(connectionEvictor::shutdown);
connectionEvictor.start();
}

View File

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

View File

@ -47,8 +47,8 @@ final class CredentialsMatcher {
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) {

View File

@ -141,7 +141,7 @@ public class DigestScheme implements AuthScheme, Serializable {
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 @@ public class DigestScheme implements AuthScheme, Serializable {
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 @@ public class DigestScheme implements AuthScheme, Serializable {
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];
}

View File

@ -211,10 +211,10 @@ public abstract class GGSSchemeBase implements AuthScheme {
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) {

View File

@ -1224,7 +1224,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
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 @@ final class NTLMEngineImpl implements NTLMEngine {
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 @@ final class NTLMEngineImpl implements NTLMEngine {
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 @@ final class NTLMEngineImpl implements NTLMEngine {
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 @@ final class NTLMEngineImpl implements NTLMEngine {
}
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 @@ final class NTLMEngineImpl implements NTLMEngine {
}
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[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[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[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[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);
}

View File

@ -162,7 +162,7 @@ public class SystemDefaultCredentialsProvider implements CredentialsStore {
return new PasswordAuthentication(proxyUser,
proxyPassword != null ? proxyPassword.toCharArray() : new char[] {});
}
} catch (final NumberFormatException ex) {
} catch (final NumberFormatException ignore) {
}
return null;

View File

@ -146,7 +146,7 @@ public final class ConnectExec implements ExecChainHandler {
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 final class ConnectExec implements ExecChainHandler {
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);

View File

@ -112,7 +112,7 @@ public class FutureRequestExecutionService implements Closeable {
final HttpContext context,
final HttpClientResponseHandler<T> HttpClientResponseHandler,
final FutureCallback<T> callback) {
if(closed.get()) {
if (closed.get()) {
throw new IllegalStateException("Close has been called on this httpclient instance.");
}
metrics.getScheduledConnections().incrementAndGet();

View File

@ -117,14 +117,14 @@ class InternalExecRuntime implements ExecRuntime, Cancellable {
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) {

View File

@ -117,7 +117,7 @@ class InternalHttpClient extends CloseableHttpClient implements Configurable {
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 {

View File

@ -118,7 +118,7 @@ public final class RedirectExec implements ExecChainHandler {
return response;
}
if (redirectCount >= maxRedirects) {
throw new RedirectException("Maximum redirects ("+ maxRedirects + ") exceeded");
throw new RedirectException("Maximum redirects (" + maxRedirects + ") exceeded");
}
redirectCount++;

View File

@ -37,7 +37,7 @@ import org.apache.hc.core5.http.ClassicHttpRequest;
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();

View File

@ -190,7 +190,8 @@ class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher
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) {

View File

@ -159,7 +159,7 @@ public final class BasicClientCookie implements SetCookie, Cloneable, Serializab
*/
@Override
public boolean isPersistent() {
return (null != cookieExpiryDate);
return null != cookieExpiryDate;
}
@ -268,8 +268,8 @@ public final class BasicClientCookie implements SetCookie, Cloneable, Serializab
@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 final class BasicClientCookie implements SetCookie, Cloneable, Serializab
@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 final class BasicClientCookie implements SetCookie, Cloneable, Serializab
private String value;
/** Domain attribute. */
private String cookieDomain;
private String cookieDomain;
/** Expiration {@link Instant}. */
private Instant cookieExpiryDate;

View File

@ -132,7 +132,7 @@ public class BasicDomainHandler implements CommonCookieAttributeHandler {
if (host.equals(domain)) {
return true;
}
if ((cookie.containsAttribute(Cookie.DOMAIN_ATTR))) {
if (cookie.containsAttribute(Cookie.DOMAIN_ATTR)) {
return domainMatch(domain, host);
}
return false;

View File

@ -139,7 +139,7 @@ public class LaxExpiresHandler extends AbstractCookieAttributeHandler implements
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;
}
}

View File

@ -61,11 +61,11 @@ import org.apache.hc.core5.util.Tokenizer;
@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

View File

@ -170,7 +170,7 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
*
* @since 5.1
*/
public static Builder builder() {
public static Builder builder() {
return new Builder();
}
@ -189,7 +189,8 @@ public class ManagedHttpClientConnectionFactory implements HttpConnectionFactory
private HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory;
private HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory;
private Builder() {}
private Builder() {
}
public Builder http1Config(final Http1Config http1Config) {
this.http1Config = http1Config;

View File

@ -301,7 +301,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
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 class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
}
final PoolEntry<HttpRoute, ManagedAsyncClientConnection> 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 class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
this.tlsConfigResolver = tlsConfigResolver;
}
void closeIfExpired(final PoolEntry<HttpRoute, ManagedAsyncClientConnection > entry) {
void closeIfExpired(final PoolEntry<HttpRoute, ManagedAsyncClientConnection> entry) {
final long now = System.currentTimeMillis();
if (entry.getExpiryDeadline().isBefore(now)) {
entry.discardConnection(CloseMode.GRACEFUL);

View File

@ -65,7 +65,7 @@ public class BasicRouteDirector implements HttpRouteDirector {
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 @@ public class BasicRouteDirector implements HttpRouteDirector {
}
// 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 @@ public class BasicRouteDirector implements HttpRouteDirector {
return UNREACHABLE;
}
for (int i=0; i<fhc-1; i++) {
for (int i = 0; i < fhc - 1; i++) {
if (!plan.getHopTarget(i).equals(fact.getHopTarget(i))) {
return UNREACHABLE;
}
@ -167,8 +166,8 @@ public class BasicRouteDirector implements HttpRouteDirector {
}
// proxy chain and target are the same, check tunnelling and layering
if ((fact.isTunnelled() && !plan.isTunnelled()) ||
(fact.isLayered() && !plan.isLayered())) {
if (fact.isTunnelled() && !plan.isTunnelled() ||
fact.isLayered() && !plan.isLayered()) {
return UNREACHABLE;
}

View File

@ -106,7 +106,7 @@ public class SystemDefaultRoutePlanner extends DefaultRoutePlanner {
private Proxy chooseProxy(final List<Proxy> 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()) {

View File

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

View File

@ -82,7 +82,7 @@ public class RequestDefaultHeaders implements HttpRequestInterceptor {
if (this.defaultHeaders != null) {
for (final Header defHeader : this.defaultHeaders) {
if(!request.containsHeader(defHeader.getName())) {
if (!request.containsHeader(defHeader.getName())) {
request.addHeader(defHeader);
}
}

View File

@ -63,8 +63,8 @@ public final class PublicSuffixMatcher {
*/
public PublicSuffixMatcher(
final DomainType domainType, final Collection<String> rules, final Collection<String> 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 final class PublicSuffixMatcher {
* @since 4.5
*/
public PublicSuffixMatcher(final Collection<PublicSuffixList> 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) {

View File

@ -71,7 +71,7 @@ public final class RoutingSupport {
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);
}

View File

@ -100,7 +100,7 @@ public class PlainConnectionSocketFactory implements ConnectionSocketFactory {
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();

View File

@ -226,7 +226,7 @@ abstract class AbstractClientTlsStrategy implements TlsStrategy, TlsSocketStrate
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);

Some files were not shown because too many files have changed in this diff Show More