You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2018/08/14 14:56:21 UTC
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.)
Repository: httpcomponents-client
Updated Branches:
refs/heads/4.5.x 2232fc144 -> 12bf4c1aa
- 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.)
Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/12bf4c1a
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/12bf4c1a
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/12bf4c1a
Branch: refs/heads/4.5.x
Commit: 12bf4c1aaab88e0d4ed1dbeb11ae008b9d61c0cc
Parents: 2232fc1
Author: Gary Gregory <ga...@gmail.com>
Authored: Tue Aug 14 08:56:17 2018 -0600
Committer: Gary Gregory <ga...@gmail.com>
Committed: Tue Aug 14 08:56:17 2018 -0600
----------------------------------------------------------------------
.../impl/conn/BasicClientConnectionManager.java | 14 ++++-----
.../org/apache/http/impl/conn/HttpConnPool.java | 8 ++---
.../apache/http/impl/conn/HttpPoolEntry.java | 4 +--
.../conn/PoolingClientConnectionManager.java | 28 +++++++++---------
.../http/impl/conn/SingleClientConnManager.java | 8 ++---
.../http/impl/conn/tsccm/AbstractConnPool.java | 14 ++++-----
.../http/impl/conn/tsccm/ConnPoolByRoute.java | 20 ++++++-------
.../http/impl/conn/tsccm/PoolEntryRequest.java | 4 +--
.../conn/tsccm/ThreadSafeClientConnManager.java | 10 +++----
.../apache/http/auth/AuthSchemeRegistry.java | 3 +-
.../http/client/entity/DecompressingEntity.java | 3 +-
.../apache/http/client/utils/CloneUtils.java | 6 ++--
.../http/conn/ClientConnectionManager.java | 4 +--
.../http/conn/ClientConnectionRequest.java | 4 +--
.../org/apache/http/conn/ConnectionRequest.java | 4 +--
.../http/conn/HttpClientConnectionManager.java | 4 +--
.../apache/http/conn/ssl/AbstractVerifier.java | 3 +-
.../apache/http/cookie/CookieSpecRegistry.java | 3 +-
.../apache/http/impl/auth/AuthSchemeBase.java | 6 +---
.../apache/http/impl/client/BasicAuthCache.java | 6 ++--
.../client/DefaultHttpRequestRetryHandler.java | 9 +++---
.../http/impl/client/IdleConnectionEvictor.java | 4 +--
.../http/impl/client/InternalHttpClient.java | 4 +--
.../http/impl/client/MinimalHttpClient.java | 4 +--
.../conn/BasicHttpClientConnectionManager.java | 14 ++++-----
.../java/org/apache/http/impl/conn/CPool.java | 8 ++---
.../org/apache/http/impl/conn/CPoolEntry.java | 4 +--
.../org/apache/http/impl/conn/CPoolProxy.java | 24 +++------------
.../DefaultHttpClientConnectionOperator.java | 8 ++---
.../DefaultManagedHttpClientConnection.java | 6 ++--
.../LoggingManagedHttpClientConnection.java | 28 +++++++++---------
.../ManagedHttpClientConnectionFactory.java | 28 +++++++++---------
.../PoolingHttpClientConnectionManager.java | 30 +++++++++----------
.../http/impl/cookie/DefaultCookieSpec.java | 31 +++++++-------------
.../http/impl/execchain/ConnectionHolder.java | 8 ++---
.../client/integration/TestAbortHandling.java | 12 ++++----
36 files changed, 169 insertions(+), 209 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java
index 3e158ab..4a70eff 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/BasicClientConnectionManager.java
@@ -141,7 +141,7 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
@Override
public ManagedClientConnection getConnection(
- final long timeout, final TimeUnit tunit) {
+ final long timeout, final TimeUnit timeUnit) {
return BasicClientConnectionManager.this.getConnection(
route, state);
}
@@ -191,7 +191,7 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
}
@Override
- public void releaseConnection(final ManagedClientConnection conn, final long keepalive, final TimeUnit tunit) {
+ public void releaseConnection(final ManagedClientConnection conn, final long keepalive, final TimeUnit timeUnit) {
Args.check(conn instanceof ManagedClientConnectionImpl, "Connection class mismatch, " +
"connection not obtained from this manager");
final ManagedClientConnectionImpl managedConn = (ManagedClientConnectionImpl) conn;
@@ -214,11 +214,11 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
shutdownConnection(managedConn);
}
if (managedConn.isMarkedReusable()) {
- this.poolEntry.updateExpiry(keepalive, tunit != null ? tunit : TimeUnit.MILLISECONDS);
+ this.poolEntry.updateExpiry(keepalive, timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS);
if (this.log.isDebugEnabled()) {
final String s;
if (keepalive > 0) {
- s = "for " + keepalive + " " + tunit;
+ s = "for " + keepalive + " " + timeUnit;
} else {
s = "indefinitely";
}
@@ -249,11 +249,11 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
synchronized (this) {
assertNotShutdown();
- 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/12bf4c1a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpConnPool.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpConnPool.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpConnPool.java
index c89dbe4..f9bf401 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpConnPool.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpConnPool.java
@@ -49,22 +49,22 @@ class HttpConnPool extends AbstractConnPool<HttpRoute, OperatedClientConnection,
private final Log log;
private final long timeToLive;
- private final TimeUnit tunit;
+ private final TimeUnit timeUnit;
public HttpConnPool(final Log log,
final ClientConnectionOperator connOperator,
final int defaultMaxPerRoute, final int maxTotal,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
super(new InternalConnFactory(connOperator), defaultMaxPerRoute, maxTotal);
this.log = log;
this.timeToLive = timeToLive;
- this.tunit = tunit;
+ this.timeUnit = timeUnit;
}
@Override
protected HttpPoolEntry createEntry(final HttpRoute route, final OperatedClientConnection conn) {
final String id = Long.toString(COUNTER.getAndIncrement());
- return new HttpPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
+ return new HttpPoolEntry(this.log, id, route, conn, this.timeToLive, this.timeUnit);
}
static class InternalConnFactory implements ConnFactory<HttpRoute, OperatedClientConnection> {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpPoolEntry.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpPoolEntry.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpPoolEntry.java
index b39d952..9a27688 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpPoolEntry.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/HttpPoolEntry.java
@@ -52,8 +52,8 @@ class HttpPoolEntry extends PoolEntry<HttpRoute, OperatedClientConnection> {
final String id,
final HttpRoute route,
final OperatedClientConnection 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;
this.tracker = new RouteTracker(route);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java
index 3e2fefb..57f3dc6 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/PoolingClientConnectionManager.java
@@ -98,12 +98,12 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
public PoolingClientConnectionManager(
final SchemeRegistry schemeRegistry,
- final long timeToLive, final TimeUnit tunit) {
- this(schemeRegistry, timeToLive, tunit, new SystemDefaultDnsResolver());
+ final long timeToLive, final TimeUnit timeUnit) {
+ this(schemeRegistry, timeToLive, timeUnit, new SystemDefaultDnsResolver());
}
public PoolingClientConnectionManager(final SchemeRegistry schemeRegistry,
- final long timeToLive, final TimeUnit tunit,
+ final long timeToLive, final TimeUnit timeUnit,
final DnsResolver dnsResolver) {
super();
Args.notNull(schemeRegistry, "Scheme registry");
@@ -111,7 +111,7 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
this.schemeRegistry = schemeRegistry;
this.dnsResolver = dnsResolver;
this.operator = createConnectionOperator(schemeRegistry);
- this.pool = new HttpConnPool(this.log, this.operator, 2, 20, timeToLive, tunit);
+ this.pool = new HttpConnPool(this.log, this.operator, 2, 20, timeToLive, timeUnit);
}
@Override
@@ -196,8 +196,8 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
@Override
public ManagedClientConnection getConnection(
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
- return leaseConnection(future, timeout, tunit);
+ final TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException {
+ return leaseConnection(future, timeout, timeUnit);
}
};
@@ -207,10 +207,10 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
ManagedClientConnection leaseConnection(
final Future<HttpPoolEntry> future,
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
+ final TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException {
final HttpPoolEntry entry;
try {
- entry = future.get(timeout, tunit);
+ entry = future.get(timeout, timeUnit);
if (entry == null || future.isCancelled()) {
throw new InterruptedException();
}
@@ -234,7 +234,7 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
@Override
public void releaseConnection(
- final ManagedClientConnection conn, final long keepalive, final TimeUnit tunit) {
+ final ManagedClientConnection conn, final long keepalive, final TimeUnit timeUnit) {
Args.check(conn instanceof ManagedClientConnectionImpl, "Connection class mismatch, " +
"connection not obtained from this manager");
@@ -257,11 +257,11 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
}
// Only reusable connections can be kept alive
if (managedConn.isMarkedReusable()) {
- entry.updateExpiry(keepalive, tunit != null ? tunit : TimeUnit.MILLISECONDS);
+ entry.updateExpiry(keepalive, timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS);
if (this.log.isDebugEnabled()) {
final String s;
if (keepalive > 0) {
- s = "for " + keepalive + " " + tunit;
+ s = "for " + keepalive + " " + timeUnit;
} else {
s = "indefinitely";
}
@@ -289,11 +289,11 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
}
@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/12bf4c1a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java
index 2861b9b..993fa70 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/SingleClientConnManager.java
@@ -186,7 +186,7 @@ public class SingleClientConnManager implements ClientConnectionManager {
@Override
public ManagedClientConnection getConnection(
- final long timeout, final TimeUnit tunit) {
+ final long timeout, final TimeUnit timeUnit) {
return SingleClientConnManager.this.getConnection(
route, state);
}
@@ -317,16 +317,16 @@ public class SingleClientConnManager implements ClientConnectionManager {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
assertStillUp();
// idletime can be 0 or negative, no problem there
- Args.notNull(tunit, "Time unit");
+ Args.notNull(timeUnit, "Time unit");
synchronized (this) {
if ((managedConn == null) && uniquePoolEntry.connection.isOpen()) {
final long cutoff =
- System.currentTimeMillis() - tunit.toMillis(idletime);
+ System.currentTimeMillis() - timeUnit.toMillis(idletime);
if (lastReleaseTime <= cutoff) {
try {
uniquePoolEntry.close();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
index d9dfbfe..f9fd517 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
@@ -99,7 +99,7 @@ public abstract class AbstractConnPool {
* @param route the route for which to get the connection
* @param state the state
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
*
* @return pool entry holding a connection for the route
@@ -114,9 +114,9 @@ public abstract class AbstractConnPool {
final HttpRoute route,
final Object state,
final long timeout,
- final TimeUnit tunit)
+ final TimeUnit timeUnit)
throws ConnectionPoolTimeoutException, InterruptedException {
- return requestPoolEntry(route, state).getPoolEntry(timeout, tunit);
+ return requestPoolEntry(route, state).getPoolEntry(timeout, timeUnit);
}
/**
@@ -154,16 +154,16 @@ public abstract class AbstractConnPool {
*
* @param idletime the time the connections should have been idle
* in order to be closed now
- * @param tunit the unit for the {@code idletime}
+ * @param timeUnit the unit for the {@code idletime}
*/
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
// idletime can be 0 or negative, no problem there
- Args.notNull(tunit, "Time unit");
+ Args.notNull(timeUnit, "Time unit");
poolLock.lock();
try {
- idleConnHandler.closeIdleConnections(tunit.toMillis(idletime));
+ idleConnHandler.closeIdleConnections(timeUnit.toMillis(idletime));
} finally {
poolLock.unlock();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
index 31914c4..07f4afd 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
@@ -295,9 +295,9 @@ public class ConnPoolByRoute extends AbstractConnPool {
@Override
public BasicPoolEntry getPoolEntry(
final long timeout,
- final TimeUnit tunit)
+ final TimeUnit timeUnit)
throws InterruptedException, ConnectionPoolTimeoutException {
- return getEntryBlocking(route, state, timeout, tunit, aborter);
+ return getEntryBlocking(route, state, timeout, timeUnit, aborter);
}
};
@@ -310,7 +310,7 @@ public class ConnPoolByRoute extends AbstractConnPool {
*
* @param route the route for which to get the connection
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
* @param aborter an object which can abort a {@link WaitingThread}.
*
@@ -323,14 +323,14 @@ public class ConnPoolByRoute extends AbstractConnPool {
*/
protected BasicPoolEntry getEntryBlocking(
final HttpRoute route, final Object state,
- final long timeout, final TimeUnit tunit,
+ final long timeout, final TimeUnit timeUnit,
final WaitingThreadAborter aborter)
throws ConnectionPoolTimeoutException, InterruptedException {
Date deadline = null;
if (timeout > 0) {
deadline = new Date
- (System.currentTimeMillis() + tunit.toMillis(timeout));
+ (System.currentTimeMillis() + timeUnit.toMillis(timeout));
}
BasicPoolEntry entry = null;
@@ -710,17 +710,17 @@ public class ConnPoolByRoute extends AbstractConnPool {
*
* @param idletime the time the connections should have been idle
* in order to be closed now
- * @param tunit the unit for the {@code idletime}
+ * @param timeUnit the unit for the {@code idletime}
*/
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
final long t = idletime > 0 ? idletime : 0;
if (log.isDebugEnabled()) {
- log.debug("Closing connections idle longer than " + t + " " + tunit);
+ log.debug("Closing connections idle longer than " + t + " " + timeUnit);
}
// the latest time for which connections will be closed
- final long deadline = System.currentTimeMillis() - tunit.toMillis(t);
+ final long deadline = System.currentTimeMillis() - timeUnit.toMillis(t);
poolLock.lock();
try {
final Iterator<BasicPoolEntry> iter = freeConnections.iterator();
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
index 52b3564..5090888 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
@@ -46,7 +46,7 @@ public interface PoolEntryRequest {
* an {@link InterruptedException} is thrown.
*
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
*
* @return pool entry holding a connection for the route
@@ -58,7 +58,7 @@ public interface PoolEntryRequest {
*/
BasicPoolEntry getPoolEntry(
long timeout,
- TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException;
+ TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException;
/**
* Aborts the active or next call to
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
index 74f1118..dd2147a 100644
--- a/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
+++ b/httpclient/src/main/java-deprecated/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
@@ -232,7 +232,7 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
@Override
public ManagedClientConnection getConnection(
- final long timeout, final TimeUnit tunit) throws InterruptedException,
+ final long timeout, final TimeUnit timeUnit) throws InterruptedException,
ConnectionPoolTimeoutException {
Args.notNull(route, "Route");
@@ -240,7 +240,7 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
log.debug("Get connection: " + route + ", timeout = " + timeout);
}
- final BasicPoolEntry entry = poolRequest.getPoolEntry(timeout, tunit);
+ final BasicPoolEntry entry = poolRequest.getPoolEntry(timeout, timeUnit);
return new BasicPooledConnAdapter(ThreadSafeClientConnManager.this, entry);
}
@@ -327,11 +327,11 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
}
@Override
- public void closeIdleConnections(final long idleTimeout, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idleTimeout, final TimeUnit timeUnit) {
if (log.isDebugEnabled()) {
- log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
+ log.debug("Closing connections idle longer than " + idleTimeout + " " + timeUnit);
}
- pool.closeIdleConnections(idleTimeout, tunit);
+ pool.closeIdleConnections(idleTimeout, timeUnit);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java b/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
index 30a578e..8e7f0e9 100644
--- a/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
+++ b/httpclient/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
@@ -112,9 +112,8 @@ public final class AuthSchemeRegistry implements Lookup<AuthSchemeProvider> {
final AuthSchemeFactory factory = registeredSchemes.get(name.toLowerCase(Locale.ENGLISH));
if (factory != null) {
return factory.newInstance(params);
- } else {
- throw new IllegalStateException("Unsupported authentication scheme: " + name);
}
+ throw new IllegalStateException("Unsupported authentication scheme: " + name);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java b/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
index 9392f4a..27ee00d 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
@@ -79,9 +79,8 @@ public class DecompressingEntity extends HttpEntityWrapper {
content = getDecompressingStream();
}
return content;
- } else {
- return getDecompressingStream();
}
+ return getDecompressingStream();
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java
index be8e56d..ed2db74 100644
--- a/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java
+++ b/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java
@@ -59,15 +59,13 @@ public class CloneUtils {
final Throwable cause = ex.getCause();
if (cause instanceof CloneNotSupportedException) {
throw ((CloneNotSupportedException) cause);
- } else {
- throw new Error("Unexpected exception", cause);
}
+ throw new Error("Unexpected exception", cause);
} catch (final IllegalAccessException ex) {
throw new IllegalAccessError(ex.getMessage());
}
- } else {
- throw new CloneNotSupportedException();
}
+ throw new CloneNotSupportedException();
}
public static Object clone(final Object obj) throws CloneNotSupportedException {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java
index 8b30e68..845507c 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ClientConnectionManager.java
@@ -92,11 +92,11 @@ public interface ClientConnectionManager {
* All expired connections will also be closed.
*
* @param idletime the idle time of connections to be closed
- * @param tunit the unit for the {@code idletime}
+ * @param timeUnit the unit for the {@code idletime}
*
* @see #closeExpiredConnections()
*/
- void closeIdleConnections(long idletime, TimeUnit tunit);
+ void closeIdleConnections(long idletime, TimeUnit timeUnit);
/**
* Closes all expired connections in the pool.
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java b/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java
index cd8d5c4..afb053e 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ClientConnectionRequest.java
@@ -51,7 +51,7 @@ public interface ClientConnectionRequest {
* be thrown.
*
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
*
* @return a connection that can be used to communicate
@@ -62,7 +62,7 @@ public interface ClientConnectionRequest {
* @throws InterruptedException
* if the calling thread is interrupted while waiting
*/
- ManagedClientConnection getConnection(long timeout, TimeUnit tunit)
+ ManagedClientConnection getConnection(long timeout, TimeUnit timeUnit)
throws InterruptedException, ConnectionPoolTimeoutException;
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java b/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java
index 3520a52..ccd9eb3 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ConnectionRequest.java
@@ -52,7 +52,7 @@ public interface ConnectionRequest extends Cancellable {
* be thrown.
*
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
*
* @return a connection that can be used to communicate
@@ -63,7 +63,7 @@ public interface ConnectionRequest extends Cancellable {
* @throws InterruptedException
* if the calling thread is interrupted while waiting
*/
- HttpClientConnection get(long timeout, TimeUnit tunit)
+ HttpClientConnection get(long timeout, TimeUnit timeUnit)
throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java b/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
index 70c2908..d39f179 100644
--- a/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
+++ b/httpclient/src/main/java/org/apache/http/conn/HttpClientConnectionManager.java
@@ -155,11 +155,11 @@ public interface HttpClientConnectionManager {
* </p>
*
* @param idletime the idle time of connections to be closed
- * @param tunit the unit for the {@code idletime}
+ * @param timeUnit the unit for the {@code idletime}
*
* @see #closeExpiredConnections()
*/
- void closeIdleConnections(long idletime, TimeUnit tunit);
+ void closeIdleConnections(long idletime, TimeUnit timeUnit);
/**
* Closes all expired connections in the pool.
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java
----------------------------------------------------------------------
diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java b/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java
index ec7c0bf..4877b30 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java
@@ -214,9 +214,8 @@ public abstract class AbstractVerifier implements X509HostnameVerifier {
match = normalizedHost.endsWith(normalizedIdentity.substring(1));
}
return match && (!strict || countDots(normalizedHost) == countDots(normalizedIdentity));
- } else {
- return normalizedHost.equals(normalizedIdentity);
}
+ return normalizedHost.equals(normalizedIdentity);
}
private static boolean validCountryWildcard(final String parts[]) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/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/12bf4c1a/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/12bf4c1a/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/12bf4c1a/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/12bf4c1a/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/12bf4c1a/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/12bf4c1a/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/12bf4c1a/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/12bf4c1a/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/12bf4c1a/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/12bf4c1a/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/12bf4c1a/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/12bf4c1a/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 97c54e0..f5efb83 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
@@ -64,14 +64,14 @@ public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnec
final String id,
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;
http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/12bf4c1a/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 6866e42..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 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/12bf4c1a/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/12bf4c1a/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/12bf4c1a/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..1deb146 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
@@ -138,13 +138,10 @@ public class DefaultCookieSpec implements CookieSpec {
}
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);
- }
}
+ 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/12bf4c1a/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/12bf4c1a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
----------------------------------------------------------------------
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
index 282e11b..d1b0057 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java
@@ -373,11 +373,11 @@ public class TestAbortHandling extends LocalServerTestBase {
@Override
public HttpClientConnection get(
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
+ final TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException {
connLatch.countDown(); // notify waiter that we're getting a connection
// zero usually means sleep forever, but CountDownLatch doesn't interpret it that way.
- if(!awaitLatch.await(timeout > 0 ? timeout : Integer.MAX_VALUE, tunit)) {
+ if(!awaitLatch.await(timeout > 0 ? timeout : Integer.MAX_VALUE, timeUnit)) {
throw new ConnectionPoolTimeoutException();
}
@@ -401,7 +401,7 @@ public class TestAbortHandling extends LocalServerTestBase {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
throw new UnsupportedOperationException("just a mockup");
}
@@ -411,7 +411,7 @@ public class TestAbortHandling extends LocalServerTestBase {
}
public HttpClientConnection getConnection(final HttpRoute route,
- final long timeout, final TimeUnit tunit) {
+ final long timeout, final TimeUnit timeUnit) {
throw new UnsupportedOperationException("just a mockup");
}
@@ -433,11 +433,11 @@ public class TestAbortHandling extends LocalServerTestBase {
@Override
public HttpClientConnection get(
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
+ final TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException {
connLatch.countDown(); // notify waiter that we're getting a connection
// zero usually means sleep forever, but CountDownLatch doesn't interpret it that way.
- if(!awaitLatch.await(timeout > 0 ? timeout : Integer.MAX_VALUE, tunit)) {
+ if(!awaitLatch.await(timeout > 0 ? timeout : Integer.MAX_VALUE, timeUnit)) {
throw new ConnectionPoolTimeoutException();
}