diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheValidityPolicy.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheValidityPolicy.java index 2d469cada..7f7a674eb 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheValidityPolicy.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheValidityPolicy.java @@ -53,9 +53,9 @@ class CacheValidityPolicy { } public long getFreshnessLifetimeSecs(final HttpCacheEntry entry) { - final long maxage = getMaxAge(entry); - if (maxage > -1) { - return maxage; + final long maxAge = getMaxAge(entry); + if (maxAge > -1) { + return maxAge; } final Date dateValue = entry.getDate(); @@ -242,23 +242,23 @@ class CacheValidityPolicy { } protected long getMaxAge(final HttpCacheEntry entry) { - long maxage = -1; + long maxAge = -1; final Iterator it = MessageSupport.iterate(entry, HeaderConstants.CACHE_CONTROL); while (it.hasNext()) { final HeaderElement elt = it.next(); if (HeaderConstants.CACHE_CONTROL_MAX_AGE.equals(elt.getName()) || "s-maxage".equals(elt.getName())) { try { final long currMaxAge = Long.parseLong(elt.getValue()); - if (maxage == -1 || currMaxAge < maxage) { - maxage = currMaxAge; + if (maxAge == -1 || currMaxAge < maxAge) { + maxAge = currMaxAge; } } catch (final NumberFormatException nfe) { // be conservative if can't parse - maxage = 0; + maxAge = 0; } } } - return maxage; + return maxAge; } public boolean hasCacheControlDirective(final HttpCacheEntry entry, final String directive) { 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 dc6b4d179..97ebd5c05 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 @@ -80,11 +80,11 @@ class CachedResponseSuitabilityChecker { if (originInsistsOnFreshness(entry)) { return false; } - final long maxstale = getMaxStale(request); - if (maxstale == -1) { + final long maxStale = getMaxStale(request); + if (maxStale == -1) { return false; } - return (maxstale > validityStrategy.getStalenessSecs(entry, now)); + return (maxStale > validityStrategy.getStalenessSecs(entry, now)); } private boolean originInsistsOnFreshness(final HttpCacheEntry entry) { @@ -99,30 +99,30 @@ class CachedResponseSuitabilityChecker { } private long getMaxStale(final HttpRequest request) { - long maxstale = -1; + long maxStale = -1; final Iterator it = MessageSupport.iterate(request, HeaderConstants.CACHE_CONTROL); while (it.hasNext()) { final HeaderElement elt = it.next(); if (HeaderConstants.CACHE_CONTROL_MAX_STALE.equals(elt.getName())) { - if ((elt.getValue() == null || "".equals(elt.getValue().trim())) && maxstale == -1) { - maxstale = Long.MAX_VALUE; + if ((elt.getValue() == null || "".equals(elt.getValue().trim())) && maxStale == -1) { + maxStale = Long.MAX_VALUE; } else { try { long val = Long.parseLong(elt.getValue()); if (val < 0) { val = 0; } - if (maxstale == -1 || val < maxstale) { - maxstale = val; + if (maxStale == -1 || val < maxStale) { + maxStale = val; } } catch (final NumberFormatException nfe) { // err on the side of preserving semantic transparency - maxstale = 0; + maxStale = 0; } } } } - return maxstale; + return maxStale; } /** @@ -185,9 +185,9 @@ class CachedResponseSuitabilityChecker { if (HeaderConstants.CACHE_CONTROL_MAX_AGE.equals(elt.getName())) { try { - final int maxage = Integer.parseInt(elt.getValue()); - if (validityStrategy.getCurrentAgeSecs(entry, now) > maxage) { - log.debug("Response from cache was NOT suitable due to max age"); + final int maxAge = Integer.parseInt(elt.getValue()); + if (validityStrategy.getCurrentAgeSecs(entry, now) > maxAge) { + log.debug("Response from cache was not suitable due to max age"); return false; } } catch (final NumberFormatException ex) { @@ -199,9 +199,9 @@ class CachedResponseSuitabilityChecker { if (HeaderConstants.CACHE_CONTROL_MAX_STALE.equals(elt.getName())) { try { - final int maxstale = Integer.parseInt(elt.getValue()); - if (validityStrategy.getFreshnessLifetimeSecs(entry) > maxstale) { - log.debug("Response from cache was not suitable due to Max stale freshness"); + final int maxStale = Integer.parseInt(elt.getValue()); + if (validityStrategy.getFreshnessLifetimeSecs(entry) > maxStale) { + log.debug("Response from cache was not suitable due to max stale freshness"); return false; } } catch (final NumberFormatException ex) { @@ -213,13 +213,13 @@ class CachedResponseSuitabilityChecker { if (HeaderConstants.CACHE_CONTROL_MIN_FRESH.equals(elt.getName())) { try { - final long minfresh = Long.parseLong(elt.getValue()); - if (minfresh < 0L) { + final long minFresh = Long.parseLong(elt.getValue()); + if (minFresh < 0L) { return false; } final long age = validityStrategy.getCurrentAgeSecs(entry, now); final long freshness = validityStrategy.getFreshnessLifetimeSecs(entry); - if (freshness - age < minfresh) { + if (freshness - age < minFresh) { log.debug("Response from cache was not suitable due to min fresh " + "freshness requirement"); return false; diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java index 50ae89ec9..cb7a421ef 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExecBase.java @@ -247,10 +247,10 @@ public class CachingExecBase { final HeaderElement elt = it.next(); if (HeaderConstants.CACHE_CONTROL_MAX_STALE.equals(elt.getName())) { try { - final int maxstale = Integer.parseInt(elt.getValue()); + final int maxStale = Integer.parseInt(elt.getValue()); final long age = validityPolicy.getCurrentAgeSecs(entry, now); final long lifetime = validityPolicy.getFreshnessLifetimeSecs(entry); - if (age - lifetime > maxstale) { + if (age - lifetime > maxStale) { return true; } } catch (final NumberFormatException nfe) { diff --git a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java index 28fef8617..c1d8b7d6f 100644 --- a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java +++ b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java @@ -99,29 +99,29 @@ public class Executor { return this; } - public Executor auth(final AuthScope authScope, final Credentials creds) { + public Executor auth(final AuthScope authScope, final Credentials credentials) { if (this.credentialsStore == null) { this.credentialsStore = new BasicCredentialsProvider(); } - this.credentialsStore.setCredentials(authScope, creds); + this.credentialsStore.setCredentials(authScope, credentials); return this; } - public Executor auth(final HttpHost host, final Credentials creds) { - return auth(new AuthScope(host), creds); + public Executor auth(final HttpHost host, final Credentials credentials) { + return auth(new AuthScope(host), credentials); } /** * @since 4.4 */ - public Executor auth(final String host, final Credentials creds) { + public Executor auth(final String host, final Credentials credentials) { final HttpHost httpHost; try { httpHost = HttpHost.create(host); } catch (final URISyntaxException ex) { throw new IllegalArgumentException("Invalid host: " + host); } - return auth(httpHost, creds); + return auth(httpHost, credentials); } public Executor authPreemptive(final HttpHost host) { 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 46fb78717..74fe68c6a 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 @@ -127,14 +127,14 @@ public class AuthScope { /** * Creates a copy of the given credentials scope. */ - public AuthScope(final AuthScope authscope) { + public AuthScope(final AuthScope authScope) { super(); - Args.notNull(authscope, "Scope"); - this.protocol = authscope.getProtocol(); - this.host = authscope.getHost(); - this.port = authscope.getPort(); - this.realm = authscope.getRealm(); - this.authScheme = authscope.getAuthScheme(); + Args.notNull(authScope, "Scope"); + this.protocol = authScope.getProtocol(); + this.host = authScope.getHost(); + this.port = authScope.getPort(); + this.realm = authScope.getRealm(); + this.authScheme = authScope.getAuthScheme(); } public String getProtocol() { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsProvider.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsProvider.java index 103fc060f..39be2aad7 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsProvider.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsProvider.java @@ -44,11 +44,11 @@ public interface CredentialsProvider { * Returns {@link Credentials credentials} for the given authentication scope, * if available. * - * @param authscope the {@link AuthScope authentication scope} + * @param authScope the {@link AuthScope authentication scope} * @param context the {@link HttpContext http context} * @return the credentials * @since 5.0 */ - Credentials getCredentials(AuthScope authscope, HttpContext context); + Credentials getCredentials(AuthScope authScope, HttpContext context); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsStore.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsStore.java index a7578830e..a36c59d65 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsStore.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsStore.java @@ -42,13 +42,13 @@ public interface CredentialsStore extends CredentialsProvider { * Sets the {@link Credentials credentials} for the given authentication * scope. Any previous credentials for the given scope will be overwritten. * - * @param authscope the {@link AuthScope authentication scope} + * @param authScope the {@link AuthScope authentication scope} * @param credentials the authentication {@link Credentials credentials} * for the given scope. * * @see #getCredentials(AuthScope, org.apache.hc.core5.http.protocol.HttpContext) */ - void setCredentials(AuthScope authscope, Credentials credentials); + void setCredentials(AuthScope authScope, Credentials credentials); /** * Clears all credentials. diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ConnectionBackoffStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ConnectionBackoffStrategy.java index 059ac26b6..1ae39c814 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ConnectionBackoffStrategy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ConnectionBackoffStrategy.java @@ -56,9 +56,9 @@ public interface ConnectionBackoffStrategy { * signal. Implementations MUST restrict themselves to examining * the response header and MUST NOT consume any of the response * body, if any. - * @param resp the {@code HttpResponse} that was received + * @param response the {@code HttpResponse} that was received * @return {@code true} if a backoff signal should be * given */ - boolean shouldBackoff(HttpResponse resp); + boolean shouldBackoff(HttpResponse response); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/AbstractMultipartFormat.java b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/AbstractMultipartFormat.java index 93befa639..416bccbb0 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/AbstractMultipartFormat.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/mime/AbstractMultipartFormat.java @@ -91,7 +91,7 @@ abstract class AbstractMultipartFormat { static final ByteArrayBuffer FIELD_SEP = encode(StandardCharsets.ISO_8859_1, ": "); static final ByteArrayBuffer CR_LF = encode(StandardCharsets.ISO_8859_1, "\r\n"); - static final ByteArrayBuffer TWO_DASHES = encode(StandardCharsets.ISO_8859_1, "--"); + static final ByteArrayBuffer TWO_HYPHENS = encode(StandardCharsets.ISO_8859_1, "--"); final Charset charset; final String boundary; @@ -122,7 +122,7 @@ abstract class AbstractMultipartFormat { final ByteArrayBuffer boundaryEncoded = encode(this.charset, this.boundary); for (final MultipartPart part: getParts()) { - writeBytes(TWO_DASHES, out); + writeBytes(TWO_HYPHENS, out); writeBytes(boundaryEncoded, out); writeBytes(CR_LF, out); @@ -135,9 +135,9 @@ abstract class AbstractMultipartFormat { } writeBytes(CR_LF, out); } - writeBytes(TWO_DASHES, out); + writeBytes(TWO_HYPHENS, out); writeBytes(boundaryEncoded, out); - writeBytes(TWO_DASHES, out); + writeBytes(TWO_HYPHENS, out); writeBytes(CR_LF, out); } 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 97d039236..29f6a5598 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 @@ -38,7 +38,7 @@ public class Wire { private static final int MAX_STRING_BUILDER_SIZE = 2048; - private static final ThreadLocal threadLocal = new ThreadLocal<>(); + private static final ThreadLocal THREAD_LOCAL = new ThreadLocal<>(); /** * Returns a {@code StringBuilder} that this Layout implementation can use to write the formatted log event to. @@ -46,12 +46,11 @@ public class Wire { * @return a {@code StringBuilder} */ private static StringBuilder getStringBuilder() { - StringBuilder result = threadLocal.get(); + StringBuilder result = THREAD_LOCAL.get(); if (result == null) { result = new StringBuilder(MAX_STRING_BUILDER_SIZE); - threadLocal.set(result); + THREAD_LOCAL.set(result); } - // TODO Delegate to Log4j's 2.9 StringBuilds.trimToMaxSize() when it is released. trimToMaxSize(result, MAX_STRING_BUILDER_SIZE); result.setLength(0); return result; @@ -64,7 +63,6 @@ public class Wire { * @param stringBuilder the StringBuilder to check * @param maxSize the maximum number of characters the StringBuilder is allowed to have */ - // TODO Delete wheb Log4j's 2.9 (see #trimToMaxSize(StringBuild)) private static void trimToMaxSize(final StringBuilder stringBuilder, final int maxSize) { if (stringBuilder != null && stringBuilder.capacity() > maxSize) { stringBuilder.setLength(maxSize); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractMinimalHttpAsyncClientBase.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractMinimalHttpAsyncClientBase.java index 4b927ab8e..9058a967a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractMinimalHttpAsyncClientBase.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AbstractMinimalHttpAsyncClientBase.java @@ -54,7 +54,7 @@ abstract class AbstractMinimalHttpAsyncClientBase extends AbstractHttpAsyncClien @Override protected Future doExecute( - final HttpHost httphost, + final HttpHost httpHost, final AsyncRequestProducer requestProducer, final AsyncResponseConsumer responseConsumer, final HandlerFactory pushHandlerFactory, diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java index 07882c1b8..48289b95a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalHttpAsyncClient.java @@ -68,7 +68,7 @@ import org.apache.hc.core5.reactor.DefaultConnectingIOReactor; @Internal public final class InternalHttpAsyncClient extends InternalAbstractHttpAsyncClient { - private final AsyncClientConnectionManager connmgr; + private final AsyncClientConnectionManager manager; private final HttpRoutePlanner routePlanner; private final HttpVersionPolicy versionPolicy; @@ -77,7 +77,7 @@ public final class InternalHttpAsyncClient extends InternalAbstractHttpAsyncClie final AsyncExecChainElement execChain, final AsyncPushConsumerRegistry pushConsumerRegistry, final ThreadFactory threadFactory, - final AsyncClientConnectionManager connmgr, + final AsyncClientConnectionManager manager, final HttpRoutePlanner routePlanner, final HttpVersionPolicy versionPolicy, final Lookup cookieSpecRegistry, @@ -88,14 +88,14 @@ public final class InternalHttpAsyncClient extends InternalAbstractHttpAsyncClie final List closeables) { super(ioReactor, pushConsumerRegistry, threadFactory, execChain, cookieSpecRegistry, authSchemeRegistry, cookieStore, credentialsProvider, defaultConfig, closeables); - this.connmgr = connmgr; + this.manager = manager; this.routePlanner = routePlanner; this.versionPolicy = versionPolicy; } @Override AsyncExecRuntime createAsyncExecRuntime(final HandlerFactory pushHandlerFactory) { - return new InternalHttpAsyncExecRuntime(log, connmgr, getConnectionInitiator(), pushHandlerFactory, versionPolicy); + return new InternalHttpAsyncExecRuntime(log, manager, getConnectionInitiator(), pushHandlerFactory, versionPolicy); } @Override diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java index fc9399934..e74cf3d53 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java @@ -98,7 +98,7 @@ import org.apache.hc.core5.util.Timeout; @Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClientBase { - private final AsyncClientConnectionManager connmgr; + private final AsyncClientConnectionManager manager; private final SchemePortResolver schemePortResolver; private final HttpVersionPolicy versionPolicy; @@ -109,7 +109,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient final IOReactorConfig reactorConfig, final ThreadFactory threadFactory, final ThreadFactory workerThreadFactory, - final AsyncClientConnectionManager connmgr, + final AsyncClientConnectionManager manager, final SchemePortResolver schemePortResolver) { super(new DefaultConnectingIOReactor( eventHandlerFactory, @@ -128,7 +128,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient }), pushConsumerRegistry, threadFactory); - this.connmgr = connmgr; + this.manager = manager; this.schemePortResolver = schemePortResolver != null ? schemePortResolver : DefaultSchemePortResolver.INSTANCE; this.versionPolicy = versionPolicy != null ? versionPolicy : HttpVersionPolicy.NEGOTIATE; } @@ -142,7 +142,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient final HttpRoute route = new HttpRoute(RoutingSupport.normalize(host, schemePortResolver)); final ComplexFuture resultFuture = new ComplexFuture<>(callback); final String exchangeId = ExecSupport.getNextExchangeId(); - final Future leaseFuture = connmgr.lease( + final Future leaseFuture = manager.lease( exchangeId, route, null, @@ -154,7 +154,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient if (connectionEndpoint.isConnected()) { resultFuture.completed(connectionEndpoint); } else { - final Future connectFuture = connmgr.connect( + final Future connectFuture = manager.connect( connectionEndpoint, getConnectionInitiator(), connectTimeout, @@ -478,7 +478,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient @Override public void releaseAndReuse() { if (released.compareAndSet(false, true)) { - connmgr.release(connectionEndpoint, null, TimeValue.NEG_ONE_MILLISECONDS); + manager.release(connectionEndpoint, null, TimeValue.NEG_ONE_MILLISECONDS); } } @@ -486,7 +486,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient public void releaseAndDiscard() { if (released.compareAndSet(false, true)) { Closer.closeQuietly(connectionEndpoint); - connmgr.release(connectionEndpoint, null, TimeValue.ZERO_MILLISECONDS); + manager.release(connectionEndpoint, null, TimeValue.ZERO_MILLISECONDS); } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/BasicCredentialsProvider.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/BasicCredentialsProvider.java index 26465ca0a..579d8b2ab 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/BasicCredentialsProvider.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/BasicCredentialsProvider.java @@ -57,32 +57,32 @@ public class BasicCredentialsProvider implements CredentialsStore { @Override public void setCredentials( - final AuthScope authscope, + final AuthScope authScope, final Credentials credentials) { - Args.notNull(authscope, "Authentication scope"); - credMap.put(authscope, credentials); + Args.notNull(authScope, "Authentication scope"); + credMap.put(authScope, credentials); } /** * Find matching {@link Credentials credentials} for the given authentication scope. * * @param map the credentials hash map - * @param authscope the {@link AuthScope authentication scope} + * @param authScope the {@link AuthScope authentication scope} * @return the credentials * */ private static Credentials matchCredentials( final Map map, - final AuthScope authscope) { + final AuthScope authScope) { // see if we get a direct hit - Credentials creds = map.get(authscope); + Credentials creds = map.get(authScope); if (creds == null) { // Nope. // Do a full scan int bestMatchFactor = -1; AuthScope bestMatch = null; for (final AuthScope current: map.keySet()) { - final int factor = authscope.match(current); + final int factor = authScope.match(current); if (factor > bestMatchFactor) { bestMatchFactor = factor; bestMatch = current; @@ -96,10 +96,10 @@ public class BasicCredentialsProvider implements CredentialsStore { } @Override - public Credentials getCredentials(final AuthScope authscope, + public Credentials getCredentials(final AuthScope authScope, final HttpContext httpContext) { - Args.notNull(authscope, "Authentication scope"); - return matchCredentials(this.credMap, authscope); + Args.notNull(authScope, "Authentication scope"); + return matchCredentials(this.credMap, authScope); } @Override 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 a4c0b0e22..b338c2de4 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 @@ -88,13 +88,13 @@ public class SystemDefaultCredentialsProvider implements CredentialsStore { } @Override - public void setCredentials(final AuthScope authscope, final Credentials credentials) { - internal.setCredentials(authscope, credentials); + public void setCredentials(final AuthScope authScope, final Credentials credentials) { + internal.setCredentials(authScope, credentials); } private static PasswordAuthentication getSystemCreds( final String protocol, - final AuthScope authscope, + final AuthScope authScope, final Authenticator.RequestorType requestorType, final HttpClientContext context) { final HttpRequest request = context != null ? context.getRequest() : null; @@ -107,41 +107,41 @@ public class SystemDefaultCredentialsProvider implements CredentialsStore { } // use null addr, because the authentication fails if it does not exactly match the expected realm's host return Authenticator.requestPasswordAuthentication( - authscope.getHost(), + authScope.getHost(), null, - authscope.getPort(), + authScope.getPort(), protocol, - authscope.getRealm(), - translateAuthScheme(authscope.getAuthScheme()), + authScope.getRealm(), + translateAuthScheme(authScope.getAuthScheme()), targetHostURL, requestorType); } @Override - public Credentials getCredentials(final AuthScope authscope, final HttpContext context) { - Args.notNull(authscope, "Auth scope"); - final Credentials localcreds = internal.getCredentials(authscope, context); + public Credentials getCredentials(final AuthScope authScope, final HttpContext context) { + Args.notNull(authScope, "Auth scope"); + final Credentials localcreds = internal.getCredentials(authScope, context); if (localcreds != null) { return localcreds; } - final String host = authscope.getHost(); + final String host = authScope.getHost(); if (host != null) { final HttpClientContext clientContext = context != null ? HttpClientContext.adapt(context) : null; - final String protocol = authscope.getProtocol() != null ? authscope.getProtocol() : (authscope.getPort() == 443 ? URIScheme.HTTPS.id : URIScheme.HTTP.id); + final String protocol = authScope.getProtocol() != null ? authScope.getProtocol() : (authScope.getPort() == 443 ? URIScheme.HTTPS.id : URIScheme.HTTP.id); PasswordAuthentication systemcreds = getSystemCreds( - protocol, authscope, Authenticator.RequestorType.SERVER, clientContext); + protocol, authScope, Authenticator.RequestorType.SERVER, clientContext); if (systemcreds == null) { systemcreds = getSystemCreds( - protocol, authscope, Authenticator.RequestorType.PROXY, clientContext); + protocol, authScope, Authenticator.RequestorType.PROXY, clientContext); } if (systemcreds == null) { // Look for values given using http.proxyUser/http.proxyPassword or // https.proxyUser/https.proxyPassword. We cannot simply use the protocol from // the origin since a proxy retrieved from https.proxyHost/https.proxyPort will // still use http as protocol - systemcreds = getProxyCredentials("http", authscope); + systemcreds = getProxyCredentials("http", authScope); if (systemcreds == null) { - systemcreds = getProxyCredentials("https", authscope); + systemcreds = getProxyCredentials("https", authScope); } } if (systemcreds != null) { @@ -149,7 +149,7 @@ public class SystemDefaultCredentialsProvider implements CredentialsStore { if (domain != null) { return new NTCredentials(systemcreds.getUserName(), systemcreds.getPassword(), null, domain); } - if (AuthSchemes.NTLM.ident.equalsIgnoreCase(authscope.getAuthScheme())) { + if (AuthSchemes.NTLM.ident.equalsIgnoreCase(authScope.getAuthScheme())) { // Domain may be specified in a fully qualified user name return new NTCredentials( systemcreds.getUserName(), systemcreds.getPassword(), null, null); @@ -160,7 +160,7 @@ public class SystemDefaultCredentialsProvider implements CredentialsStore { return null; } - private static PasswordAuthentication getProxyCredentials(final String protocol, final AuthScope authscope) { + private static PasswordAuthentication getProxyCredentials(final String protocol, final AuthScope authScope) { final String proxyHost = System.getProperty(protocol + ".proxyHost"); if (proxyHost == null) { return null; @@ -172,7 +172,7 @@ public class SystemDefaultCredentialsProvider implements CredentialsStore { try { final AuthScope systemScope = new AuthScope(proxyHost, Integer.parseInt(proxyPort)); - if (authscope.match(systemScope) >= 0) { + if (authScope.match(systemScope) >= 0) { final String proxyUser = System.getProperty(protocol + ".proxyUser"); if (proxyUser == null) { return null; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/DefaultBackoffStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/DefaultBackoffStrategy.java index 86c7af324..9ade7eab5 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/DefaultBackoffStrategy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/DefaultBackoffStrategy.java @@ -50,9 +50,9 @@ public class DefaultBackoffStrategy implements ConnectionBackoffStrategy { } @Override - public boolean shouldBackoff(final HttpResponse resp) { - return resp.getCode() == HttpStatus.SC_TOO_MANY_REQUESTS || - resp.getCode() == HttpStatus.SC_SERVICE_UNAVAILABLE; + public boolean shouldBackoff(final HttpResponse response) { + return response.getCode() == HttpStatus.SC_TOO_MANY_REQUESTS || + response.getCode() == HttpStatus.SC_SERVICE_UNAVAILABLE; } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/NullBackoffStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/NullBackoffStrategy.java index 36440aaa9..402af4882 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/NullBackoffStrategy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/NullBackoffStrategy.java @@ -43,7 +43,7 @@ public class NullBackoffStrategy implements ConnectionBackoffStrategy { } @Override - public boolean shouldBackoff(final HttpResponse resp) { + public boolean shouldBackoff(final HttpResponse response) { return false; } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/socket/ConnectionSocketFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/socket/ConnectionSocketFactory.java index edb510b37..88cafd07c 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/socket/ConnectionSocketFactory.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/socket/ConnectionSocketFactory.java @@ -60,7 +60,7 @@ public interface ConnectionSocketFactory { * Connects the socket to the target host with the given resolved remote address. * * @param connectTimeout connect timeout. - * @param sock the socket to connect, as obtained from {@link #createSocket(HttpContext)}. + * @param socket the socket to connect, as obtained from {@link #createSocket(HttpContext)}. * {@code null} indicates that a new socket should be created and connected. * @param host target host as specified by the caller (end user). * @param remoteAddress the resolved remote address to connect to. @@ -75,7 +75,7 @@ public interface ConnectionSocketFactory { */ Socket connectSocket( TimeValue connectTimeout, - Socket sock, + Socket socket, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, 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 741f01684..d3be93123 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 @@ -121,7 +121,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor return false; } - private final javax.net.ssl.SSLSocketFactory socketfactory; + private final javax.net.ssl.SSLSocketFactory socketFactory; private final HostnameVerifier hostnameVerifier; private final String[] supportedProtocols; private final String[] supportedCipherSuites; @@ -156,20 +156,20 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor * @since 4.4 */ public SSLConnectionSocketFactory( - final javax.net.ssl.SSLSocketFactory socketfactory, + final javax.net.ssl.SSLSocketFactory socketFactory, final HostnameVerifier hostnameVerifier) { - this(socketfactory, null, null, hostnameVerifier); + this(socketFactory, null, null, hostnameVerifier); } /** * @since 4.4 */ public SSLConnectionSocketFactory( - final javax.net.ssl.SSLSocketFactory socketfactory, + final javax.net.ssl.SSLSocketFactory socketFactory, final String[] supportedProtocols, final String[] supportedCipherSuites, final HostnameVerifier hostnameVerifier) { - this.socketfactory = Args.notNull(socketfactory, "SSL socket factory"); + this.socketFactory = Args.notNull(socketFactory, "SSL socket factory"); this.supportedProtocols = supportedProtocols; this.supportedCipherSuites = supportedCipherSuites; this.hostnameVerifier = hostnameVerifier != null ? hostnameVerifier : HttpsSupport.getDefaultHostnameVerifier(); @@ -250,7 +250,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor final String target, final int port, final HttpContext context) throws IOException { - final SSLSocket sslsock = (SSLSocket) this.socketfactory.createSocket( + final SSLSocket sslsock = (SSLSocket) this.socketFactory.createSocket( socket, target, port, @@ -310,8 +310,8 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor protected void verifySession( final String hostname, - final SSLSession sslsession) throws SSLException { - tlsSessionValidator.verifySession(hostname, sslsession, hostnameVerifier); + final SSLSession sslSession) throws SSLException { + tlsSessionValidator.verifySession(hostname, sslSession, hostnameVerifier); } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactoryBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactoryBuilder.java index 2310c3022..f31d78d88 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactoryBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/ssl/SSLConnectionSocketFactoryBuilder.java @@ -125,14 +125,14 @@ public class SSLConnectionSocketFactoryBuilder { } public SSLConnectionSocketFactory build() { - final javax.net.ssl.SSLSocketFactory socketfactory; + final javax.net.ssl.SSLSocketFactory socketFactory; if (sslContext != null) { - socketfactory = sslContext.getSocketFactory(); + socketFactory = sslContext.getSocketFactory(); } else { if (systemProperties) { - socketfactory = (javax.net.ssl.SSLSocketFactory) javax.net.ssl.SSLSocketFactory.getDefault(); + socketFactory = (javax.net.ssl.SSLSocketFactory) javax.net.ssl.SSLSocketFactory.getDefault(); } else { - socketfactory = SSLContexts.createDefault().getSocketFactory(); + socketFactory = SSLContexts.createDefault().getSocketFactory(); } } final String[] tlsVersionsCopy; @@ -148,7 +148,7 @@ public class SSLConnectionSocketFactoryBuilder { ciphersCopy = systemProperties ? HttpsSupport.getSystemCipherSuits() : null; } return new SSLConnectionSocketFactory( - socketfactory, + socketFactory, tlsVersionsCopy, ciphersCopy, hostnameVerifier != null ? hostnameVerifier : HttpsSupport.getDefaultHostnameVerifier());