You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2018/08/14 19:01:26 UTC
[2/3] httpcomponents-client git commit: - Always use blocks - Add
missing serial version ID (default 1L) - Camel-case names. - Don't nest in
else clause unnecessarily. - Remove declared exceptions that are not thrown
(but don't break BC.) - Remove redund
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java
index ce2a2c9..e069370 100644
--- a/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java
+++ b/httpclient/src/main/java/org/apache/http/conn/util/PublicSuffixMatcher.java
@@ -103,11 +103,7 @@ public final class PublicSuffixMatcher {
return false;
}
final DomainType domainType = map.get(rule);
- if (domainType == null) {
- return false;
- } else {
- return expectedType == null || domainType.equals(expectedType);
- }
+ return domainType == null ? false : expectedType == null || domainType.equals(expectedType);
}
private boolean hasRule(final String rule, final DomainType expectedType) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java b/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
index e24be61..4407f13 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
@@ -107,9 +107,8 @@ public final class CookieSpecRegistry implements Lookup<CookieSpecProvider> {
final CookieSpecFactory factory = registeredSpecs.get(name.toLowerCase(Locale.ENGLISH));
if (factory != null) {
return factory.newInstance(params);
- } else {
- throw new IllegalStateException("Unsupported cookie spec: " + name);
}
+ throw new IllegalStateException("Unsupported cookie spec: " + name);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java b/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
index 296b15c..a1515df 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
@@ -159,11 +159,7 @@ public abstract class AuthSchemeBase implements ContextAwareAuthScheme {
@Override
public String toString() {
final String name = getSchemeName();
- if (name != null) {
- return name.toUpperCase(Locale.ROOT);
- } else {
- return super.toString();
- }
+ return name != null ? name.toUpperCase(Locale.ROOT) : super.toString();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
index 1e3c62f..74d0377 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
@@ -152,11 +152,7 @@ public class DigestScheme extends RFC2617Scheme {
@Override
public boolean isComplete() {
final String s = getParameter("stale");
- if ("true".equalsIgnoreCase(s)) {
- return false;
- } else {
- return this.complete;
- }
+ return "true".equalsIgnoreCase(s) ? false : this.complete;
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java b/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
index 1fbc86a..e341a85 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java
@@ -120,11 +120,9 @@ public abstract class GGSSchemeBase extends AuthSchemeBase {
}
final GSSContext gssContext = createGSSContext(manager, oid, serverName, gssCredential);
- if (input != null) {
- return gssContext.initSecContext(input, 0, input.length);
- } else {
- return gssContext.initSecContext(new byte[] {}, 0, 0);
- }
+ return input != null
+ ? gssContext.initSecContext(input, 0, input.length)
+ : gssContext.initSecContext(new byte[] {}, 0, 0);
}
GSSContext createGSSContext(
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java b/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
index 6bc2878..a19bd48 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
@@ -79,21 +79,20 @@ public class HttpAuthenticator {
authStrategy.authFailed(host, authState.getAuthScheme(), context);
}
return true;
- } else {
- switch (authState.getState()) {
- case CHALLENGED:
- case HANDSHAKE:
- this.log.debug("Authentication succeeded");
- authState.setState(AuthProtocolState.SUCCESS);
- authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
- break;
- case SUCCESS:
- break;
- default:
- authState.setState(AuthProtocolState.UNCHALLENGED);
- }
- return false;
}
+ switch (authState.getState()) {
+ case CHALLENGED:
+ case HANDSHAKE:
+ this.log.debug("Authentication succeeded");
+ authState.setState(AuthProtocolState.SUCCESS);
+ authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
+ break;
+ case SUCCESS:
+ break;
+ default:
+ authState.setState(AuthProtocolState.UNCHALLENGED);
+ }
+ return false;
}
public boolean handleAuthChallenge(
@@ -141,14 +140,12 @@ public class HttpAuthenticator {
authState.reset();
authState.setState(AuthProtocolState.FAILURE);
return false;
- } else {
- authState.setState(AuthProtocolState.HANDSHAKE);
- return true;
}
- } else {
- authState.reset();
- // Retry authentication with a different scheme
+ authState.setState(AuthProtocolState.HANDSHAKE);
+ return true;
}
+ authState.reset();
+ // Retry authentication with a different scheme
}
}
final Queue<AuthOption> authOptions = authStrategy.select(challenges, host, response, context);
@@ -159,9 +156,8 @@ public class HttpAuthenticator {
authState.setState(AuthProtocolState.CHALLENGED);
authState.update(authOptions);
return true;
- } else {
- return false;
}
+ return false;
} catch (final MalformedChallengeException ex) {
if (this.log.isWarnEnabled()) {
this.log.warn("Malformed challenge: " + ex.getMessage());
@@ -209,9 +205,8 @@ public class HttpAuthenticator {
}
}
return;
- } else {
- ensureAuthScheme(authScheme);
}
+ ensureAuthScheme(authScheme);
}
if (authScheme != null) {
try {
@@ -235,11 +230,10 @@ public class HttpAuthenticator {
final Credentials creds,
final HttpRequest request,
final HttpContext context) throws AuthenticationException {
- if (authScheme instanceof ContextAwareAuthScheme) {
- return ((ContextAwareAuthScheme) authScheme).authenticate(creds, request, context);
- } else {
- return authScheme.authenticate(creds, request);
- }
+ return authScheme instanceof ContextAwareAuthScheme
+ ? ((ContextAwareAuthScheme) authScheme).authenticate(creds, request,
+ context)
+ : authScheme.authenticate(creds, request);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
index 1677e77..e642615 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
@@ -209,7 +209,7 @@ final class NTLMEngineImpl implements NTLMEngine {
targetInformation, peerServerCertificate, type1Message, type2Message).getResponse();
}
- private static int readULong(final byte[] src, final int index) throws NTLMEngineException {
+ private static int readULong(final byte[] src, final int index) {
if (src.length < index + 4) {
return 0;
}
@@ -217,14 +217,14 @@ final class NTLMEngineImpl implements NTLMEngine {
| ((src[index + 2] & 0xff) << 16) | ((src[index + 3] & 0xff) << 24);
}
- private static int readUShort(final byte[] src, final int index) throws NTLMEngineException {
+ private static int readUShort(final byte[] src, final int index) {
if (src.length < index + 2) {
return 0;
}
return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8);
}
- private static byte[] readSecurityBuffer(final byte[] src, final int index) throws NTLMEngineException {
+ private static byte[] readSecurityBuffer(final byte[] src, final int index) {
final int length = readUShort(src, index);
final int offset = readULong(src, index + 4);
if (src.length < offset + length) {
@@ -236,7 +236,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Calculate a challenge block */
- private static byte[] makeRandomChallenge(final Random random) throws NTLMEngineException {
+ private static byte[] makeRandomChallenge(final Random random) {
final byte[] rval = new byte[8];
synchronized (random) {
random.nextBytes(rval);
@@ -245,7 +245,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Calculate a 16-byte secondary key */
- private static byte[] makeSecondaryKey(final Random random) throws NTLMEngineException {
+ private static byte[] makeSecondaryKey(final Random random) {
final byte[] rval = new byte[16];
synchronized (random) {
random.nextBytes(rval);
@@ -747,8 +747,7 @@ final class NTLMEngineImpl implements NTLMEngine {
* @return The response (either NTLMv2 or LMv2, depending on the client
* data).
*/
- private static byte[] lmv2Response(final byte[] hash, final byte[] challenge, final byte[] clientData)
- throws NTLMEngineException {
+ private static byte[] lmv2Response(final byte[] hash, final byte[] challenge, final byte[] clientData) {
final HMACMD5 hmacMD5 = new HMACMD5(hash);
hmacMD5.update(challenge);
hmacMD5.update(clientData);
@@ -856,17 +855,17 @@ final class NTLMEngineImpl implements NTLMEngine {
sequenceNumber++;
}
- private byte[] encrypt( final byte[] data ) throws NTLMEngineException
+ private byte[] encrypt( final byte[] data )
{
return rc4.update( data );
}
- private byte[] decrypt( final byte[] data ) throws NTLMEngineException
+ private byte[] decrypt( final byte[] data )
{
return rc4.update( data );
}
- private byte[] computeSignature( final byte[] message ) throws NTLMEngineException
+ private byte[] computeSignature( final byte[] message )
{
final byte[] sig = new byte[16];
@@ -892,7 +891,7 @@ final class NTLMEngineImpl implements NTLMEngine {
return sig;
}
- private boolean validateSignature( final byte[] signature, final byte message[] ) throws NTLMEngineException
+ private boolean validateSignature( final byte[] signature, final byte message[] )
{
final byte[] computedSignature = computeSignature( message );
// log.info( "SSSSS validateSignature("+seqNumber+")\n"
@@ -1036,12 +1035,11 @@ final class NTLMEngineImpl implements NTLMEngine {
{
if ((flags & FLAG_REQUEST_UNICODE_ENCODING) == 0) {
return DEFAULT_CHARSET;
- } else {
- if (UNICODE_LITTLE_UNMARKED == null) {
- throw new NTLMEngineException( "Unicode not supported" );
- }
- return UNICODE_LITTLE_UNMARKED;
}
+ if (UNICODE_LITTLE_UNMARKED == null) {
+ throw new NTLMEngineException( "Unicode not supported" );
+ }
+ return UNICODE_LITTLE_UNMARKED;
}
/** Strip dot suffix from a name */
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java b/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
index 4d163ba..eeffd01 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
@@ -90,9 +90,8 @@ public class BasicAuthCache implements AuthCache {
return host;
}
return new HttpHost(host.getHostName(), port, host.getSchemeName());
- } else {
- return host;
}
+ return host;
}
@Override
@@ -142,9 +141,8 @@ public class BasicAuthCache implements AuthCache {
}
return null;
}
- } else {
- return null;
}
+ return null;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
index dd5eb4a..33ecf97 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
@@ -138,11 +138,10 @@ public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler {
}
if (this.nonRetriableClasses.contains(exception.getClass())) {
return false;
- } else {
- for (final Class<? extends IOException> rejectException : this.nonRetriableClasses) {
- if (rejectException.isInstance(exception)) {
- return false;
- }
+ }
+ for (final Class<? extends IOException> rejectException : this.nonRetriableClasses) {
+ if (rejectException.isInstance(exception)) {
+ return false;
}
}
final HttpClientContext clientContext = HttpClientContext.adapt(context);
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
index 0e02b29..5d92e5a 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
@@ -226,11 +226,9 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
return new HttpGet(uri);
} else {
final int status = response.getStatusLine().getStatusCode();
- if (status == HttpStatus.SC_TEMPORARY_REDIRECT) {
- return RequestBuilder.copy(request).setUri(uri).build();
- } else {
- return new HttpGet(uri);
- }
+ return status == HttpStatus.SC_TEMPORARY_REDIRECT
+ ? RequestBuilder.copy(request).setUri(uri).build()
+ : new HttpGet(uri);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java b/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
index 061ae3f..8b099af 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
@@ -105,9 +105,9 @@ public class EntityEnclosingRequestWrapper extends RequestWrapper
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
+ public void writeTo(final OutputStream outStream) throws IOException {
consumed = true;
- super.writeTo(outstream);
+ super.writeTo(outStream);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java
index f37cd7a..1bd8090 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java
@@ -82,9 +82,8 @@ public class HttpRequestFutureTask<V> extends FutureTask<V> {
public long endedTime() {
if (isDone()) {
return callable.getEnded();
- } else {
- throw new IllegalStateException("Task is not done yet");
}
+ throw new IllegalStateException("Task is not done yet");
}
/**
@@ -94,9 +93,8 @@ public class HttpRequestFutureTask<V> extends FutureTask<V> {
public long requestDuration() {
if (isDone()) {
return endedTime() - startedTime();
- } else {
- throw new IllegalStateException("Task is not done yet");
}
+ throw new IllegalStateException("Task is not done yet");
}
/**
@@ -105,9 +103,8 @@ public class HttpRequestFutureTask<V> extends FutureTask<V> {
public long taskDuration() {
if (isDone()) {
return endedTime() - scheduledTime();
- } else {
- throw new IllegalStateException("Task is not done yet");
}
+ throw new IllegalStateException("Task is not done yet");
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
index 47fb238..749ac7e 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
@@ -106,9 +106,8 @@ class HttpRequestTaskCallable<V> implements Callable<V> {
metrics.getTasks().increment(started);
metrics.getActiveConnections().decrementAndGet();
}
- } else {
- throw new IllegalStateException("call has been cancelled for request " + request.getURI());
}
+ throw new IllegalStateException("call has been cancelled for request " + request.getURI());
}
public void cancel() {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java b/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java
index b95b508..40c0ff4 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/IdleConnectionEvictor.java
@@ -104,8 +104,8 @@ public final class IdleConnectionEvictor {
return thread.isAlive();
}
- public void awaitTermination(final long time, final TimeUnit tunit) throws InterruptedException {
- thread.join((tunit != null ? tunit : TimeUnit.MILLISECONDS).toMillis(time));
+ public void awaitTermination(final long time, final TimeUnit timeUnit) throws InterruptedException {
+ thread.join((timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS).toMillis(time));
}
static class DefaultThreadFactory implements ThreadFactory {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
index 20bf060..07eac49 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
@@ -240,8 +240,8 @@ class InternalHttpClient extends CloseableHttpClient implements Configurable {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- connManager.closeIdleConnections(idletime, tunit);
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ connManager.closeIdleConnections(idletime, timeUnit);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
index 30ce492..585eb9e 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
@@ -150,8 +150,8 @@ class MinimalHttpClient extends CloseableHttpClient {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- connManager.closeIdleConnections(idletime, tunit);
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ connManager.closeIdleConnections(idletime, timeUnit);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
index 122a859..3ac37f6 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
@@ -142,19 +142,13 @@ public class SystemDefaultCredentialsProvider implements CredentialsProvider {
systemcreds.getUserName(),
new String(systemcreds.getPassword()),
null, domain);
- } else {
- if (AuthSchemes.NTLM.equalsIgnoreCase(authscope.getScheme())) {
- // Domain may be specified in a fully qualified user name
- return new NTCredentials(
- systemcreds.getUserName(),
- new String(systemcreds.getPassword()),
- null, null);
- } else {
- return new UsernamePasswordCredentials(
- systemcreds.getUserName(),
- new String(systemcreds.getPassword()));
- }
}
+ return AuthSchemes.NTLM.equalsIgnoreCase(authscope.getScheme())
+ // Domain may be specified in a fully qualified user name
+ ? new NTCredentials(systemcreds.getUserName(),
+ new String(systemcreds.getPassword()), null, null)
+ : new UsernamePasswordCredentials(systemcreds.getUserName(),
+ new String(systemcreds.getPassword()));
}
}
return null;
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
index 10aef9f..8119102 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
@@ -200,7 +200,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
}
@Override
- public HttpClientConnection get(final long timeout, final TimeUnit tunit) {
+ public HttpClientConnection get(final long timeout, final TimeUnit timeUnit) {
return BasicHttpClientConnectionManager.this.getConnection(
route, state);
}
@@ -255,7 +255,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
public synchronized void releaseConnection(
final HttpClientConnection conn,
final Object state,
- final long keepalive, final TimeUnit tunit) {
+ final long keepalive, final TimeUnit timeUnit) {
Args.notNull(conn, "Connection");
Asserts.check(conn == this.conn, "Connection not obtained from this manager");
if (this.log.isDebugEnabled()) {
@@ -277,14 +277,14 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
if (this.log.isDebugEnabled()) {
final String s;
if (keepalive > 0) {
- s = "for " + keepalive + " " + tunit;
+ s = "for " + keepalive + " " + timeUnit;
} else {
s = "indefinitely";
}
this.log.debug("Connection can be kept alive " + s);
}
if (keepalive > 0) {
- this.expiry = this.updated + tunit.toMillis(keepalive);
+ this.expiry = this.updated + timeUnit.toMillis(keepalive);
} else {
this.expiry = Long.MAX_VALUE;
}
@@ -343,13 +343,13 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
}
@Override
- public synchronized void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
+ public synchronized void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
if (this.isShutdown.get()) {
return;
}
if (!this.leased) {
- long time = tunit.toMillis(idletime);
+ long time = timeUnit.toMillis(idletime);
if (time < 0) {
time = 0;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java b/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
index eee9b78..603fd72 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/CPool.java
@@ -49,21 +49,21 @@ class CPool extends AbstractConnPool<HttpRoute, ManagedHttpClientConnection, CPo
private final Log log = LogFactory.getLog(CPool.class);
private final long timeToLive;
- private final TimeUnit tunit;
+ private final TimeUnit timeUnit;
public CPool(
final ConnFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
final int defaultMaxPerRoute, final int maxTotal,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
super(connFactory, defaultMaxPerRoute, maxTotal);
this.timeToLive = timeToLive;
- this.tunit = tunit;
+ this.timeUnit = timeUnit;
}
@Override
protected CPoolEntry createEntry(final HttpRoute route, final ManagedHttpClientConnection conn) {
final String id = Long.toString(COUNTER.getAndIncrement());
- return new CPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
+ return new CPoolEntry(this.log, id, route, conn, this.timeToLive, this.timeUnit);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
index cb89d27..bf122c8 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
@@ -52,8 +52,8 @@ class CPoolEntry extends PoolEntry<HttpRoute, ManagedHttpClientConnection> {
final String id,
final HttpRoute route,
final ManagedHttpClientConnection conn,
- final long timeToLive, final TimeUnit tunit) {
- super(id, route, conn, timeToLive, tunit);
+ final long timeToLive, final TimeUnit timeUnit) {
+ super(id, route, conn, timeToLive, timeUnit);
this.log = log;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
index 8c8f623..23197c2 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/CPoolProxy.java
@@ -98,21 +98,13 @@ class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
@Override
public boolean isOpen() {
final CPoolEntry local = this.poolEntry;
- if (local != null) {
- return !local.isClosed();
- } else {
- return false;
- }
+ return local != null ? !local.isClosed() : false;
}
@Override
public boolean isStale() {
final HttpClientConnection conn = getConnection();
- if (conn != null) {
- return conn.isStale();
- } else {
- return true;
- }
+ return conn != null ? conn.isStale() : true;
}
@Override
@@ -203,11 +195,7 @@ class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
@Override
public Object getAttribute(final String id) {
final ManagedHttpClientConnection conn = getValidConnection();
- if (conn instanceof HttpContext) {
- return ((HttpContext) conn).getAttribute(id);
- } else {
- return null;
- }
+ return conn instanceof HttpContext ? ((HttpContext) conn).getAttribute(id) : null;
}
@Override
@@ -221,11 +209,7 @@ class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
@Override
public Object removeAttribute(final String id) {
final ManagedHttpClientConnection conn = getValidConnection();
- if (conn instanceof HttpContext) {
- return ((HttpContext) conn).removeAttribute(id);
- } else {
- return null;
- }
+ return conn instanceof HttpContext ? ((HttpContext) conn).removeAttribute(id) : null;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
index 76af8e8..b84737a 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
@@ -153,11 +153,9 @@ public class DefaultHttpClientConnectionOperator implements HttpClientConnection
} catch (final ConnectException ex) {
if (last) {
final String msg = ex.getMessage();
- if ("Connection timed out".equals(msg)) {
- throw new ConnectTimeoutException(ex, host, addresses);
- } else {
- throw new HttpHostConnectException(ex, host, addresses);
- }
+ throw "Connection timed out".equals(msg)
+ ? new ConnectTimeoutException(ex, host, addresses)
+ : new HttpHostConnectException(ex, host, addresses);
}
} catch (final NoRouteToHostException ex) {
if (last) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java
index 1a74f5e..73e827c 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultManagedHttpClientConnection.java
@@ -62,16 +62,16 @@ public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnec
public DefaultManagedHttpClientConnection(
final String id,
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
- super(buffersize, fragmentSizeHint, chardecoder, charencoder,
+ super(bufferSize, fragmentSizeHint, charDecoder, charEncoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.id = id;
@@ -80,8 +80,8 @@ public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnec
public DefaultManagedHttpClientConnection(
final String id,
- final int buffersize) {
- this(id, buffersize, buffersize, null, null, null, null, null, null, null);
+ final int bufferSize) {
+ this(id, bufferSize, bufferSize, null, null, null, null, null, null, null);
}
@Override
@@ -128,11 +128,7 @@ public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnec
@Override
public SSLSession getSSLSession() {
final Socket socket = super.getSocket();
- if (socket instanceof SSLSocket) {
- return ((SSLSocket) socket).getSession();
- } else {
- return null;
- }
+ return socket instanceof SSLSocket ? ((SSLSocket) socket).getSession() : null;
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
index 3652115..6bc8174 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
@@ -92,11 +92,9 @@ public class DefaultRoutePlanner implements HttpRoutePlanner {
target = host;
}
final boolean secure = target.getSchemeName().equalsIgnoreCase("https");
- if (proxy == null) {
- return new HttpRoute(target, local, secure);
- } else {
- return new HttpRoute(target, local, proxy, secure);
- }
+ return proxy == null
+ ? new HttpRoute(target, local, secure)
+ : new HttpRoute(target, local, proxy, secure);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
index 6d3b34f..24a7ad8 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
@@ -46,29 +46,29 @@ import org.apache.http.io.HttpMessageWriterFactory;
class LoggingManagedHttpClientConnection extends DefaultManagedHttpClientConnection {
private final Log log;
- private final Log headerlog;
+ private final Log headerLog;
private final Wire wire;
public LoggingManagedHttpClientConnection(
final String id,
final Log log,
- final Log headerlog,
- final Log wirelog,
- final int buffersize,
+ final Log headerLog,
+ final Log wireLog,
+ final int bufferSize,
final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final HttpMessageParserFactory<HttpResponse> responseParserFactory) {
- super(id, buffersize, fragmentSizeHint, chardecoder, charencoder,
+ super(id, bufferSize, fragmentSizeHint, charDecoder, charEncoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.log = log;
- this.headerlog = headerlog;
- this.wire = new Wire(wirelog, id);
+ this.headerLog = headerLog;
+ this.wire = new Wire(wireLog, id);
}
@Override
@@ -118,22 +118,22 @@ class LoggingManagedHttpClientConnection extends DefaultManagedHttpClientConnect
@Override
protected void onResponseReceived(final HttpResponse response) {
- if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(getId() + " << " + response.getStatusLine().toString());
+ if (response != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(getId() + " << " + response.getStatusLine().toString());
final Header[] headers = response.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(getId() + " << " + header.toString());
+ this.headerLog.debug(getId() + " << " + header.toString());
}
}
}
@Override
protected void onRequestSubmitted(final HttpRequest request) {
- if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(getId() + " >> " + request.getRequestLine().toString());
+ if (request != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(getId() + " >> " + request.getRequestLine().toString());
final Header[] headers = request.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(getId() + " >> " + header.toString());
+ this.headerLog.debug(getId() + " >> " + header.toString());
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java b/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
index 7057c3e..ff40295 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
@@ -63,8 +63,8 @@ public class ManagedHttpClientConnectionFactory
public static final ManagedHttpClientConnectionFactory INSTANCE = new ManagedHttpClientConnectionFactory();
private final Log log = LogFactory.getLog(DefaultManagedHttpClientConnection.class);
- private final Log headerlog = LogFactory.getLog("org.apache.http.headers");
- private final Log wirelog = LogFactory.getLog("org.apache.http.wire");
+ private final Log headerLog = LogFactory.getLog("org.apache.http.headers");
+ private final Log wireLog = LogFactory.getLog("org.apache.http.wire");
private final HttpMessageWriterFactory<HttpRequest> requestWriterFactory;
private final HttpMessageParserFactory<HttpResponse> responseParserFactory;
@@ -108,31 +108,31 @@ public class ManagedHttpClientConnectionFactory
@Override
public ManagedHttpClientConnection create(final HttpRoute route, final ConnectionConfig config) {
final ConnectionConfig cconfig = config != null ? config : ConnectionConfig.DEFAULT;
- CharsetDecoder chardecoder = null;
- CharsetEncoder charencoder = null;
+ CharsetDecoder charDecoder = null;
+ CharsetEncoder charEncoder = null;
final Charset charset = cconfig.getCharset();
final CodingErrorAction malformedInputAction = cconfig.getMalformedInputAction() != null ?
cconfig.getMalformedInputAction() : CodingErrorAction.REPORT;
final CodingErrorAction unmappableInputAction = cconfig.getUnmappableInputAction() != null ?
cconfig.getUnmappableInputAction() : CodingErrorAction.REPORT;
if (charset != null) {
- chardecoder = charset.newDecoder();
- chardecoder.onMalformedInput(malformedInputAction);
- chardecoder.onUnmappableCharacter(unmappableInputAction);
- charencoder = charset.newEncoder();
- charencoder.onMalformedInput(malformedInputAction);
- charencoder.onUnmappableCharacter(unmappableInputAction);
+ charDecoder = charset.newDecoder();
+ charDecoder.onMalformedInput(malformedInputAction);
+ charDecoder.onUnmappableCharacter(unmappableInputAction);
+ charEncoder = charset.newEncoder();
+ charEncoder.onMalformedInput(malformedInputAction);
+ charEncoder.onUnmappableCharacter(unmappableInputAction);
}
final String id = "http-outgoing-" + Long.toString(COUNTER.getAndIncrement());
return new LoggingManagedHttpClientConnection(
id,
log,
- headerlog,
- wirelog,
+ headerLog,
+ wireLog,
cconfig.getBufferSize(),
cconfig.getFragmentSizeHint(),
- chardecoder,
- charencoder,
+ charDecoder,
+ charEncoder,
cconfig.getMessageConstraints(),
incomingContentStrategy,
outgoingContentStrategy,
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
index b20e024..4c38bd8 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
@@ -121,8 +121,8 @@ public class PoolingHttpClientConnectionManager
this(getDefaultRegistry());
}
- public PoolingHttpClientConnectionManager(final long timeToLive, final TimeUnit tunit) {
- this(getDefaultRegistry(), null, null ,null, timeToLive, tunit);
+ public PoolingHttpClientConnectionManager(final long timeToLive, final TimeUnit timeUnit) {
+ this(getDefaultRegistry(), null, null ,null, timeToLive, timeUnit);
}
public PoolingHttpClientConnectionManager(
@@ -159,11 +159,11 @@ public class PoolingHttpClientConnectionManager
final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
final SchemePortResolver schemePortResolver,
final DnsResolver dnsResolver,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
this(
new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver, dnsResolver),
connFactory,
- timeToLive, tunit
+ timeToLive, timeUnit
);
}
@@ -173,11 +173,11 @@ public class PoolingHttpClientConnectionManager
public PoolingHttpClientConnectionManager(
final HttpClientConnectionOperator httpClientConnectionOperator,
final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
super();
this.configData = new ConfigData();
this.pool = new CPool(new InternalConnectionFactory(
- this.configData, connFactory), 2, 20, timeToLive, tunit);
+ this.configData, connFactory), 2, 20, timeToLive, timeUnit);
this.pool.setValidateAfterInactivity(2000);
this.connectionOperator = Args.notNull(httpClientConnectionOperator, "HttpClientConnectionOperator");
this.isShutDown = new AtomicBoolean(false);
@@ -275,8 +275,8 @@ public class PoolingHttpClientConnectionManager
@Override
public HttpClientConnection get(
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
- final HttpClientConnection conn = leaseConnection(future, timeout, tunit);
+ final TimeUnit timeUnit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
+ final HttpClientConnection conn = leaseConnection(future, timeout, timeUnit);
if (conn.isOpen()) {
final HttpHost host;
if (route.getProxyHost() != null) {
@@ -297,10 +297,10 @@ public class PoolingHttpClientConnectionManager
protected HttpClientConnection leaseConnection(
final Future<CPoolEntry> future,
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
+ final TimeUnit timeUnit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
final CPoolEntry entry;
try {
- entry = future.get(timeout, tunit);
+ entry = future.get(timeout, timeUnit);
if (entry == null || future.isCancelled()) {
throw new InterruptedException();
}
@@ -318,7 +318,7 @@ public class PoolingHttpClientConnectionManager
public void releaseConnection(
final HttpClientConnection managedConn,
final Object state,
- final long keepalive, final TimeUnit tunit) {
+ final long keepalive, final TimeUnit timeUnit) {
Args.notNull(managedConn, "Managed connection");
synchronized (managedConn) {
final CPoolEntry entry = CPoolProxy.detach(managedConn);
@@ -328,7 +328,7 @@ public class PoolingHttpClientConnectionManager
final ManagedHttpClientConnection conn = entry.getConnection();
try {
if (conn.isOpen()) {
- final TimeUnit effectiveUnit = tunit != null ? tunit : TimeUnit.MILLISECONDS;
+ final TimeUnit effectiveUnit = timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS;
entry.setState(state);
entry.updateExpiry(keepalive, effectiveUnit);
if (this.log.isDebugEnabled()) {
@@ -416,11 +416,11 @@ public class PoolingHttpClientConnectionManager
}
@Override
- public void closeIdleConnections(final long idleTimeout, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idleTimeout, final TimeUnit timeUnit) {
if (this.log.isDebugEnabled()) {
- this.log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
+ this.log.debug("Closing connections idle longer than " + idleTimeout + " " + timeUnit);
}
- this.pool.closeIdle(idleTimeout, tunit);
+ this.pool.closeIdle(idleTimeout, timeUnit);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java b/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
index 48195e5..07b2e77 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
@@ -59,11 +59,11 @@ public class Wire {
this(log, "");
}
- private void wire(final String header, final InputStream instream)
+ private void wire(final String header, final InputStream inStream)
throws IOException {
final StringBuilder buffer = new StringBuilder();
int ch;
- while ((ch = instream.read()) != -1) {
+ while ((ch = inStream.read()) != -1) {
if (ch == 13) {
buffer.append("[\\r]");
} else if (ch == 10) {
@@ -93,16 +93,16 @@ public class Wire {
return log.isDebugEnabled();
}
- public void output(final InputStream outstream)
+ public void output(final InputStream outStream)
throws IOException {
- Args.notNull(outstream, "Output");
- wire(">> ", outstream);
+ Args.notNull(outStream, "Output");
+ wire(">> ", outStream);
}
- public void input(final InputStream instream)
+ public void input(final InputStream inStream)
throws IOException {
- Args.notNull(instream, "Input");
- wire("<< ", instream);
+ Args.notNull(inStream, "Input");
+ wire("<< ", inStream);
}
public void output(final byte[] b, final int off, final int len)
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
index c291f1c..72770a6 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/DefaultCookieSpec.java
@@ -105,14 +105,14 @@ public class DefaultCookieSpec implements CookieSpec {
final CookieOrigin origin) throws MalformedCookieException {
Args.notNull(header, "Header");
Args.notNull(origin, "Cookie origin");
- HeaderElement[] helems = header.getElements();
+ HeaderElement[] hElems = header.getElements();
boolean versioned = false;
boolean netscape = false;
- for (final HeaderElement helem: helems) {
- if (helem.getParameterByName("version") != null) {
+ for (final HeaderElement hElem: hElems) {
+ if (hElem.getParameterByName("version") != null) {
versioned = true;
}
- if (helem.getParameterByName("expires") != null) {
+ if (hElem.getParameterByName("expires") != null) {
netscape = true;
}
}
@@ -128,23 +128,20 @@ public class DefaultCookieSpec implements CookieSpec {
((FormattedHeader) header).getValuePos(),
buffer.length());
} else {
- final String s = header.getValue();
- if (s == null) {
+ final String hValue = header.getValue();
+ if (hValue == null) {
throw new MalformedCookieException("Header value is null");
}
- buffer = new CharArrayBuffer(s.length());
- buffer.append(s);
+ buffer = new CharArrayBuffer(hValue.length());
+ buffer.append(hValue);
cursor = new ParserCursor(0, buffer.length());
}
- helems = new HeaderElement[] { parser.parseHeader(buffer, cursor) };
- return netscapeDraft.parse(helems, origin);
- } else {
- if (SM.SET_COOKIE2.equals(header.getName())) {
- return strict.parse(helems, origin);
- } else {
- return obsoleteStrict.parse(helems, origin);
- }
+ hElems = new HeaderElement[] { parser.parseHeader(buffer, cursor) };
+ return netscapeDraft.parse(hElems, origin);
}
+ return SM.SET_COOKIE2.equals(header.getName())
+ ? strict.parse(hElems, origin)
+ : obsoleteStrict.parse(hElems, origin);
}
@Override
@@ -169,14 +166,11 @@ public class DefaultCookieSpec implements CookieSpec {
Args.notNull(cookie, "Cookie");
Args.notNull(origin, "Cookie origin");
if (cookie.getVersion() > 0) {
- if (cookie instanceof SetCookie2) {
- return strict.match(cookie, origin);
- } else {
- return obsoleteStrict.match(cookie, origin);
- }
- } else {
- return netscapeDraft.match(cookie, origin);
+ return cookie instanceof SetCookie2
+ ? strict.match(cookie, origin)
+ : obsoleteStrict.match(cookie, origin);
}
+ return netscapeDraft.match(cookie, origin);
}
@Override
@@ -193,14 +187,11 @@ public class DefaultCookieSpec implements CookieSpec {
}
}
if (version > 0) {
- if (isSetCookie2) {
- return strict.formatCookies(cookies);
- } else {
- return obsoleteStrict.formatCookies(cookies);
- }
- } else {
- return netscapeDraft.formatCookies(cookies);
+ return isSetCookie2
+ ? strict.formatCookies(cookies)
+ : obsoleteStrict.formatCookies(cookies);
}
+ return netscapeDraft.formatCookies(cookies);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java b/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java
index 8043bb4..02fdbdc 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/LaxExpiresHandler.java
@@ -205,10 +205,9 @@ public class LaxExpiresHandler extends AbstractCookieAttributeHandler implements
final char current = buf.charAt(i);
if (DELIMS.get(current)) {
break;
- } else {
- pos++;
- dst.append(current);
}
+ pos++;
+ dst.append(current);
}
cursor.updatePos(pos);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
index dbc205e..429782e 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
@@ -143,11 +143,7 @@ public class RFC2109Spec extends CookieSpecBase {
} else {
cookieList = cookies;
}
- if (this.oneHeader) {
- return doFormatOneHeader(cookieList);
- } else {
- return doFormatManyHeaders(cookieList);
- }
+ return this.oneHeader ? doFormatOneHeader(cookieList) : doFormatManyHeaders(cookieList);
}
private List<Header> doFormatOneHeader(final List<Cookie> cookies) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
index 5fca006..5b77164 100644
--- a/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
+++ b/httpclient/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
@@ -64,7 +64,6 @@ public class RFC2965Spec extends RFC2109Spec {
/**
* Default constructor
- *
*/
public RFC2965Spec() {
this(null, false);
@@ -222,7 +221,7 @@ public class RFC2965Spec extends RFC2109Spec {
* @param origin origin where cookie is received from or being sent to.
*/
private static CookieOrigin adjustEffectiveHost(final CookieOrigin origin) {
- String host = origin.getHost();
+ final String host = origin.getHost();
// Test if the host name appears to be a fully qualified DNS name,
// IPv4 address or IPv6 address
@@ -234,16 +233,13 @@ public class RFC2965Spec extends RFC2109Spec {
break;
}
}
- if (isLocalHost) {
- host += ".local";
- return new CookieOrigin(
- host,
- origin.getPort(),
- origin.getPath(),
- origin.isSecure());
- } else {
- return origin;
- }
+ return isLocalHost
+ ? new CookieOrigin(
+ host + ".local",
+ origin.getPort(),
+ origin.getPath(),
+ origin.isSecure())
+ : origin;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
index daa5a31..c102f91 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
@@ -56,7 +56,7 @@ class ConnectionHolder implements ConnectionReleaseTrigger, Cancellable, Closeab
private volatile boolean reusable;
private volatile Object state;
private volatile long validDuration;
- private volatile TimeUnit tunit;
+ private volatile TimeUnit timeUnit;
public ConnectionHolder(
final Log log,
@@ -85,10 +85,10 @@ class ConnectionHolder implements ConnectionReleaseTrigger, Cancellable, Closeab
this.state = state;
}
- public void setValidFor(final long duration, final TimeUnit tunit) {
+ public void setValidFor(final long duration, final TimeUnit timeUnit) {
synchronized (this.managedConn) {
this.validDuration = duration;
- this.tunit = tunit;
+ this.timeUnit = timeUnit;
}
}
@@ -97,7 +97,7 @@ class ConnectionHolder implements ConnectionReleaseTrigger, Cancellable, Closeab
synchronized (this.managedConn) {
if (reusable) {
this.manager.releaseConnection(this.managedConn,
- this.state, this.validDuration, this.tunit);
+ this.state, this.validDuration, this.timeUnit);
} else {
try {
this.managedConn.close();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java b/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java
index 1affd94..e5bba36 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/RequestEntityProxy.java
@@ -116,9 +116,9 @@ class RequestEntityProxy implements HttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
+ public void writeTo(final OutputStream outStream) throws IOException {
consumed = true;
- original.writeTo(outstream);
+ original.writeTo(outStream);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java b/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java
index 6f53c23..47c5ac9 100644
--- a/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/execchain/ResponseEntityProxy.java
@@ -94,10 +94,10 @@ class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
+ public void writeTo(final OutputStream outStream) throws IOException {
try {
- if (outstream != null) {
- this.wrappedEntity.writeTo(outstream);
+ if (outStream != null) {
+ this.wrappedEntity.writeTo(outStream);
}
releaseConnection();
} catch (final IOException ex) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java b/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java
index 10564a0..937acc4 100644
--- a/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java
+++ b/httpclient/src/test/java/org/apache/http/auth/TestCredentials.java
@@ -203,13 +203,13 @@ public class TestCredentials {
public void testUsernamePasswordCredentialsSerialization() throws Exception {
final UsernamePasswordCredentials orig = new UsernamePasswordCredentials("name", "pwd");
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final UsernamePasswordCredentials clone = (UsernamePasswordCredentials) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final UsernamePasswordCredentials clone = (UsernamePasswordCredentials) inStream.readObject();
Assert.assertEquals(orig, clone);
}
@@ -217,13 +217,13 @@ public class TestCredentials {
public void testNTCredentialsSerialization() throws Exception {
final NTCredentials orig = new NTCredentials("name", "pwd", "somehost", "domain");
final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream();
- final ObjectOutputStream outstream = new ObjectOutputStream(outbuffer);
- outstream.writeObject(orig);
- outstream.close();
+ final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer);
+ outStream.writeObject(orig);
+ outStream.close();
final byte[] raw = outbuffer.toByteArray();
- final ByteArrayInputStream inbuffer = new ByteArrayInputStream(raw);
- final ObjectInputStream instream = new ObjectInputStream(inbuffer);
- final NTCredentials clone = (NTCredentials) instream.readObject();
+ final ByteArrayInputStream inBuffer = new ByteArrayInputStream(raw);
+ final ObjectInputStream inStream = new ObjectInputStream(inBuffer);
+ final NTCredentials clone = (NTCredentials) inStream.readObject();
Assert.assertEquals(orig, clone);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java b/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java
index 347d99d..b36a609 100644
--- a/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java
+++ b/httpclient/src/test/java/org/apache/http/client/entity/TestDecompressingEntity.java
@@ -97,8 +97,8 @@ public class TestDecompressingEntity {
super(wrapped, new InputStreamFactory() {
@Override
- public InputStream create(final InputStream instream) throws IOException {
- return new CheckedInputStream(instream, checksum);
+ public InputStream create(final InputStream inStream) throws IOException {
+ return new CheckedInputStream(inStream, checksum);
}
});
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java b/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
index 2f9ba9a..516299d 100644
--- a/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
+++ b/httpclient/src/test/java/org/apache/http/client/entity/TestGZip.java
@@ -41,6 +41,7 @@ import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.junit.Assert;
import org.junit.Test;
+import org.mockito.Matchers;
import org.mockito.Mockito;
public class TestGZip {
@@ -71,7 +72,7 @@ public class TestGZip {
@Test
public void testCompressionIOExceptionLeavesOutputStreamOpen() throws Exception {
final HttpEntity in = Mockito.mock(HttpEntity.class);
- Mockito.doThrow(new IOException("Ooopsie")).when(in).writeTo(Mockito.<OutputStream>any());
+ Mockito.doThrow(new IOException("Ooopsie")).when(in).writeTo(Matchers.<OutputStream>any());
final GzipCompressingEntity gzipe = new GzipCompressingEntity(in);
final OutputStream out = Mockito.mock(OutputStream.class);
try {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java b/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
index 51a794e..2165387 100644
--- a/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
+++ b/httpclient/src/test/java/org/apache/http/client/methods/TestHttpRequestBase.java
@@ -97,8 +97,8 @@ public class TestHttpRequestBase {
@Test(expected=CloneNotSupportedException.class)
public void testCloneStreamingEntityEnclosingRequests() throws Exception {
- final ByteArrayInputStream instream = new ByteArrayInputStream(new byte[] {});
- final InputStreamEntity e2 = new InputStreamEntity(instream, -1);
+ final ByteArrayInputStream inStream = new ByteArrayInputStream(new byte[] {});
+ final InputStreamEntity e2 = new InputStreamEntity(inStream, -1);
final HttpPost httppost = new HttpPost("http://host/path");
httppost.setEntity(e2);
httppost.clone();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
index 1c8cf42..4854f52 100644
--- a/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
+++ b/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAddCookies.java
@@ -57,6 +57,7 @@ import org.apache.http.protocol.HttpCoreContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Matchers;
import org.mockito.Mockito;
public class TestRequestAddCookies {
@@ -402,7 +403,7 @@ public class TestRequestAddCookies {
Assert.assertNotNull(headers2);
Assert.assertEquals(0, headers2.length);
- Mockito.verify(this.cookieStore, Mockito.times(1)).clearExpired(Mockito.<Date>any());
+ Mockito.verify(this.cookieStore, Mockito.times(1)).clearExpired(Matchers.<Date>any());
}
@Test
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java b/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
index b1fa88d..f8d778f 100644
--- a/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
+++ b/httpclient/src/test/java/org/apache/http/client/utils/TestHttpClientUtils.java
@@ -66,22 +66,22 @@ public class TestHttpClientUtils {
public void testCloseQuietlyResponseEntity() throws Exception {
final HttpResponse response = Mockito.mock(HttpResponse.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class);
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.isStreaming()).thenReturn(Boolean.TRUE);
- Mockito.when(entity.getContent()).thenReturn(instream);
+ Mockito.when(entity.getContent()).thenReturn(inStream);
HttpClientUtils.closeQuietly(response);
- Mockito.verify(instream).close();
+ Mockito.verify(inStream).close();
}
@Test
public void testCloseQuietlyResponseIgnoreIOError() throws Exception {
final HttpResponse response = Mockito.mock(HttpResponse.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class);
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity);
- Mockito.when(entity.getContent()).thenReturn(instream);
- Mockito.doThrow(new IOException()).when(instream).close();
+ Mockito.when(entity.getContent()).thenReturn(inStream);
+ Mockito.doThrow(new IOException()).when(inStream).close();
HttpClientUtils.closeQuietly(response);
}
@@ -114,12 +114,12 @@ public class TestHttpClientUtils {
public void testCloseQuietlyCloseableResponseEntity() throws Exception {
final CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class);
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity);
Mockito.when(entity.isStreaming()).thenReturn(Boolean.TRUE);
- Mockito.when(entity.getContent()).thenReturn(instream);
+ Mockito.when(entity.getContent()).thenReturn(inStream);
HttpClientUtils.closeQuietly(response);
- Mockito.verify(instream).close();
+ Mockito.verify(inStream).close();
Mockito.verify(response).close();
}
@@ -127,10 +127,10 @@ public class TestHttpClientUtils {
public void testCloseQuietlyCloseableResponseIgnoreIOError() throws Exception {
final CloseableHttpResponse response = Mockito.mock(CloseableHttpResponse.class);
final HttpEntity entity = Mockito.mock(HttpEntity.class);
- final InputStream instream = Mockito.mock(InputStream.class);
+ final InputStream inStream = Mockito.mock(InputStream.class);
Mockito.when(response.getEntity()).thenReturn(entity);
- Mockito.when(entity.getContent()).thenReturn(instream);
- Mockito.doThrow(new IOException()).when(instream).close();
+ Mockito.when(entity.getContent()).thenReturn(inStream);
+ Mockito.doThrow(new IOException()).when(inStream).close();
HttpClientUtils.closeQuietly(response);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/conn/TestEofSensorInputStream.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/conn/TestEofSensorInputStream.java b/httpclient/src/test/java/org/apache/http/conn/TestEofSensorInputStream.java
index 396f431..7770e77 100644
--- a/httpclient/src/test/java/org/apache/http/conn/TestEofSensorInputStream.java
+++ b/httpclient/src/test/java/org/apache/http/conn/TestEofSensorInputStream.java
@@ -37,15 +37,15 @@ import org.mockito.Mockito;
@SuppressWarnings({"boxing","static-access"}) // test code
public class TestEofSensorInputStream {
- private InputStream instream;
+ private InputStream inStream;
private EofSensorWatcher eofwatcher;
private EofSensorInputStream eofstream;
@Before
public void setup() throws Exception {
- instream = Mockito.mock(InputStream.class);
+ inStream = Mockito.mock(InputStream.class);
eofwatcher = Mockito.mock(EofSensorWatcher.class);
- eofstream = new EofSensorInputStream(instream, eofwatcher);
+ eofstream = new EofSensorInputStream(inStream, eofwatcher);
}
@Test
@@ -57,8 +57,8 @@ public class TestEofSensorInputStream {
Assert.assertTrue(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(instream, Mockito.times(1)).close();
- Mockito.verify(eofwatcher).streamClosed(instream);
+ Mockito.verify(inStream, Mockito.times(1)).close();
+ Mockito.verify(eofwatcher).streamClosed(inStream);
eofstream.close();
}
@@ -75,7 +75,7 @@ public class TestEofSensorInputStream {
Assert.assertTrue(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(eofwatcher).streamClosed(instream);
+ Mockito.verify(eofwatcher).streamClosed(inStream);
}
@Test
@@ -87,8 +87,8 @@ public class TestEofSensorInputStream {
Assert.assertTrue(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(instream, Mockito.times(1)).close();
- Mockito.verify(eofwatcher).streamClosed(instream);
+ Mockito.verify(inStream, Mockito.times(1)).close();
+ Mockito.verify(eofwatcher).streamClosed(inStream);
eofstream.releaseConnection();
}
@@ -102,8 +102,8 @@ public class TestEofSensorInputStream {
Assert.assertTrue(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(instream, Mockito.times(1)).close();
- Mockito.verify(eofwatcher).streamAbort(instream);
+ Mockito.verify(inStream, Mockito.times(1)).close();
+ Mockito.verify(eofwatcher).streamAbort(inStream);
eofstream.abortConnection();
}
@@ -120,28 +120,28 @@ public class TestEofSensorInputStream {
Assert.assertTrue(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(eofwatcher).streamAbort(instream);
+ Mockito.verify(eofwatcher).streamAbort(inStream);
}
@Test
public void testRead() throws Exception {
Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
- Mockito.when(instream.read()).thenReturn(0, -1);
+ Mockito.when(inStream.read()).thenReturn(0, -1);
Assert.assertEquals(0, eofstream.read());
Assert.assertFalse(eofstream.isSelfClosed());
Assert.assertNotNull(eofstream.getWrappedStream());
- Mockito.verify(eofwatcher, Mockito.never()).eofDetected(instream);
+ Mockito.verify(eofwatcher, Mockito.never()).eofDetected(inStream);
Assert.assertEquals(-1, eofstream.read());
Assert.assertFalse(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(instream, Mockito.times(1)).close();
- Mockito.verify(eofwatcher).eofDetected(instream);
+ Mockito.verify(inStream, Mockito.times(1)).close();
+ Mockito.verify(eofwatcher).eofDetected(inStream);
Assert.assertEquals(-1, eofstream.read());
}
@@ -149,7 +149,7 @@ public class TestEofSensorInputStream {
@Test
public void testReadIOError() throws Exception {
Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
- Mockito.when(instream.read()).thenThrow(new IOException());
+ Mockito.when(inStream.read()).thenThrow(new IOException());
try {
eofstream.read();
@@ -159,13 +159,13 @@ public class TestEofSensorInputStream {
Assert.assertFalse(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(eofwatcher).streamAbort(instream);
+ Mockito.verify(eofwatcher).streamAbort(inStream);
}
@Test
public void testReadByteArray() throws Exception {
Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
- Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
+ Mockito.when(inStream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
.thenReturn(1, -1);
final byte[] tmp = new byte[1];
@@ -175,15 +175,15 @@ public class TestEofSensorInputStream {
Assert.assertFalse(eofstream.isSelfClosed());
Assert.assertNotNull(eofstream.getWrappedStream());
- Mockito.verify(eofwatcher, Mockito.never()).eofDetected(instream);
+ Mockito.verify(eofwatcher, Mockito.never()).eofDetected(inStream);
Assert.assertEquals(-1, eofstream.read(tmp));
Assert.assertFalse(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(instream, Mockito.times(1)).close();
- Mockito.verify(eofwatcher).eofDetected(instream);
+ Mockito.verify(inStream, Mockito.times(1)).close();
+ Mockito.verify(eofwatcher).eofDetected(inStream);
Assert.assertEquals(-1, eofstream.read(tmp));
}
@@ -191,7 +191,7 @@ public class TestEofSensorInputStream {
@Test
public void testReadByteArrayIOError() throws Exception {
Mockito.when(eofwatcher.eofDetected(Mockito.<InputStream>any())).thenReturn(Boolean.TRUE);
- Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
+ Mockito.when(inStream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
.thenThrow(new IOException());
final byte[] tmp = new byte[1];
@@ -203,7 +203,7 @@ public class TestEofSensorInputStream {
Assert.assertFalse(eofstream.isSelfClosed());
Assert.assertNull(eofstream.getWrappedStream());
- Mockito.verify(eofwatcher).streamAbort(instream);
+ Mockito.verify(eofwatcher).streamAbort(inStream);
}
@Test
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/e6c226d5/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java b/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java
index d8a4c3d..299e191 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/MockConnPoolControl.java
@@ -85,11 +85,7 @@ public final class MockConnPoolControl implements ConnPoolControl<HttpRoute> {
@Override
public int getMaxPerRoute(final HttpRoute route) {
final Integer max = this.maxPerHostMap.get(route);
- if (max != null) {
- return max.intValue();
- } else {
- return this.defaultMax;
- }
+ return max != null ? max.intValue() : this.defaultMax;
}
public void setMaxForRoutes(final Map<HttpRoute, Integer> map) {