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:58:55 UTC
[1/3] httpcomponents-core 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-core
Updated Branches:
refs/heads/4.4.x 14e3a19a9 -> d956f67e6
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java b/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
index b10c932..14c6290 100644
--- a/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
+++ b/httpcore/src/main/java/org/apache/http/pool/AbstractConnPool.java
@@ -210,9 +210,8 @@ public abstract class AbstractConnPool<T, C, E extends PoolEntry<T, C>>
callback.cancelled();
}
return true;
- } else {
- return false;
}
+ return false;
}
@Override
@@ -235,7 +234,7 @@ public abstract class AbstractConnPool<T, C, E extends PoolEntry<T, C>>
}
@Override
- public E get(final long timeout, final TimeUnit tunit) throws InterruptedException, ExecutionException, TimeoutException {
+ public E get(final long timeout, final TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
final E entry = entryRef.get();
if (entry != null) {
return entry;
@@ -243,7 +242,7 @@ public abstract class AbstractConnPool<T, C, E extends PoolEntry<T, C>>
synchronized (this) {
try {
for (;;) {
- final E leasedEntry = getPoolEntryBlocking(route, state, timeout, tunit, this);
+ final E leasedEntry = getPoolEntryBlocking(route, state, timeout, timeUnit, this);
if (validateAfterInactivity > 0) {
if (leasedEntry.getUpdated() + validateAfterInactivity <= System.currentTimeMillis()) {
if (!validate(leasedEntry)) {
@@ -296,12 +295,12 @@ public abstract class AbstractConnPool<T, C, E extends PoolEntry<T, C>>
private E getPoolEntryBlocking(
final T route, final Object state,
- final long timeout, final TimeUnit tunit,
+ final long timeout, final TimeUnit timeUnit,
final Future<E> future) throws IOException, InterruptedException, TimeoutException {
Date deadline = null;
if (timeout > 0) {
- deadline = new Date (System.currentTimeMillis() + tunit.toMillis(timeout));
+ deadline = new Date (System.currentTimeMillis() + timeUnit.toMillis(timeout));
}
this.lock.lock();
try {
@@ -432,11 +431,7 @@ public abstract class AbstractConnPool<T, C, E extends PoolEntry<T, C>>
private int getMax(final T route) {
final Integer v = this.maxPerRoute.get(route);
- if (v != null) {
- return v.intValue();
- } else {
- return this.defaultMaxPerRoute;
- }
+ return v != null ? v.intValue() : this.defaultMaxPerRoute;
}
@Override
@@ -610,11 +605,11 @@ public abstract class AbstractConnPool<T, C, E extends PoolEntry<T, C>>
* of time and evicts them from the pool.
*
* @param idletime maximum idle time.
- * @param tunit time unit.
+ * @param timeUnit time unit.
*/
- public void closeIdle(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
- long time = tunit.toMillis(idletime);
+ public void closeIdle(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
+ long time = timeUnit.toMillis(idletime);
if (time < 0) {
time = 0;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/pool/PoolEntry.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/pool/PoolEntry.java b/httpcore/src/main/java/org/apache/http/pool/PoolEntry.java
index dad5139..0459b2b 100644
--- a/httpcore/src/main/java/org/apache/http/pool/PoolEntry.java
+++ b/httpcore/src/main/java/org/apache/http/pool/PoolEntry.java
@@ -71,21 +71,21 @@ public abstract class PoolEntry<T, C> {
* @param conn the connection.
* @param timeToLive maximum time to live. May be zero if the connection
* does not have an expiry deadline.
- * @param tunit time unit.
+ * @param timeUnit time unit.
*/
public PoolEntry(final String id, final T route, final C conn,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
super();
Args.notNull(route, "Route");
Args.notNull(conn, "Connection");
- Args.notNull(tunit, "Time unit");
+ Args.notNull(timeUnit, "Time unit");
this.id = id;
this.route = route;
this.conn = conn;
this.created = System.currentTimeMillis();
this.updated = this.created;
if (timeToLive > 0) {
- final long deadline = this.created + tunit.toMillis(timeToLive);
+ final long deadline = this.created + timeUnit.toMillis(timeToLive);
// If the above overflows then default to Long.MAX_VALUE
this.validityDeadline = deadline > 0 ? deadline : Long.MAX_VALUE;
} else {
@@ -152,12 +152,12 @@ public abstract class PoolEntry<T, C> {
return this.expiry;
}
- public synchronized void updateExpiry(final long time, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
+ public synchronized void updateExpiry(final long time, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
this.updated = System.currentTimeMillis();
final long newExpiry;
if (time > 0) {
- newExpiry = this.updated + tunit.toMillis(time);
+ newExpiry = this.updated + timeUnit.toMillis(time);
} else {
newExpiry = Long.MAX_VALUE;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/pool/RouteSpecificPool.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/pool/RouteSpecificPool.java b/httpcore/src/main/java/org/apache/http/pool/RouteSpecificPool.java
index c337228..5280ba9 100644
--- a/httpcore/src/main/java/org/apache/http/pool/RouteSpecificPool.java
+++ b/httpcore/src/main/java/org/apache/http/pool/RouteSpecificPool.java
@@ -99,11 +99,7 @@ abstract class RouteSpecificPool<T, C, E extends PoolEntry<T, C>> {
}
public E getLastUsed() {
- if (!this.available.isEmpty()) {
- return this.available.getLast();
- } else {
- return null;
- }
+ return this.available.isEmpty() ? null : this.available.getLast();
}
public boolean remove(final E entry) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/protocol/HttpCoreContext.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/protocol/HttpCoreContext.java b/httpcore/src/main/java/org/apache/http/protocol/HttpCoreContext.java
index f690a04..481ce2f 100644
--- a/httpcore/src/main/java/org/apache/http/protocol/HttpCoreContext.java
+++ b/httpcore/src/main/java/org/apache/http/protocol/HttpCoreContext.java
@@ -78,11 +78,9 @@ public class HttpCoreContext implements HttpContext {
public static HttpCoreContext adapt(final HttpContext context) {
Args.notNull(context, "HTTP context");
- if (context instanceof HttpCoreContext) {
- return (HttpCoreContext) context;
- } else {
- return new HttpCoreContext(context);
- }
+ return context instanceof HttpCoreContext
+ ? (HttpCoreContext) context
+ : new HttpCoreContext(context);
}
private final HttpContext context;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java b/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
index 25d6695..93a2efd 100644
--- a/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
+++ b/httpcore/src/main/java/org/apache/http/protocol/UriPatternMatcher.java
@@ -165,11 +165,10 @@ public class UriPatternMatcher<T> {
protected boolean matchUriRequestPattern(final String pattern, final String path) {
if (pattern.equals("*")) {
return true;
- } else {
- return
- (pattern.endsWith("*") && path.startsWith(pattern.substring(0, pattern.length() - 1))) ||
- (pattern.startsWith("*") && path.endsWith(pattern.substring(1, pattern.length())));
}
+ return
+ (pattern.endsWith("*") && path.startsWith(pattern.substring(0, pattern.length() - 1))) ||
+ (pattern.startsWith("*") && path.endsWith(pattern.substring(1, pattern.length())));
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/util/LangUtils.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/util/LangUtils.java b/httpcore/src/main/java/org/apache/http/util/LangUtils.java
index 44e497a..2d37a28 100644
--- a/httpcore/src/main/java/org/apache/http/util/LangUtils.java
+++ b/httpcore/src/main/java/org/apache/http/util/LangUtils.java
@@ -83,18 +83,16 @@ public final class LangUtils {
public static boolean equals(final Object[] a1, final Object[] a2) {
if (a1 == null) {
return a2 == null;
- } else {
- if (a2 != null && a1.length == a2.length) {
- for (int i = 0; i < a1.length; i++) {
- if (!equals(a1[i], a2[i])) {
- return false;
- }
+ }
+ if (a2 != null && a1.length == a2.length) {
+ for (int i = 0; i < a1.length; i++) {
+ if (!equals(a1[i], a2[i])) {
+ return false;
}
- return true;
- } else {
- return false;
}
+ return true;
}
+ return false;
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/test/java/org/apache/http/impl/SessionOutputBufferMock.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/SessionOutputBufferMock.java b/httpcore/src/test/java/org/apache/http/impl/SessionOutputBufferMock.java
index 421d849..aa9e204 100644
--- a/httpcore/src/test/java/org/apache/http/impl/SessionOutputBufferMock.java
+++ b/httpcore/src/test/java/org/apache/http/impl/SessionOutputBufferMock.java
@@ -80,11 +80,7 @@ public class SessionOutputBufferMock extends SessionOutputBufferImpl {
}
public byte[] getData() {
- if (this.buffer != null) {
- return this.buffer.toByteArray();
- } else {
- return new byte[] {};
- }
+ return this.buffer != null ? this.buffer.toByteArray() : new byte[] {};
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/test/java/org/apache/http/impl/io/TimeoutByteArrayInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/impl/io/TimeoutByteArrayInputStream.java b/httpcore/src/test/java/org/apache/http/impl/io/TimeoutByteArrayInputStream.java
index dabc617..5a57e3a 100644
--- a/httpcore/src/test/java/org/apache/http/impl/io/TimeoutByteArrayInputStream.java
+++ b/httpcore/src/test/java/org/apache/http/impl/io/TimeoutByteArrayInputStream.java
@@ -61,9 +61,8 @@ class TimeoutByteArrayInputStream extends InputStream {
final int v = this.buf[this.pos++] & 0xff;
if (v != 0) {
return v;
- } else {
- throw new InterruptedIOException("Timeout");
}
+ throw new InterruptedIOException("Timeout");
}
@Override
@@ -92,10 +91,9 @@ class TimeoutByteArrayInputStream extends InputStream {
final int v = this.buf[this.pos] & 0xff;
if (v == 0) {
return i;
- } else {
- b[off + i] = (byte) v;
- this.pos++;
}
+ b[off + i] = (byte) v;
+ this.pos++;
}
return chunk;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java b/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java
index e5417a3..164c4e4 100644
--- a/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java
+++ b/httpcore/src/test/java/org/apache/http/pool/TestConnPool.java
@@ -187,16 +187,16 @@ public class TestConnPool {
private final Future<LocalPoolEntry> future;
private final long time;
- private final TimeUnit tunit;
+ private final TimeUnit timeUnit;
private volatile LocalPoolEntry entry;
private volatile Exception ex;
- GetPoolEntryThread(final Future<LocalPoolEntry> future, final long time, final TimeUnit tunit) {
+ GetPoolEntryThread(final Future<LocalPoolEntry> future, final long time, final TimeUnit timeUnit) {
super();
this.future = future;
this.time = time;
- this.tunit = tunit;
+ this.timeUnit = timeUnit;
setDaemon(true);
}
@@ -207,7 +207,7 @@ public class TestConnPool {
@Override
public void run() {
try {
- this.entry = this.future.get(this.time, this.tunit);
+ this.entry = this.future.get(this.time, this.timeUnit);
} catch (final Exception ex) {
this.ex = ex;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/test/java/org/apache/http/pool/TestPoolEntry.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/pool/TestPoolEntry.java b/httpcore/src/test/java/org/apache/http/pool/TestPoolEntry.java
index 6bad38e..52ccd50 100644
--- a/httpcore/src/test/java/org/apache/http/pool/TestPoolEntry.java
+++ b/httpcore/src/test/java/org/apache/http/pool/TestPoolEntry.java
@@ -39,13 +39,13 @@ public class TestPoolEntry {
static class MockPoolEntry extends PoolEntry<String, HttpConnection> {
public MockPoolEntry(final String route,
- final long timeToLive, final TimeUnit tunit) {
- super(null, route, Mockito.mock(HttpConnection.class), timeToLive, tunit);
+ final long timeToLive, final TimeUnit timeUnit) {
+ super(null, route, Mockito.mock(HttpConnection.class), timeToLive, timeUnit);
}
public MockPoolEntry(final String route, final HttpConnection conn,
- final long timeToLive, final TimeUnit tunit) {
- super(null, route, conn, timeToLive, tunit);
+ final long timeToLive, final TimeUnit timeUnit) {
+ super(null, route, conn, timeToLive, timeUnit);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java b/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
index e937716..7f3d544 100644
--- a/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
+++ b/httpcore/src/test/java/org/apache/http/ssl/TestSSLContextBuilder.java
@@ -559,11 +559,7 @@ public class TestSSLContextBuilder {
final PrivateKeyStrategy privateKeyStrategy = new PrivateKeyStrategy() {
@Override
public String chooseAlias(final Map<String, PrivateKeyDetails> aliases, final Socket socket) {
- if (aliases.keySet().contains("client2")) {
- return "client2";
- } else {
- return null;
- }
+ return aliases.keySet().contains("client2") ? "client2" : null;
}
};
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java b/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java
index 21224a3..64af7e5 100644
--- a/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java
+++ b/httpcore/src/test/java/org/apache/http/testserver/HttpServer.java
@@ -53,7 +53,7 @@ public class HttpServer {
private volatile org.apache.http.impl.bootstrap.HttpServer server;
- public HttpServer() throws IOException {
+ public HttpServer() {
super();
this.reqistry = new UriHttpRequestHandlerMapper();
}
@@ -80,18 +80,16 @@ public class HttpServer {
final org.apache.http.impl.bootstrap.HttpServer local = this.server;
if (local != null) {
return this.server.getLocalPort();
- } else {
- throw new IllegalStateException("Server not running");
}
+ throw new IllegalStateException("Server not running");
}
public InetAddress getInetAddress() {
final org.apache.http.impl.bootstrap.HttpServer local = this.server;
if (local != null) {
return local.getInetAddress();
- } else {
- throw new IllegalStateException("Server not running");
}
+ throw new IllegalStateException("Server not running");
}
public void start() throws IOException {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java b/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
index a623a10..afecfc7 100644
--- a/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
+++ b/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpClientConnection.java
@@ -52,25 +52,25 @@ public class LoggingBHttpClientConnection extends DefaultBHttpClientConnection {
private final String id;
private final Log log;
- private final Log headerlog;
+ private final Log headerLog;
private final Wire wire;
public LoggingBHttpClientConnection(
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 = "http-outgoing-" + COUNT.incrementAndGet();
this.log = LogFactory.getLog(getClass());
- this.headerlog = LogFactory.getLog("org.apache.http.headers");
+ this.headerLog = LogFactory.getLog("org.apache.http.headers");
this.wire = new Wire(LogFactory.getLog("org.apache.http.wire"), this.id);
}
@@ -114,22 +114,22 @@ public class LoggingBHttpClientConnection extends DefaultBHttpClientConnection {
@Override
protected void onResponseReceived(final HttpResponse response) {
- if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(this.id + " << " + response.getStatusLine().toString());
+ if (response != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(this.id + " << " + response.getStatusLine().toString());
final Header[] headers = response.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(this.id + " << " + header.toString());
+ this.headerLog.debug(this.id + " << " + header.toString());
}
}
}
@Override
protected void onRequestSubmitted(final HttpRequest request) {
- if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(id + " >> " + request.getRequestLine().toString());
+ if (request != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(id + " >> " + request.getRequestLine().toString());
final Header[] headers = request.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(this.id + " >> " + header.toString());
+ this.headerLog.debug(this.id + " >> " + header.toString());
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java b/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
index 030a25f..b81150d 100644
--- a/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
+++ b/httpcore/src/test/java/org/apache/http/testserver/LoggingBHttpServerConnection.java
@@ -52,25 +52,25 @@ public class LoggingBHttpServerConnection extends DefaultBHttpServerConnection {
private final String id;
private final Log log;
- private final Log headerlog;
+ private final Log headerLog;
private final Wire wire;
public LoggingBHttpServerConnection(
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 HttpMessageParserFactory<HttpRequest> requestParserFactory,
final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
- super(bufferSize, fragmentSizeHint, chardecoder, charencoder, constraints,
+ super(bufferSize, fragmentSizeHint, charDecoder, charEncoder, constraints,
incomingContentStrategy, outgoingContentStrategy,
requestParserFactory, responseWriterFactory);
this.id = "http-incoming-" + COUNT.incrementAndGet();
this.log = LogFactory.getLog(getClass());
- this.headerlog = LogFactory.getLog("org.apache.http.headers");
+ this.headerLog = LogFactory.getLog("org.apache.http.headers");
this.wire = new Wire(LogFactory.getLog("org.apache.http.wire"), this.id);
}
@@ -114,22 +114,22 @@ public class LoggingBHttpServerConnection extends DefaultBHttpServerConnection {
@Override
protected void onRequestReceived(final HttpRequest request) {
- if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(this.id + " >> " + request.getRequestLine().toString());
+ if (request != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(this.id + " >> " + request.getRequestLine().toString());
final Header[] headers = request.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(this.id + " >> " + header.toString());
+ this.headerLog.debug(this.id + " >> " + header.toString());
}
}
}
@Override
protected void onResponseSubmitted(final HttpResponse response) {
- if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(this.id + " << " + response.getStatusLine().toString());
+ if (response != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(this.id + " << " + response.getStatusLine().toString());
final Header[] headers = response.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(this.id + " << " + header.toString());
+ this.headerLog.debug(this.id + " << " + header.toString());
}
}
}
[2/3] httpcomponents-core 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.)
Posted by gg...@apache.org.
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java b/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
index d1b1953..9672db6 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/pool/TestNIOConnPool.java
@@ -103,15 +103,15 @@ public class TestNIOConnPool {
static class LocalSessionPool extends AbstractNIOConnPool<String, IOSession, LocalPoolEntry> {
public LocalSessionPool(
- final ConnectingIOReactor ioreactor, final int defaultMaxPerRoute, final int maxTotal) {
- super(ioreactor, new LocalConnFactory(), new LocalAddressResolver(), defaultMaxPerRoute, maxTotal);
+ final ConnectingIOReactor ioReactor, final int defaultMaxPerRoute, final int maxTotal) {
+ super(ioReactor, new LocalConnFactory(), new LocalAddressResolver(), defaultMaxPerRoute, maxTotal);
}
public LocalSessionPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final SocketAddressResolver<String> addressResolver,
final int defaultMaxPerRoute, final int maxTotal) {
- super(ioreactor, new LocalConnFactory(), addressResolver, defaultMaxPerRoute, maxTotal);
+ super(ioReactor, new LocalConnFactory(), addressResolver, defaultMaxPerRoute, maxTotal);
}
@Override
@@ -123,8 +123,8 @@ public class TestNIOConnPool {
@Test
public void testEmptyPool() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
final PoolStats totals = pool.getTotalStats();
Assert.assertEquals(0, totals.getAvailable());
Assert.assertEquals(0, totals.getLeased());
@@ -149,19 +149,19 @@ public class TestNIOConnPool {
@Test
public void testInvalidConstruction() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
try {
new LocalSessionPool(null, 1, 1);
Assert.fail("IllegalArgumentException should have been thrown");
} catch (final IllegalArgumentException expected) {
}
try {
- new LocalSessionPool(ioreactor, -1, 1);
+ new LocalSessionPool(ioReactor, -1, 1);
Assert.fail("IllegalArgumentException should have been thrown");
} catch (final IllegalArgumentException expected) {
}
try {
- new LocalSessionPool(ioreactor, 1, -1);
+ new LocalSessionPool(ioReactor, 1, -1);
Assert.fail("IllegalArgumentException should have been thrown");
} catch (final IllegalArgumentException expected) {
}
@@ -169,17 +169,17 @@ public class TestNIOConnPool {
@Test
public void testSuccessfulConnect() throws Exception {
- final IOSession iosession = Mockito.mock(IOSession.class);
+ final IOSession ioSession = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest.getSession()).thenReturn(iosession);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ Mockito.when(sessionRequest.getSession()).thenReturn(ioSession);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
final Future<LocalPoolEntry> future = pool.lease("somehost", null, 100, TimeUnit.MILLISECONDS, null);
Mockito.verify(sessionRequest).setConnectTimeout(100);
@@ -206,13 +206,13 @@ public class TestNIOConnPool {
final SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest.getAttachment()).thenReturn("somehost");
Mockito.when(sessionRequest.getException()).thenReturn(new IOException());
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
final Future<LocalPoolEntry> future = pool.lease("somehost", null);
PoolStats totals = pool.getTotalStats();
@@ -239,18 +239,18 @@ public class TestNIOConnPool {
@Test
public void testCencelledConnect() throws Exception {
- final IOSession iosession = Mockito.mock(IOSession.class);
+ final IOSession ioSession = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest.getSession()).thenReturn(iosession);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ Mockito.when(sessionRequest.getSession()).thenReturn(ioSession);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest);
- Mockito.when(ioreactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ Mockito.when(ioReactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
final Future<LocalPoolEntry> future = pool.lease("somehost", null);
PoolStats totals = pool.getTotalStats();
@@ -276,19 +276,19 @@ public class TestNIOConnPool {
@Test
public void testTimeoutConnect() throws Exception {
- final IOSession iosession = Mockito.mock(IOSession.class);
+ final IOSession ioSession = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest.getAttachment()).thenReturn("somehost");
Mockito.when(sessionRequest.getRemoteAddress())
.thenReturn(new InetSocketAddress(InetAddress.getByAddress(new byte[]{127, 0, 0, 1}), 80));
- Mockito.when(sessionRequest.getSession()).thenReturn(iosession);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ Mockito.when(sessionRequest.getSession()).thenReturn(ioSession);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
final Future<LocalPoolEntry> future = pool.lease("somehost", null);
PoolStats totals = pool.getTotalStats();
@@ -319,10 +319,10 @@ public class TestNIOConnPool {
final SessionRequest sessionRequest = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest.getAttachment()).thenReturn("somehost");
Mockito.when(sessionRequest.getException()).thenReturn(new IOException());
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
final SocketAddressResolver<String> addressResolver = Mockito.mock(SocketAddressResolver.class);
Mockito.when(addressResolver.resolveRemoteAddress("somehost")).thenThrow(new UnknownHostException());
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, addressResolver, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, addressResolver, 2, 10);
final Future<LocalPoolEntry> future = pool.lease("somehost", null);
Assert.assertTrue(future.isDone());
@@ -337,29 +337,29 @@ public class TestNIOConnPool {
@Test
public void testLeaseRelease() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final IOSession iosession2 = Mockito.mock(IOSession.class);
+ final IOSession ioSession2 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest2.getAttachment()).thenReturn("otherhost");
- Mockito.when(sessionRequest2.getSession()).thenReturn(iosession2);
+ Mockito.when(sessionRequest2.getSession()).thenReturn(ioSession2);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1);
- Mockito.when(ioreactor.connect(
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest2);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
pool.requestCompleted(sessionRequest1);
final Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
@@ -377,8 +377,8 @@ public class TestNIOConnPool {
pool.release(entry1, true);
pool.release(entry2, true);
pool.release(entry3, false);
- Mockito.verify(iosession1, Mockito.never()).close();
- Mockito.verify(iosession2, Mockito.times(1)).close();
+ Mockito.verify(ioSession1, Mockito.never()).close();
+ Mockito.verify(ioSession2, Mockito.times(1)).close();
final PoolStats totals = pool.getTotalStats();
Assert.assertEquals(2, totals.getAvailable());
@@ -388,8 +388,8 @@ public class TestNIOConnPool {
@Test
public void testLeaseIllegal() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
try {
pool.lease(null, null, 0, TimeUnit.MILLISECONDS, null);
Assert.fail("IllegalArgumentException should have been thrown");
@@ -404,36 +404,36 @@ public class TestNIOConnPool {
@Test
public void testReleaseUnknownEntry() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
pool.release(new LocalPoolEntry("somehost", Mockito.mock(IOSession.class)), true);
}
@Test
public void testMaxLimits() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final IOSession iosession2 = Mockito.mock(IOSession.class);
+ final IOSession ioSession2 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest2.getAttachment()).thenReturn("otherhost");
- Mockito.when(sessionRequest2.getSession()).thenReturn(iosession2);
+ Mockito.when(sessionRequest2.getSession()).thenReturn(ioSession2);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1);
- Mockito.when(ioreactor.connect(
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest2);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
pool.setMaxPerRoute("somehost", 2);
pool.setMaxPerRoute("otherhost", 1);
pool.setMaxTotal(3);
@@ -481,7 +481,7 @@ public class TestNIOConnPool {
Assert.assertFalse(future8.isDone());
Assert.assertFalse(future9.isDone());
- Mockito.verify(ioreactor, Mockito.times(3)).connect(
+ Mockito.verify(ioReactor, Mockito.times(3)).connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -493,46 +493,46 @@ public class TestNIOConnPool {
Assert.assertFalse(future8.isDone());
Assert.assertTrue(future9.isDone());
- Mockito.verify(ioreactor, Mockito.times(4)).connect(
+ Mockito.verify(ioReactor, Mockito.times(4)).connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
}
@Test
public void testConnectionRedistributionOnTotalMaxLimit() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final IOSession iosession2 = Mockito.mock(IOSession.class);
+ final IOSession ioSession2 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest2.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest2.getSession()).thenReturn(iosession2);
+ Mockito.when(sessionRequest2.getSession()).thenReturn(ioSession2);
- final IOSession iosession3 = Mockito.mock(IOSession.class);
+ final IOSession ioSession3 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest3 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest3.getAttachment()).thenReturn("otherhost");
- Mockito.when(sessionRequest3.getSession()).thenReturn(iosession3);
+ Mockito.when(sessionRequest3.getSession()).thenReturn(ioSession3);
- final IOSession iosession4 = Mockito.mock(IOSession.class);
+ final IOSession ioSession4 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest4 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest4.getAttachment()).thenReturn("otherhost");
- Mockito.when(sessionRequest4.getSession()).thenReturn(iosession4);
+ Mockito.when(sessionRequest4.getSession()).thenReturn(ioSession4);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1, sessionRequest2, sessionRequest1);
- Mockito.when(ioreactor.connect(
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest3, sessionRequest4, sessionRequest3);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
pool.setMaxPerRoute("somehost", 2);
pool.setMaxPerRoute("otherhost", 2);
pool.setMaxTotal(2);
@@ -542,12 +542,12 @@ public class TestNIOConnPool {
final Future<LocalPoolEntry> future3 = pool.lease("otherhost", null);
final Future<LocalPoolEntry> future4 = pool.lease("otherhost", null);
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
- Mockito.verify(ioreactor, Mockito.never()).connect(
+ Mockito.verify(ioReactor, Mockito.never()).connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -573,12 +573,12 @@ public class TestNIOConnPool {
pool.release(entry1, true);
pool.release(entry2, true);
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -601,12 +601,12 @@ public class TestNIOConnPool {
final Future<LocalPoolEntry> future5 = pool.lease("somehost", null);
final Future<LocalPoolEntry> future6 = pool.lease("otherhost", null);
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -614,12 +614,12 @@ public class TestNIOConnPool {
pool.release(entry3, true);
pool.release(entry4, true);
- Mockito.verify(ioreactor, Mockito.times(3)).connect(
+ Mockito.verify(ioReactor, Mockito.times(3)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -641,12 +641,12 @@ public class TestNIOConnPool {
pool.release(entry5, true);
pool.release(entry6, true);
- Mockito.verify(ioreactor, Mockito.times(3)).connect(
+ Mockito.verify(ioReactor, Mockito.times(3)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("otherhost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -659,36 +659,36 @@ public class TestNIOConnPool {
@Test
public void testStatefulConnectionRedistributionOnPerRouteMaxLimit() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final IOSession iosession2 = Mockito.mock(IOSession.class);
+ final IOSession ioSession2 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest2.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest2.getSession()).thenReturn(iosession2);
+ Mockito.when(sessionRequest2.getSession()).thenReturn(ioSession2);
- final IOSession iosession3 = Mockito.mock(IOSession.class);
+ final IOSession ioSession3 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest3 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest3.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest3.getSession()).thenReturn(iosession3);
+ Mockito.when(sessionRequest3.getSession()).thenReturn(ioSession3);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1, sessionRequest2, sessionRequest3);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 10);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 10);
pool.setMaxPerRoute("somehost", 2);
pool.setMaxTotal(2);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
final Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -723,7 +723,7 @@ public class TestNIOConnPool {
final LocalPoolEntry entry4 = future4.get();
Assert.assertNotNull(entry4);
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -740,13 +740,13 @@ public class TestNIOConnPool {
Assert.assertFalse(future5.isDone());
- Mockito.verify(ioreactor, Mockito.times(3)).connect(
+ Mockito.verify(ioReactor, Mockito.times(3)).connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
- Mockito.verify(iosession2).close();
- Mockito.verify(iosession1, Mockito.never()).close();
+ Mockito.verify(ioSession2).close();
+ Mockito.verify(ioSession1, Mockito.never()).close();
totals = pool.getTotalStats();
Assert.assertEquals(1, totals.getAvailable());
@@ -756,24 +756,24 @@ public class TestNIOConnPool {
@Test
public void testCreateNewIfExpired() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
- Mockito.when(iosession1.isClosed()).thenReturn(Boolean.TRUE);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
+ Mockito.when(ioSession1.isClosed()).thenReturn(Boolean.TRUE);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.eq(InetSocketAddress.createUnresolved("somehost", 80)),
Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
- Mockito.verify(ioreactor, Mockito.times(1)).connect(
+ Mockito.verify(ioReactor, Mockito.times(1)).connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -792,8 +792,8 @@ public class TestNIOConnPool {
Assert.assertFalse(future2.isDone());
- Mockito.verify(iosession1).close();
- Mockito.verify(ioreactor, Mockito.times(2)).connect(
+ Mockito.verify(ioSession1).close();
+ Mockito.verify(ioReactor, Mockito.times(2)).connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class));
@@ -810,24 +810,24 @@ public class TestNIOConnPool {
@Test
public void testCloseExpired() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
- Mockito.when(iosession1.isClosed()).thenReturn(Boolean.TRUE);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
+ Mockito.when(ioSession1.isClosed()).thenReturn(Boolean.TRUE);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final IOSession iosession2 = Mockito.mock(IOSession.class);
+ final IOSession ioSession2 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest2.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest2.getSession()).thenReturn(iosession2);
+ Mockito.when(sessionRequest2.getSession()).thenReturn(ioSession2);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1, sessionRequest2);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
final Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
@@ -852,8 +852,8 @@ public class TestNIOConnPool {
pool.closeExpired();
- Mockito.verify(iosession1).close();
- Mockito.verify(iosession2, Mockito.never()).close();
+ Mockito.verify(ioSession1).close();
+ Mockito.verify(ioSession2, Mockito.never()).close();
final PoolStats totals = pool.getTotalStats();
Assert.assertEquals(1, totals.getAvailable());
@@ -867,23 +867,23 @@ public class TestNIOConnPool {
@Test
public void testCloseIdle() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final IOSession iosession2 = Mockito.mock(IOSession.class);
+ final IOSession ioSession2 = Mockito.mock(IOSession.class);
final SessionRequest sessionRequest2 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest2.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest2.getSession()).thenReturn(iosession2);
+ Mockito.when(sessionRequest2.getSession()).thenReturn(ioSession2);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1, sessionRequest2);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null);
final Future<LocalPoolEntry> future2 = pool.lease("somehost", null);
@@ -908,8 +908,8 @@ public class TestNIOConnPool {
pool.closeIdle(50, TimeUnit.MILLISECONDS);
- Mockito.verify(iosession1).close();
- Mockito.verify(iosession2, Mockito.never()).close();
+ Mockito.verify(ioSession1).close();
+ Mockito.verify(ioSession2, Mockito.never()).close();
PoolStats totals = pool.getTotalStats();
Assert.assertEquals(1, totals.getAvailable());
@@ -922,7 +922,7 @@ public class TestNIOConnPool {
pool.closeIdle(-1, TimeUnit.MILLISECONDS);
- Mockito.verify(iosession2).close();
+ Mockito.verify(ioSession2).close();
totals = pool.getTotalStats();
Assert.assertEquals(0, totals.getAvailable());
@@ -936,19 +936,19 @@ public class TestNIOConnPool {
@Test
public void testLeaseRequestTimeout() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
- Mockito.when(iosession1.isClosed()).thenReturn(Boolean.TRUE);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
+ Mockito.when(ioSession1.isClosed()).thenReturn(Boolean.TRUE);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 1, 1);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 1, 1);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null, 0, TimeUnit.MILLISECONDS, null);
final Future<LocalPoolEntry> future2 = pool.lease("somehost", null, 0, TimeUnit.MILLISECONDS, null);
@@ -972,22 +972,22 @@ public class TestNIOConnPool {
@Test(expected=IllegalArgumentException.class)
public void testCloseIdleInvalid() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
pool.closeIdle(50, null);
}
@Test(expected=IllegalArgumentException.class)
public void testGetStatsInvalid() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
pool.getStats(null);
}
@Test
public void testSetMaxInvalid() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
try {
pool.setMaxTotal(-1);
Assert.fail("IllegalArgumentException should have been thrown");
@@ -1007,8 +1007,8 @@ public class TestNIOConnPool {
@Test
public void testSetMaxPerRoute() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
pool.setMaxPerRoute("somehost", 1);
Assert.assertEquals(1, pool.getMaxPerRoute("somehost"));
pool.setMaxPerRoute("somehost", 0);
@@ -1019,12 +1019,12 @@ public class TestNIOConnPool {
@Test
public void testShutdown() throws Exception {
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 2, 2);
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 2, 2);
pool.shutdown(1000);
- Mockito.verify(ioreactor, Mockito.times(1)).shutdown(1000);
+ Mockito.verify(ioReactor, Mockito.times(1)).shutdown(1000);
pool.shutdown(1000);
- Mockito.verify(ioreactor, Mockito.times(1)).shutdown(1000);
+ Mockito.verify(ioReactor, Mockito.times(1)).shutdown(1000);
try {
pool.lease("somehost", null);
Assert.fail("IllegalStateException should have been thrown");
@@ -1040,20 +1040,20 @@ public class TestNIOConnPool {
@Test
public void testLeaseRequestCanceled() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
- Mockito.when(iosession1.isClosed()).thenReturn(Boolean.TRUE);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
+ Mockito.when(ioSession1.isClosed()).thenReturn(Boolean.TRUE);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1);
- Mockito.when(ioreactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
+ Mockito.when(ioReactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 1, 1);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 1, 1);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null, 0, TimeUnit.MILLISECONDS, null);
future1.cancel(true);
@@ -1074,20 +1074,20 @@ public class TestNIOConnPool {
@Test
public void testLeaseRequestCanceledWhileConnecting() throws Exception {
- final IOSession iosession1 = Mockito.mock(IOSession.class);
- Mockito.when(iosession1.isClosed()).thenReturn(Boolean.TRUE);
+ final IOSession ioSession1 = Mockito.mock(IOSession.class);
+ Mockito.when(ioSession1.isClosed()).thenReturn(Boolean.TRUE);
final SessionRequest sessionRequest1 = Mockito.mock(SessionRequest.class);
Mockito.when(sessionRequest1.getAttachment()).thenReturn("somehost");
- Mockito.when(sessionRequest1.getSession()).thenReturn(iosession1);
+ Mockito.when(sessionRequest1.getSession()).thenReturn(ioSession1);
- final ConnectingIOReactor ioreactor = Mockito.mock(ConnectingIOReactor.class);
- Mockito.when(ioreactor.connect(
+ final ConnectingIOReactor ioReactor = Mockito.mock(ConnectingIOReactor.class);
+ Mockito.when(ioReactor.connect(
Matchers.any(SocketAddress.class), Matchers.any(SocketAddress.class),
Matchers.any(), Matchers.any(SessionRequestCallback.class))).
thenReturn(sessionRequest1);
- Mockito.when(ioreactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
+ Mockito.when(ioReactor.getStatus()).thenReturn(IOReactorStatus.ACTIVE);
- final LocalSessionPool pool = new LocalSessionPool(ioreactor, 1, 1);
+ final LocalSessionPool pool = new LocalSessionPool(ioReactor, 1, 1);
final Future<LocalPoolEntry> future1 = pool.lease("somehost", null, 0, TimeUnit.MILLISECONDS, null);
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ClientConnectionFactory.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ClientConnectionFactory.java b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ClientConnectionFactory.java
index 0042772..b6121b6 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ClientConnectionFactory.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ClientConnectionFactory.java
@@ -56,14 +56,14 @@ public class ClientConnectionFactory implements NHttpConnectionFactory<DefaultNH
}
@Override
- public DefaultNHttpClientConnection createConnection(final IOSession iosession) {
+ public DefaultNHttpClientConnection createConnection(final IOSession ioSession) {
if (this.sslContext != null) {
- final SSLIOSession ssliosession = new SSLIOSession(
- iosession, SSLMode.CLIENT, this.sslContext, this.setupHandler);
- iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
- return new LoggingNHttpClientConnection(ssliosession);
+ final SSLIOSession sslioSession = new SSLIOSession(
+ ioSession, SSLMode.CLIENT, this.sslContext, this.setupHandler);
+ ioSession.setAttribute(SSLIOSession.SESSION_KEY, sslioSession);
+ return new LoggingNHttpClientConnection(sslioSession);
} else {
- return new LoggingNHttpClientConnection(iosession);
+ return new LoggingNHttpClientConnection(ioSession);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingIOSession.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingIOSession.java b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingIOSession.java
index 4aa4c03..b898b7a 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingIOSession.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingIOSession.java
@@ -45,18 +45,18 @@ import org.apache.http.nio.reactor.SessionBufferStatus;
public class LoggingIOSession implements IOSession {
private final Log log;
- private final Wire wirelog;
+ private final Wire wireLog;
private final String id;
private final IOSession session;
private final ByteChannel channel;
- public LoggingIOSession(final IOSession session, final String id, final Log log, final Log wirelog) {
+ public LoggingIOSession(final IOSession session, final String id, final Log log, final Log wireLog) {
super();
this.session = session;
this.channel = new LoggingByteChannel();
this.id = id;
this.log = log;
- this.wirelog = new Wire(wirelog, this.id);
+ this.wireLog = new Wire(wireLog, this.id);
}
@Override
@@ -210,12 +210,12 @@ public class LoggingIOSession implements IOSession {
if (log.isDebugEnabled()) {
log.debug(id + " " + session + ": " + bytesRead + " bytes read");
}
- if (bytesRead > 0 && wirelog.isEnabled()) {
+ if (bytesRead > 0 && wireLog.isEnabled()) {
final ByteBuffer b = dst.duplicate();
final int p = b.position();
b.limit(p);
b.position(p - bytesRead);
- wirelog.input(b);
+ wireLog.input(b);
}
return bytesRead;
}
@@ -226,12 +226,12 @@ public class LoggingIOSession implements IOSession {
if (log.isDebugEnabled()) {
log.debug(id + " " + session + ": " + byteWritten + " bytes written");
}
- if (byteWritten > 0 && wirelog.isEnabled()) {
+ if (byteWritten > 0 && wireLog.isEnabled()) {
final ByteBuffer b = src.duplicate();
final int p = b.position();
b.limit(p);
b.position(p - byteWritten);
- wirelog.output(b);
+ wireLog.output(b);
}
return byteWritten;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpClientConnection.java b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpClientConnection.java
index 60dbb57..4428e29 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpClientConnection.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpClientConnection.java
@@ -46,19 +46,19 @@ public class LoggingNHttpClientConnection extends DefaultNHttpClientConnection {
private final Log log;
private final Log iolog;
- private final Log headerlog;
- private final Log wirelog;
+ private final Log headerLog;
+ private final Log wireLog;
private final String id;
public LoggingNHttpClientConnection(final IOSession session) {
super(session, 8 * 1024);
this.log = LogFactory.getLog(getClass());
this.iolog = LogFactory.getLog(session.getClass());
- this.headerlog = LogFactory.getLog("org.apache.http.headers");
- this.wirelog = LogFactory.getLog("org.apache.http.wire");
+ this.headerLog = LogFactory.getLog("org.apache.http.headers");
+ this.wireLog = LogFactory.getLog("org.apache.http.wire");
this.id = "http-outgoing-" + COUNT.incrementAndGet();
- if (this.iolog.isDebugEnabled() || this.wirelog.isDebugEnabled()) {
- this.session = new LoggingIOSession(session, this.id, this.iolog, this.wirelog);
+ if (this.iolog.isDebugEnabled() || this.wireLog.isDebugEnabled()) {
+ this.session = new LoggingIOSession(session, this.id, this.iolog, this.wireLog);
}
}
@@ -104,22 +104,22 @@ public class LoggingNHttpClientConnection extends DefaultNHttpClientConnection {
@Override
protected void onResponseReceived(final HttpResponse response) {
- if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(this.id + " << " + response.getStatusLine().toString());
+ if (response != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(this.id + " << " + response.getStatusLine().toString());
final Header[] headers = response.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(this.id + " << " + header.toString());
+ this.headerLog.debug(this.id + " << " + header.toString());
}
}
}
@Override
protected void onRequestSubmitted(final HttpRequest request) {
- if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(id + " >> " + request.getRequestLine().toString());
+ if (request != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(id + " >> " + request.getRequestLine().toString());
final Header[] headers = request.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(this.id + " >> " + header.toString());
+ this.headerLog.debug(this.id + " >> " + header.toString());
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpServerConnection.java b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpServerConnection.java
index 6004ef1..218dec8 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpServerConnection.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/LoggingNHttpServerConnection.java
@@ -46,19 +46,19 @@ public class LoggingNHttpServerConnection extends DefaultNHttpServerConnection {
private final Log log;
private final Log iolog;
- private final Log headerlog;
- private final Log wirelog;
+ private final Log headerLog;
+ private final Log wireLog;
private final String id;
public LoggingNHttpServerConnection(final IOSession session) {
super(session, 8 * 1024);
this.log = LogFactory.getLog(getClass());
this.iolog = LogFactory.getLog(session.getClass());
- this.headerlog = LogFactory.getLog("org.apache.http.headers");
- this.wirelog = LogFactory.getLog("org.apache.http.wire");
+ this.headerLog = LogFactory.getLog("org.apache.http.headers");
+ this.wireLog = LogFactory.getLog("org.apache.http.wire");
this.id = "http-incoming-" + COUNT.incrementAndGet();
- if (this.iolog.isDebugEnabled() || this.wirelog.isDebugEnabled()) {
- this.session = new LoggingIOSession(session, this.id, this.iolog, this.wirelog);
+ if (this.iolog.isDebugEnabled() || this.wireLog.isDebugEnabled()) {
+ this.session = new LoggingIOSession(session, this.id, this.iolog, this.wireLog);
}
}
@@ -104,22 +104,22 @@ public class LoggingNHttpServerConnection extends DefaultNHttpServerConnection {
@Override
protected void onRequestReceived(final HttpRequest request) {
- if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(this.id + " >> " + request.getRequestLine().toString());
+ if (request != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(this.id + " >> " + request.getRequestLine().toString());
final Header[] headers = request.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(this.id + " >> " + header.toString());
+ this.headerLog.debug(this.id + " >> " + header.toString());
}
}
}
@Override
protected void onResponseSubmitted(final HttpResponse response) {
- if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(this.id + " << " + response.getStatusLine().toString());
+ if (response != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(this.id + " << " + response.getStatusLine().toString());
final Header[] headers = response.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(this.id + " << " + header.toString());
+ this.headerLog.debug(this.id + " << " + header.toString());
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ServerConnectionFactory.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ServerConnectionFactory.java b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ServerConnectionFactory.java
index 4c0b174..151212f 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ServerConnectionFactory.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/testserver/ServerConnectionFactory.java
@@ -56,14 +56,14 @@ public class ServerConnectionFactory implements NHttpConnectionFactory<DefaultNH
}
@Override
- public DefaultNHttpServerConnection createConnection(final IOSession iosession) {
+ public DefaultNHttpServerConnection createConnection(final IOSession ioSession) {
if (this.sslContext != null) {
- final SSLIOSession ssliosession = new SSLIOSession(
- iosession, SSLMode.SERVER, this.sslContext, this.setupHandler);
- iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
- return new LoggingNHttpServerConnection(ssliosession);
+ final SSLIOSession sslioSession = new SSLIOSession(
+ ioSession, SSLMode.SERVER, this.sslContext, this.setupHandler);
+ ioSession.setAttribute(SSLIOSession.SESSION_KEY, sslioSession);
+ return new LoggingNHttpServerConnection(sslioSession);
} else {
- return new LoggingNHttpServerConnection(iosession);
+ return new LoggingNHttpServerConnection(ioSession);
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java b/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java
index dcf190c..fce3f53 100644
--- a/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java
+++ b/httpcore/src/main/java-deprecated/org/apache/http/impl/SocketHttpServerConnection.java
@@ -207,9 +207,8 @@ public class SocketHttpServerConnection extends
} catch (final SocketException ignore) {
return -1;
}
- } else {
- return -1;
}
+ return -1;
}
@Override
@@ -272,9 +271,8 @@ public class SocketHttpServerConnection extends
formatAddress(buffer, remoteAddress);
}
return buffer.toString();
- } else {
- return super.toString();
}
+ return super.toString();
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/HttpHost.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/HttpHost.java b/httpcore/src/main/java/org/apache/http/HttpHost.java
index cbd5ac0..50bad3c 100644
--- a/httpcore/src/main/java/org/apache/http/HttpHost.java
+++ b/httpcore/src/main/java/org/apache/http/HttpHost.java
@@ -287,9 +287,8 @@ public final class HttpHost implements Cloneable, Serializable {
buffer.append(":");
buffer.append(Integer.toString(this.port));
return buffer.toString();
- } else {
- return this.hostname;
}
+ return this.hostname;
}
@@ -310,9 +309,8 @@ public final class HttpHost implements Cloneable, Serializable {
&& this.port == that.port
&& this.schemeName.equals(that.schemeName)
&& (this.address==null ? that.address== null : this.address.equals(that.address));
- } else {
- return false;
}
+ return false;
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java b/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
index b8b2ca1..5402d4c 100644
--- a/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
+++ b/httpcore/src/main/java/org/apache/http/concurrent/BasicFuture.java
@@ -100,11 +100,10 @@ public class BasicFuture<T> implements Future<T>, Cancellable {
wait(waitTime);
if (this.completed) {
return getResult();
- } else {
- waitTime = msecs - (System.currentTimeMillis() - startTime);
- if (waitTime <= 0) {
- throw new TimeoutException();
- }
+ }
+ waitTime = msecs - (System.currentTimeMillis() - startTime);
+ if (waitTime <= 0) {
+ throw new TimeoutException();
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java b/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
index 4466aec..7b2330f 100644
--- a/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
+++ b/httpcore/src/main/java/org/apache/http/entity/BufferedHttpEntity.java
@@ -69,20 +69,12 @@ public class BufferedHttpEntity extends HttpEntityWrapper {
@Override
public long getContentLength() {
- if (this.buffer != null) {
- return this.buffer.length;
- } else {
- return super.getContentLength();
- }
+ return this.buffer != null ? this.buffer.length : super.getContentLength();
}
@Override
public InputStream getContent() throws IOException {
- if (this.buffer != null) {
- return new ByteArrayInputStream(this.buffer);
- } else {
- return super.getContent();
- }
+ return this.buffer != null ? new ByteArrayInputStream(this.buffer) : super.getContent();
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/entity/ContentType.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/entity/ContentType.java b/httpcore/src/main/java/org/apache/http/entity/ContentType.java
index 8398ddb..be2b43c 100644
--- a/httpcore/src/main/java/org/apache/http/entity/ContentType.java
+++ b/httpcore/src/main/java/org/apache/http/entity/ContentType.java
@@ -315,9 +315,8 @@ public final class ContentType implements Serializable {
final HeaderElement[] elements = BasicHeaderValueParser.INSTANCE.parseElements(buf, cursor);
if (elements.length > 0) {
return create(elements[0], true);
- } else {
- throw new ParseException("Invalid content type: " + s);
}
+ throw new ParseException("Invalid content type: " + s);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java b/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
index 165f9a9..cedd6a0 100644
--- a/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
+++ b/httpcore/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
@@ -88,9 +88,9 @@ public class BHttpConnectionBase implements HttpInetConnection {
*
* @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param messageConstraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -102,8 +102,8 @@ public class BHttpConnectionBase implements HttpInetConnection {
protected BHttpConnectionBase(
final int bufferSize,
final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints messageConstraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
@@ -112,9 +112,9 @@ public class BHttpConnectionBase implements HttpInetConnection {
final HttpTransportMetricsImpl inTransportMetrics = new HttpTransportMetricsImpl();
final HttpTransportMetricsImpl outTransportMetrics = new HttpTransportMetricsImpl();
this.inBuffer = new SessionInputBufferImpl(inTransportMetrics, bufferSize, -1,
- messageConstraints != null ? messageConstraints : MessageConstraints.DEFAULT, chardecoder);
+ messageConstraints != null ? messageConstraints : MessageConstraints.DEFAULT, charDecoder);
this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, bufferSize, fragmentSizeHint,
- charencoder);
+ charEncoder);
this.messageConstraints = messageConstraints;
this.connMetrics = new HttpConnectionMetricsImpl(inTransportMetrics, outTransportMetrics);
this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
@@ -291,9 +291,8 @@ public class BHttpConnectionBase implements HttpInetConnection {
} catch (final SocketException ignore) {
return -1;
}
- } else {
- return -1;
}
+ return -1;
}
@Override
@@ -395,9 +394,8 @@ public class BHttpConnectionBase implements HttpInetConnection {
NetUtils.formatAddress(buffer, remoteAddress);
}
return buffer.toString();
- } else {
- return "[Not bound]";
}
+ return "[Not bound]";
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/impl/ConnSupport.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/ConnSupport.java b/httpcore/src/main/java/org/apache/http/impl/ConnSupport.java
index a957629..d4320c3 100644
--- a/httpcore/src/main/java/org/apache/http/impl/ConnSupport.java
+++ b/httpcore/src/main/java/org/apache/http/impl/ConnSupport.java
@@ -51,9 +51,8 @@ public final class ConnSupport {
return charset.newDecoder()
.onMalformedInput(malformed != null ? malformed : CodingErrorAction.REPORT)
.onUnmappableCharacter(unmappable != null ? unmappable: CodingErrorAction.REPORT);
- } else {
- return null;
}
+ return null;
}
public static CharsetEncoder createEncoder(final ConnectionConfig cconfig) {
@@ -67,9 +66,8 @@ public final class ConnSupport {
return charset.newEncoder()
.onMalformedInput(malformed != null ? malformed : CodingErrorAction.REPORT)
.onUnmappableCharacter(unmappable != null ? unmappable: CodingErrorAction.REPORT);
- } else {
- return null;
}
+ return null;
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java b/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
index 44c614a..5ace305 100644
--- a/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
@@ -67,9 +67,9 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
*
* @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -85,14 +85,14 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
public DefaultBHttpClientConnection(
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);
this.requestWriter = (requestWriterFactory != null ? requestWriterFactory :
DefaultHttpRequestWriterFactory.INSTANCE).create(getSessionOutputBuffer());
@@ -102,10 +102,10 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
public DefaultBHttpClientConnection(
final int bufferSize,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints) {
- this(bufferSize, bufferSize, chardecoder, charencoder, constraints, null, null, null, null);
+ this(bufferSize, bufferSize, charDecoder, charEncoder, constraints, null, null, null, null);
}
public DefaultBHttpClientConnection(final int bufferSize) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java b/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
index 5e9f65d..26a8a58 100644
--- a/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
+++ b/httpcore/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
@@ -65,9 +65,9 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
*
* @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -83,14 +83,14 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
public DefaultBHttpServerConnection(
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 HttpMessageParserFactory<HttpRequest> requestParserFactory,
final HttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
- super(bufferSize, fragmentSizeHint, chardecoder, charencoder, constraints,
+ super(bufferSize, fragmentSizeHint, charDecoder, charEncoder, constraints,
incomingContentStrategy != null ? incomingContentStrategy :
DisallowIdentityContentLengthStrategy.INSTANCE, outgoingContentStrategy);
this.requestParser = (requestParserFactory != null ? requestParserFactory :
@@ -101,10 +101,10 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
public DefaultBHttpServerConnection(
final int bufferSize,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints) {
- this(bufferSize, bufferSize, chardecoder, charencoder, constraints, null, null, null, null);
+ this(bufferSize, bufferSize, charDecoder, charEncoder, constraints, null, null, null, null);
}
public DefaultBHttpServerConnection(final int bufferSize) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/impl/HttpConnectionMetricsImpl.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/HttpConnectionMetricsImpl.java b/httpcore/src/main/java/org/apache/http/impl/HttpConnectionMetricsImpl.java
index c3106c5..b9f786c 100644
--- a/httpcore/src/main/java/org/apache/http/impl/HttpConnectionMetricsImpl.java
+++ b/httpcore/src/main/java/org/apache/http/impl/HttpConnectionMetricsImpl.java
@@ -67,20 +67,12 @@ public class HttpConnectionMetricsImpl implements HttpConnectionMetrics {
@Override
public long getReceivedBytesCount() {
- if (this.inTransportMetric != null) {
- return this.inTransportMetric.getBytesTransferred();
- } else {
- return -1;
- }
+ return this.inTransportMetric != null ? this.inTransportMetric.getBytesTransferred() : -1;
}
@Override
public long getSentBytesCount() {
- if (this.outTransportMetric != null) {
- return this.outTransportMetric.getBytesTransferred();
- } else {
- return -1;
- }
+ return this.outTransportMetric != null ? this.outTransportMetric.getBytesTransferred() : -1;
}
@Override
@@ -113,17 +105,13 @@ public class HttpConnectionMetricsImpl implements HttpConnectionMetrics {
} else if (RESPONSE_COUNT.equals(metricName)) {
value = Long.valueOf(responseCount);
} else if (RECEIVED_BYTES_COUNT.equals(metricName)) {
- if (this.inTransportMetric != null) {
- return Long.valueOf(this.inTransportMetric.getBytesTransferred());
- } else {
- return null;
- }
+ return this.inTransportMetric != null
+ ? Long.valueOf(this.inTransportMetric.getBytesTransferred())
+ : null;
} else if (SENT_BYTES_COUNT.equals(metricName)) {
- if (this.outTransportMetric != null) {
- return Long.valueOf(this.outTransportMetric.getBytesTransferred());
- } else {
- return null;
- }
+ return this.outTransportMetric != null
+ ? Long.valueOf(this.outTransportMetric.getBytesTransferred())
+ : null;
}
}
return value;
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java b/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java
index 696aae5..c2eef30 100644
--- a/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java
+++ b/httpcore/src/main/java/org/apache/http/impl/bootstrap/HttpServer.java
@@ -99,20 +99,12 @@ public class HttpServer {
public InetAddress getInetAddress() {
final ServerSocket localSocket = this.serverSocket;
- if (localSocket != null) {
- return localSocket.getInetAddress();
- } else {
- return null;
- }
+ return localSocket != null ? localSocket.getInetAddress() : null;
}
public int getLocalPort() {
final ServerSocket localSocket = this.serverSocket;
- if (localSocket != null) {
- return localSocket.getLocalPort();
- } else {
- return -1;
- }
+ return localSocket != null ? localSocket.getLocalPort() : -1;
}
public void start() throws IOException {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java b/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
index d5dd611..aa18110 100644
--- a/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
+++ b/httpcore/src/main/java/org/apache/http/impl/entity/LaxContentLengthStrategy.java
@@ -105,22 +105,18 @@ public class LaxContentLengthStrategy implements ContentLengthStrategy {
}
final Header contentLengthHeader = message.getFirstHeader(HTTP.CONTENT_LEN);
if (contentLengthHeader != null) {
- long contentlen = -1;
+ long contentLen = -1;
final Header[] headers = message.getHeaders(HTTP.CONTENT_LEN);
for (int i = headers.length - 1; i >= 0; i--) {
final Header header = headers[i];
try {
- contentlen = Long.parseLong(header.getValue());
+ contentLen = Long.parseLong(header.getValue());
break;
} catch (final NumberFormatException ignore) {
}
// See if we can have better luck with another header, if present
}
- if (contentlen >= 0) {
- return contentlen;
- } else {
- return IDENTITY;
- }
+ return contentLen >= 0 ? contentLen : IDENTITY;
}
return this.implicitLen;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java b/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
index 68fe740..7456c15 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/ChunkedInputStream.java
@@ -119,9 +119,8 @@ public class ChunkedInputStream extends InputStream {
if (this.in instanceof BufferInfo) {
final int len = ((BufferInfo) this.in).length();
return (int) Math.min(len, this.chunkSize - this.pos);
- } else {
- return 0;
}
+ return 0;
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
index c4d8848..f2617d1 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/ContentLengthInputStream.java
@@ -114,9 +114,8 @@ public class ContentLengthInputStream extends InputStream {
if (this.in instanceof BufferInfo) {
final int len = ((BufferInfo) this.in).length();
return Math.min(len, (int) (this.contentLength - this.pos));
- } else {
- return 0;
}
+ return 0;
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java b/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
index 19175bc..c5883c1 100644
--- a/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
+++ b/httpcore/src/main/java/org/apache/http/impl/io/SessionOutputBufferImpl.java
@@ -73,21 +73,21 @@ public class SessionOutputBufferImpl implements SessionOutputBuffer, BufferInfo
* @param fragementSizeHint fragment size hint defining a minimal size of a fragment
* that should be written out directly to the socket bypassing the session buffer.
* Value {@code 0} disables fragment buffering.
- * @param charencoder charencoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder charEncoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
*/
public SessionOutputBufferImpl(
final HttpTransportMetricsImpl metrics,
final int bufferSize,
final int fragementSizeHint,
- final CharsetEncoder charencoder) {
+ final CharsetEncoder charEncoder) {
super();
Args.positive(bufferSize, "Buffer size");
Args.notNull(metrics, "HTTP transport metrcis");
this.metrics = metrics;
this.buffer = new ByteArrayBuffer(bufferSize);
this.fragementSizeHint = fragementSizeHint >= 0 ? fragementSizeHint : 0;
- this.encoder = charencoder;
+ this.encoder = charEncoder;
}
public SessionOutputBufferImpl(
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java b/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java
index 1182d10..71ac53e 100644
--- a/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java
+++ b/httpcore/src/main/java/org/apache/http/message/BasicHeaderElement.java
@@ -124,9 +124,8 @@ public class BasicHeaderElement implements HeaderElement, Cloneable {
return this.name.equals(that.name)
&& LangUtils.equals(this.value, that.value)
&& LangUtils.equals(this.parameters, that.parameters);
- } else {
- return false;
}
+ return false;
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java b/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
index 4bd16e8..2d9320d 100644
--- a/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
+++ b/httpcore/src/main/java/org/apache/http/message/BasicHeaderElementIterator.java
@@ -77,14 +77,13 @@ public class BasicHeaderElementIterator implements HeaderElementIterator {
this.cursor = new ParserCursor(0, this.buffer.length());
this.cursor.updatePos(((FormattedHeader) h).getValuePos());
break;
- } else {
- final String value = h.getValue();
- if (value != null) {
- this.buffer = new CharArrayBuffer(value.length());
- this.buffer.append(value);
- this.cursor = new ParserCursor(0, this.buffer.length());
- break;
- }
+ }
+ final String value = h.getValue();
+ if (value != null) {
+ this.buffer = new CharArrayBuffer(value.length());
+ this.buffer.append(value);
+ this.cursor = new ParserCursor(0, this.buffer.length());
+ break;
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/message/TokenParser.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/message/TokenParser.java b/httpcore/src/main/java/org/apache/http/message/TokenParser.java
index 884b7c0..31baacb 100644
--- a/httpcore/src/main/java/org/apache/http/message/TokenParser.java
+++ b/httpcore/src/main/java/org/apache/http/message/TokenParser.java
@@ -158,9 +158,8 @@ public class TokenParser {
final char current = buf.charAt(i);
if (!isWhitespace(current)) {
break;
- } else {
- pos++;
}
+ pos++;
}
cursor.updatePos(pos);
}
@@ -184,10 +183,9 @@ public class TokenParser {
final char current = buf.charAt(i);
if ((delimiters != null && delimiters.get(current)) || isWhitespace(current)) {
break;
- } else {
- pos++;
- dst.append(current);
}
+ pos++;
+ dst.append(current);
}
cursor.updatePos(pos);
}
@@ -212,10 +210,9 @@ public class TokenParser {
if ((delimiters != null && delimiters.get(current))
|| isWhitespace(current) || current == DQUOTE) {
break;
- } else {
- pos++;
- dst.append(current);
}
+ pos++;
+ dst.append(current);
}
cursor.updatePos(pos);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java b/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
index 18655ad..c27276f 100644
--- a/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
+++ b/httpcore/src/main/java/org/apache/http/params/BasicHttpParams.java
@@ -84,9 +84,8 @@ public class BasicHttpParams extends AbstractHttpParams implements Serializable,
if (this.parameters.containsKey(name)) {
this.parameters.remove(name);
return true;
- } else {
- return false;
}
+ return false;
}
/**
[3/3] httpcomponents-core 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.)
Posted by gg...@apache.org.
- 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-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/d956f67e
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/d956f67e
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/d956f67e
Branch: refs/heads/4.4.x
Commit: d956f67e68d0fa60b68343b11f80d64ff1ed95de
Parents: 14e3a19
Author: Gary Gregory <ga...@gmail.com>
Authored: Tue Aug 14 08:58:48 2018 -0600
Committer: Gary Gregory <ga...@gmail.com>
Committed: Tue Aug 14 08:58:48 2018 -0600
----------------------------------------------------------------------
.../apache/http/benchmark/BenchmarkWorker.java | 6 +-
.../http/examples/nio/NHttpReverseProxy.java | 4 +-
.../nio/reactor/SSLIOSessionHandlerAdaptor.java | 4 +-
.../http/impl/nio/reactor/SSLSetupHandler.java | 4 +-
.../nio/reactor/SSLSetupHandlerAdaptor.java | 4 +-
.../impl/nio/ssl/SSLClientIOEventDispatch.java | 14 +-
.../impl/nio/ssl/SSLServerIOEventDispatch.java | 14 +-
.../impl/nio/DefaultNHttpClientConnection.java | 16 +-
.../impl/nio/DefaultNHttpServerConnection.java | 16 +-
.../http/impl/nio/NHttpConnectionBase.java | 22 +-
.../nio/SSLNHttpClientConnectionFactory.java | 14 +-
.../nio/SSLNHttpServerConnectionFactory.java | 14 +-
.../http/impl/nio/SessionHttpContext.java | 16 +-
.../http/impl/nio/pool/BasicNIOConnPool.java | 24 +-
.../impl/nio/reactor/AbstractIODispatch.java | 50 +--
.../http/nio/pool/AbstractNIOConnPool.java | 40 +--
.../http/nio/reactor/ssl/SSLIOSession.java | 4 +-
.../impl/nio/pool/TestBasicNIOConnPool.java | 8 +-
.../reactor/TestDefaultListeningIOReactor.java | 50 +--
.../http/nio/integration/TestCustomSSL.java | 4 +-
.../apache/http/nio/pool/TestNIOConnPool.java | 302 +++++++++----------
.../nio/testserver/ClientConnectionFactory.java | 12 +-
.../http/nio/testserver/LoggingIOSession.java | 14 +-
.../LoggingNHttpClientConnection.java | 24 +-
.../LoggingNHttpServerConnection.java | 24 +-
.../nio/testserver/ServerConnectionFactory.java | 12 +-
.../http/impl/SocketHttpServerConnection.java | 6 +-
.../src/main/java/org/apache/http/HttpHost.java | 6 +-
.../org/apache/http/concurrent/BasicFuture.java | 9 +-
.../apache/http/entity/BufferedHttpEntity.java | 12 +-
.../org/apache/http/entity/ContentType.java | 3 +-
.../apache/http/impl/BHttpConnectionBase.java | 18 +-
.../java/org/apache/http/impl/ConnSupport.java | 6 +-
.../http/impl/DefaultBHttpClientConnection.java | 16 +-
.../http/impl/DefaultBHttpServerConnection.java | 16 +-
.../http/impl/HttpConnectionMetricsImpl.java | 28 +-
.../apache/http/impl/bootstrap/HttpServer.java | 12 +-
.../impl/entity/LaxContentLengthStrategy.java | 10 +-
.../apache/http/impl/io/ChunkedInputStream.java | 3 +-
.../http/impl/io/ContentLengthInputStream.java | 3 +-
.../http/impl/io/SessionOutputBufferImpl.java | 6 +-
.../apache/http/message/BasicHeaderElement.java | 3 +-
.../message/BasicHeaderElementIterator.java | 15 +-
.../org/apache/http/message/TokenParser.java | 13 +-
.../org/apache/http/params/BasicHttpParams.java | 3 +-
.../org/apache/http/pool/AbstractConnPool.java | 25 +-
.../java/org/apache/http/pool/PoolEntry.java | 14 +-
.../org/apache/http/pool/RouteSpecificPool.java | 6 +-
.../apache/http/protocol/HttpCoreContext.java | 8 +-
.../apache/http/protocol/UriPatternMatcher.java | 7 +-
.../java/org/apache/http/util/LangUtils.java | 16 +-
.../http/impl/SessionOutputBufferMock.java | 6 +-
.../impl/io/TimeoutByteArrayInputStream.java | 8 +-
.../java/org/apache/http/pool/TestConnPool.java | 8 +-
.../org/apache/http/pool/TestPoolEntry.java | 8 +-
.../apache/http/ssl/TestSSLContextBuilder.java | 6 +-
.../org/apache/http/testserver/HttpServer.java | 8 +-
.../LoggingBHttpClientConnection.java | 22 +-
.../LoggingBHttpServerConnection.java | 22 +-
59 files changed, 496 insertions(+), 572 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
----------------------------------------------------------------------
diff --git a/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java b/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
index d864c8e..7a07d7f 100644
--- a/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
+++ b/httpcore-ab/src/main/java/org/apache/http/benchmark/BenchmarkWorker.java
@@ -170,18 +170,18 @@ class BenchmarkWorker implements Runnable {
if (charset == null) {
charset = HTTP.DEF_CONTENT_CHARSET;
}
- long contentlen = 0;
+ long contentLen = 0;
final InputStream inStream = entity.getContent();
int l;
while ((l = inStream.read(this.buffer)) != -1) {
- contentlen += l;
+ contentLen += l;
if (config.getVerbosity() >= 4) {
final String s = new String(this.buffer, 0, l, charset);
System.out.print(s);
}
}
inStream.close();
- stats.setContentLength(contentlen);
+ stats.setContentLength(contentLen);
}
if (config.getVerbosity() >= 4) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java b/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
index 4a2469c..663875c 100644
--- a/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
+++ b/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
@@ -871,10 +871,10 @@ public class NHttpReverseProxy {
static class ProxyConnPool extends BasicNIOConnPool {
public ProxyConnPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final NIOConnFactory<HttpHost, NHttpClientConnection> connFactory,
final int connectTimeout) {
- super(ioreactor, connFactory, connectTimeout);
+ super(ioReactor, connFactory, connectTimeout);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLIOSessionHandlerAdaptor.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLIOSessionHandlerAdaptor.java b/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLIOSessionHandlerAdaptor.java
index 3b355a2..5019400 100644
--- a/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLIOSessionHandlerAdaptor.java
+++ b/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLIOSessionHandlerAdaptor.java
@@ -56,8 +56,8 @@ class SSLIOSessionHandlerAdaptor implements org.apache.http.nio.reactor.ssl.SSLS
}
@Override
- public void verify(final IOSession iosession, final SSLSession sslsession) throws SSLException {
- this.handler.verify(iosession.getRemoteAddress(), sslsession);
+ public void verify(final IOSession ioSession, final SSLSession sslsession) throws SSLException {
+ this.handler.verify(ioSession.getRemoteAddress(), sslsession);
}
public void setParams(final HttpParams params) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLSetupHandler.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLSetupHandler.java b/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLSetupHandler.java
index fc867a7..351cb3b 100644
--- a/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLSetupHandler.java
+++ b/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLSetupHandler.java
@@ -64,11 +64,11 @@ public interface SSLSetupHandler {
* For instance this would be the right place to enforce SSL cipher
* strength, validate certificate chain and do hostname checks.
*
- * @param iosession the underlying IOSession for the SSL connection.
+ * @param ioSession the underlying IOSession for the SSL connection.
* @param sslsession newly created SSL session.
* @throws SSLException if case of SSL protocol error.
*/
- void verify(IOSession iosession, SSLSession sslsession)
+ void verify(IOSession ioSession, SSLSession sslsession)
throws SSLException;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLSetupHandlerAdaptor.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLSetupHandlerAdaptor.java b/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLSetupHandlerAdaptor.java
index d49bb8d..480f438 100644
--- a/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLSetupHandlerAdaptor.java
+++ b/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/reactor/SSLSetupHandlerAdaptor.java
@@ -56,8 +56,8 @@ class SSLSetupHandlerAdaptor implements org.apache.http.nio.reactor.ssl.SSLSetup
}
@Override
- public void verify(final IOSession iosession, final SSLSession sslsession) throws SSLException {
- this.handler.verify(iosession, sslsession);
+ public void verify(final IOSession ioSession, final SSLSession sslsession) throws SSLException {
+ this.handler.verify(ioSession, sslsession);
}
public void setParams(final HttpParams params) {
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java b/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java
index d7d87ab..b404a69 100644
--- a/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java
+++ b/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/ssl/SSLClientIOEventDispatch.java
@@ -113,20 +113,20 @@ public class SSLClientIOEventDispatch extends DefaultClientIOEventDispatch {
return new SSLIOSession(session, sslContext, sslHandler);
}
- protected NHttpClientIOTarget createSSLConnection(final SSLIOSession ssliosession) {
- return super.createConnection(ssliosession);
+ protected NHttpClientIOTarget createSSLConnection(final SSLIOSession sslioSession) {
+ return super.createConnection(sslioSession);
}
@Override
protected NHttpClientIOTarget createConnection(final IOSession session) {
- final SSLIOSession ssliosession = createSSLIOSession(session, this.sslContext, this.sslHandler);
- session.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
- final NHttpClientIOTarget conn = createSSLConnection(ssliosession);
+ final SSLIOSession sslioSession = createSSLIOSession(session, this.sslContext, this.sslHandler);
+ session.setAttribute(SSLIOSession.SESSION_KEY, sslioSession);
+ final NHttpClientIOTarget conn = createSSLConnection(sslioSession);
try {
- ssliosession.initialize();
+ sslioSession.initialize();
} catch (final SSLException ex) {
this.handler.exception(conn, ex);
- ssliosession.shutdown();
+ sslioSession.shutdown();
}
return conn;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java b/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java
index cf1d413..fa6f004 100644
--- a/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java
+++ b/httpcore-nio/src/main/java-deprecated/org/apache/http/impl/nio/ssl/SSLServerIOEventDispatch.java
@@ -113,20 +113,20 @@ public class SSLServerIOEventDispatch extends DefaultServerIOEventDispatch {
return new SSLIOSession(session, sslContext, sslHandler);
}
- protected NHttpServerIOTarget createSSLConnection(final SSLIOSession ssliosession) {
- return super.createConnection(ssliosession);
+ protected NHttpServerIOTarget createSSLConnection(final SSLIOSession sslioSession) {
+ return super.createConnection(sslioSession);
}
@Override
protected NHttpServerIOTarget createConnection(final IOSession session) {
- final SSLIOSession ssliosession = createSSLIOSession(session, this.sslContext, this.sslHandler);
- session.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
- final NHttpServerIOTarget conn = createSSLConnection(ssliosession);
+ final SSLIOSession sslioSession = createSSLIOSession(session, this.sslContext, this.sslHandler);
+ session.setAttribute(SSLIOSession.SESSION_KEY, sslioSession);
+ final NHttpServerIOTarget conn = createSSLConnection(sslioSession);
try {
- ssliosession.initialize();
+ sslioSession.initialize();
} catch (final SSLException ex) {
this.handler.exception(conn, ex);
- ssliosession.shutdown();
+ sslioSession.shutdown();
}
return conn;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
index 4bbab09..cb9bd59 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
@@ -110,9 +110,9 @@ public class DefaultNHttpClientConnection
* @param allocator memory allocator.
* If {@code null} {@link org.apache.http.nio.util.HeapByteBufferAllocator#INSTANCE}
* will be used.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -128,14 +128,14 @@ public class DefaultNHttpClientConnection
final int bufferSize,
final int fragmentSizeHint,
final ByteBufferAllocator allocator,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final NHttpMessageWriterFactory<HttpRequest> requestWriterFactory,
final NHttpMessageParserFactory<HttpResponse> responseParserFactory) {
- super(session, bufferSize, fragmentSizeHint, allocator, chardecoder, charencoder,
+ super(session, bufferSize, fragmentSizeHint, allocator, charDecoder, charEncoder,
constraints, incomingContentStrategy, outgoingContentStrategy);
this.requestWriter = (requestWriterFactory != null ? requestWriterFactory :
DefaultHttpRequestWriterFactory.INSTANCE).create(this.outbuf);
@@ -149,10 +149,10 @@ public class DefaultNHttpClientConnection
public DefaultNHttpClientConnection(
final IOSession session,
final int bufferSize,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints) {
- this(session, bufferSize, bufferSize, null, chardecoder, charencoder, constraints,
+ this(session, bufferSize, bufferSize, null, charDecoder, charEncoder, constraints,
null, null, null, null);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
index cef68f1..8d7ee6b 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
@@ -110,9 +110,9 @@ public class DefaultNHttpServerConnection
* @param allocator memory allocator.
* If {@code null} {@link org.apache.http.nio.util.HeapByteBufferAllocator#INSTANCE}
* will be used.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -132,14 +132,14 @@ public class DefaultNHttpServerConnection
final int bufferSize,
final int fragmentSizeHint,
final ByteBufferAllocator allocator,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final NHttpMessageParserFactory<HttpRequest> requestParserFactory,
final NHttpMessageWriterFactory<HttpResponse> responseWriterFactory) {
- super(session, bufferSize, fragmentSizeHint, allocator, chardecoder, charencoder,
+ super(session, bufferSize, fragmentSizeHint, allocator, charDecoder, charEncoder,
constraints,
incomingContentStrategy != null ? incomingContentStrategy :
DisallowIdentityContentLengthStrategy.INSTANCE,
@@ -157,10 +157,10 @@ public class DefaultNHttpServerConnection
public DefaultNHttpServerConnection(
final IOSession session,
final int bufferSize,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints) {
- this(session, bufferSize, bufferSize, null, chardecoder, charencoder, constraints,
+ this(session, bufferSize, bufferSize, null, charDecoder, charEncoder, constraints,
null, null, null, null);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
index a071346..713cc03 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/NHttpConnectionBase.java
@@ -189,9 +189,9 @@ public class NHttpConnectionBase
* @param allocator memory allocator.
* If {@code null} {@link org.apache.http.nio.util.HeapByteBufferAllocator#INSTANCE}
* will be used.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -207,8 +207,8 @@ public class NHttpConnectionBase
final int bufferSize,
final int fragmentSizeHint,
final ByteBufferAllocator allocator,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
@@ -218,8 +218,8 @@ public class NHttpConnectionBase
if (lineBufferSize > 512) {
lineBufferSize = 512;
}
- this.inbuf = new SessionInputBufferImpl(bufferSize, lineBufferSize, chardecoder, allocator);
- this.outbuf = new SessionOutputBufferImpl(bufferSize, lineBufferSize, charencoder, allocator);
+ this.inbuf = new SessionInputBufferImpl(bufferSize, lineBufferSize, charDecoder, allocator);
+ this.outbuf = new SessionOutputBufferImpl(bufferSize, lineBufferSize, charEncoder, allocator);
this.fragmentSizeHint = fragmentSizeHint >= 0 ? fragmentSizeHint : bufferSize;
this.inTransportMetrics = new HttpTransportMetricsImpl();
@@ -244,9 +244,9 @@ public class NHttpConnectionBase
* @param allocator memory allocator.
* If {@code null} {@link org.apache.http.nio.util.HeapByteBufferAllocator#INSTANCE}
* will be used.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param incomingContentStrategy incoming content length strategy. If {@code null}
* {@link LaxContentLengthStrategy#INSTANCE} will be used.
@@ -260,11 +260,11 @@ public class NHttpConnectionBase
final int bufferSize,
final int fragmentSizeHint,
final ByteBufferAllocator allocator,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
- this(session, bufferSize, fragmentSizeHint, allocator, chardecoder, charencoder,
+ this(session, bufferSize, fragmentSizeHint, allocator, charDecoder, charEncoder,
null, incomingContentStrategy, outgoingContentStrategy);
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java/org/apache/http/impl/nio/SSLNHttpClientConnectionFactory.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/SSLNHttpClientConnectionFactory.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/SSLNHttpClientConnectionFactory.java
index 93d7bfe..6573c46 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/SSLNHttpClientConnectionFactory.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/SSLNHttpClientConnectionFactory.java
@@ -215,21 +215,21 @@ public class SSLNHttpClientConnectionFactory
* @since 4.3
*/
protected SSLIOSession createSSLIOSession(
- final IOSession iosession,
+ final IOSession ioSession,
final SSLContext sslContext,
final SSLSetupHandler sslHandler) {
- final Object attachment = iosession.getAttribute(IOSession.ATTACHMENT_KEY);
- return new SSLIOSession(iosession, SSLMode.CLIENT,
+ final Object attachment = ioSession.getAttribute(IOSession.ATTACHMENT_KEY);
+ return new SSLIOSession(ioSession, SSLMode.CLIENT,
attachment instanceof HttpHost ? (HttpHost) attachment : null,
sslContext, sslHandler);
}
@Override
- public DefaultNHttpClientConnection createConnection(final IOSession iosession) {
- final SSLIOSession ssliosession = createSSLIOSession(iosession, this.sslContext, this.sslHandler);
- iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
+ public DefaultNHttpClientConnection createConnection(final IOSession ioSession) {
+ final SSLIOSession sslioSession = createSSLIOSession(ioSession, this.sslContext, this.sslHandler);
+ ioSession.setAttribute(SSLIOSession.SESSION_KEY, sslioSession);
return new DefaultNHttpClientConnection(
- ssliosession,
+ sslioSession,
this.cconfig.getBufferSize(),
this.cconfig.getFragmentSizeHint(),
this.allocator,
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java/org/apache/http/impl/nio/SSLNHttpServerConnectionFactory.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/SSLNHttpServerConnectionFactory.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/SSLNHttpServerConnectionFactory.java
index 294f8af..74cab17 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/SSLNHttpServerConnectionFactory.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/SSLNHttpServerConnectionFactory.java
@@ -212,19 +212,19 @@ public class SSLNHttpServerConnectionFactory
* @since 4.3
*/
protected SSLIOSession createSSLIOSession(
- final IOSession iosession,
+ final IOSession ioSession,
final SSLContext sslContext,
final SSLSetupHandler sslHandler) {
- final SSLIOSession ssliosession = new SSLIOSession(iosession, SSLMode.SERVER,
+ final SSLIOSession sslioSession = new SSLIOSession(ioSession, SSLMode.SERVER,
sslContext, sslHandler);
- return ssliosession;
+ return sslioSession;
}
@Override
- public DefaultNHttpServerConnection createConnection(final IOSession iosession) {
- final SSLIOSession ssliosession = createSSLIOSession(iosession, this.sslContext, this.sslHandler);
- iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
- return new DefaultNHttpServerConnection(ssliosession,
+ public DefaultNHttpServerConnection createConnection(final IOSession ioSession) {
+ final SSLIOSession sslioSession = createSSLIOSession(ioSession, this.sslContext, this.sslHandler);
+ ioSession.setAttribute(SSLIOSession.SESSION_KEY, sslioSession);
+ return new DefaultNHttpServerConnection(sslioSession,
this.cconfig.getBufferSize(),
this.cconfig.getFragmentSizeHint(),
this.allocator,
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java/org/apache/http/impl/nio/SessionHttpContext.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/SessionHttpContext.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/SessionHttpContext.java
index 21b6ed6..d31cc72 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/SessionHttpContext.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/SessionHttpContext.java
@@ -32,26 +32,26 @@ import org.apache.http.protocol.HttpContext;
class SessionHttpContext implements HttpContext {
- private final IOSession iosession;
+ private final IOSession ioSession;
- public SessionHttpContext(final IOSession iosession) {
+ public SessionHttpContext(final IOSession ioSession) {
super();
- this.iosession = iosession;
+ this.ioSession = ioSession;
}
@Override
public Object getAttribute(final String id) {
- return this.iosession.getAttribute(id);
+ return this.ioSession.getAttribute(id);
}
@Override
public Object removeAttribute(final String id) {
- return this.iosession.removeAttribute(id);
+ return this.ioSession.removeAttribute(id);
}
@Override
public void setAttribute(final String id, final Object obj) {
- this.iosession.setAttribute(id, obj);
+ this.ioSession.setAttribute(id, obj);
}
/**
@@ -60,8 +60,8 @@ class SessionHttpContext implements HttpContext {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
- sb.append("[iosession=");
- sb.append(iosession);
+ sb.append("[ioSession=");
+ sb.append(ioSession);
sb.append("]");
return sb.toString();
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
index 2cf6f46..654af97 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/pool/BasicNIOConnPool.java
@@ -92,10 +92,10 @@ public class BasicNIOConnPool extends AbstractNIOConnPool<HttpHost, NHttpClientC
*/
@Deprecated
public BasicNIOConnPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final NIOConnFactory<HttpHost, NHttpClientConnection> connFactory,
final HttpParams params) {
- super(ioreactor, connFactory, 2, 20);
+ super(ioReactor, connFactory, 2, 20);
Args.notNull(params, "HTTP parameters");
this.connectTimeout = params.getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 0);
}
@@ -106,18 +106,18 @@ public class BasicNIOConnPool extends AbstractNIOConnPool<HttpHost, NHttpClientC
*/
@Deprecated
public BasicNIOConnPool(
- final ConnectingIOReactor ioreactor, final HttpParams params) {
- this(ioreactor, new BasicNIOConnFactory(params), params);
+ final ConnectingIOReactor ioReactor, final HttpParams params) {
+ this(ioReactor, new BasicNIOConnFactory(params), params);
}
/**
* @since 4.3
*/
public BasicNIOConnPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final NIOConnFactory<HttpHost, NHttpClientConnection> connFactory,
final int connectTimeout) {
- super(ioreactor, connFactory, new BasicAddressResolver(), 2, 20);
+ super(ioReactor, connFactory, new BasicAddressResolver(), 2, 20);
this.connectTimeout = connectTimeout;
}
@@ -125,26 +125,26 @@ public class BasicNIOConnPool extends AbstractNIOConnPool<HttpHost, NHttpClientC
* @since 4.3
*/
public BasicNIOConnPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final int connectTimeout,
final ConnectionConfig config) {
- this(ioreactor, new BasicNIOConnFactory(config), connectTimeout);
+ this(ioReactor, new BasicNIOConnFactory(config), connectTimeout);
}
/**
* @since 4.3
*/
public BasicNIOConnPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final ConnectionConfig config) {
- this(ioreactor, new BasicNIOConnFactory(config), 0);
+ this(ioReactor, new BasicNIOConnFactory(config), 0);
}
/**
* @since 4.3
*/
- public BasicNIOConnPool(final ConnectingIOReactor ioreactor) {
- this(ioreactor, new BasicNIOConnFactory(ConnectionConfig.DEFAULT), 0);
+ public BasicNIOConnPool(final ConnectingIOReactor ioReactor) {
+ this(ioReactor, new BasicNIOConnFactory(ConnectionConfig.DEFAULT), 0);
}
/**
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIODispatch.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIODispatch.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIODispatch.java
index a0fbb87..0326771 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIODispatch.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIODispatch.java
@@ -71,18 +71,18 @@ public abstract class AbstractIODispatch<T> implements IOEventDispatch {
session.setAttribute(IOEventDispatch.CONNECTION_KEY, conn);
}
onConnected(conn);
- final SSLIOSession ssliosession = (SSLIOSession) session.getAttribute(
+ final SSLIOSession sslioSession = (SSLIOSession) session.getAttribute(
SSLIOSession.SESSION_KEY);
- if (ssliosession != null) {
+ if (sslioSession != null) {
try {
- synchronized (ssliosession) {
- if (!ssliosession.isInitialized()) {
- ssliosession.initialize();
+ synchronized (sslioSession) {
+ if (!sslioSession.isInitialized()) {
+ sslioSession.initialize();
}
}
} catch (final IOException ex) {
onException(conn, ex);
- ssliosession.shutdown();
+ sslioSession.shutdown();
}
}
} catch (final RuntimeException ex) {
@@ -108,22 +108,22 @@ public abstract class AbstractIODispatch<T> implements IOEventDispatch {
T conn = (T) session.getAttribute(IOEventDispatch.CONNECTION_KEY);
try {
ensureNotNull(conn);
- final SSLIOSession ssliosession = (SSLIOSession) session.getAttribute(
+ final SSLIOSession sslioSession = (SSLIOSession) session.getAttribute(
SSLIOSession.SESSION_KEY);
- if (ssliosession == null) {
+ if (sslioSession == null) {
onInputReady(conn);
} else {
try {
- if (!ssliosession.isInitialized()) {
- ssliosession.initialize();
+ if (!sslioSession.isInitialized()) {
+ sslioSession.initialize();
}
- if (ssliosession.isAppInputReady()) {
+ if (sslioSession.isAppInputReady()) {
onInputReady(conn);
}
- ssliosession.inboundTransport();
+ sslioSession.inboundTransport();
} catch (final IOException ex) {
onException(conn, ex);
- ssliosession.shutdown();
+ sslioSession.shutdown();
}
}
} catch (final RuntimeException ex) {
@@ -139,22 +139,22 @@ public abstract class AbstractIODispatch<T> implements IOEventDispatch {
T conn = (T) session.getAttribute(IOEventDispatch.CONNECTION_KEY);
try {
ensureNotNull(conn);
- final SSLIOSession ssliosession = (SSLIOSession) session.getAttribute(
+ final SSLIOSession sslioSession = (SSLIOSession) session.getAttribute(
SSLIOSession.SESSION_KEY);
- if (ssliosession == null) {
+ if (sslioSession == null) {
onOutputReady(conn);
} else {
try {
- if (!ssliosession.isInitialized()) {
- ssliosession.initialize();
+ if (!sslioSession.isInitialized()) {
+ sslioSession.initialize();
}
- if (ssliosession.isAppOutputReady()) {
+ if (sslioSession.isAppOutputReady()) {
onOutputReady(conn);
}
- ssliosession.outboundTransport();
+ sslioSession.outboundTransport();
} catch (final IOException ex) {
onException(conn, ex);
- ssliosession.shutdown();
+ sslioSession.shutdown();
}
}
} catch (final RuntimeException ex) {
@@ -169,15 +169,15 @@ public abstract class AbstractIODispatch<T> implements IOEventDispatch {
final
T conn = (T) session.getAttribute(IOEventDispatch.CONNECTION_KEY);
try {
- final SSLIOSession ssliosession = (SSLIOSession) session.getAttribute(
+ final SSLIOSession sslioSession = (SSLIOSession) session.getAttribute(
SSLIOSession.SESSION_KEY);
ensureNotNull(conn);
onTimeout(conn);
- if (ssliosession != null) {
- synchronized (ssliosession) {
- if (ssliosession.isOutboundDone() && !ssliosession.isInboundDone()) {
+ if (sslioSession != null) {
+ synchronized (sslioSession) {
+ if (sslioSession.isOutboundDone() && !sslioSession.isInboundDone()) {
// The session failed to terminate cleanly
- ssliosession.shutdown();
+ sslioSession.shutdown();
}
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java b/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
index 179aea5..058ce58 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/pool/AbstractNIOConnPool.java
@@ -75,7 +75,7 @@ import org.apache.http.util.LangUtils;
public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>>
implements ConnPool<T, E>, ConnPoolControl<T> {
- private final ConnectingIOReactor ioreactor;
+ private final ConnectingIOReactor ioReactor;
private final NIOConnFactory<T, C> connFactory;
private final SocketAddressResolver<T> addressResolver;
private final SessionRequestCallback sessionRequestCallback;
@@ -98,16 +98,16 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>>
*/
@Deprecated
public AbstractNIOConnPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final NIOConnFactory<T, C> connFactory,
final int defaultMaxPerRoute,
final int maxTotal) {
super();
- Args.notNull(ioreactor, "I/O reactor");
+ Args.notNull(ioReactor, "I/O reactor");
Args.notNull(connFactory, "Connection factory");
Args.positive(defaultMaxPerRoute, "Max per route value");
Args.positive(maxTotal, "Max total value");
- this.ioreactor = ioreactor;
+ this.ioReactor = ioReactor;
this.connFactory = connFactory;
this.addressResolver = new SocketAddressResolver<T>() {
@@ -140,18 +140,18 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>>
* @since 4.3
*/
public AbstractNIOConnPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final NIOConnFactory<T, C> connFactory,
final SocketAddressResolver<T> addressResolver,
final int defaultMaxPerRoute,
final int maxTotal) {
super();
- Args.notNull(ioreactor, "I/O reactor");
+ Args.notNull(ioReactor, "I/O reactor");
Args.notNull(connFactory, "Connection factory");
Args.notNull(addressResolver, "Address resolver");
Args.positive(defaultMaxPerRoute, "Max per route value");
Args.positive(maxTotal, "Max total value");
- this.ioreactor = ioreactor;
+ this.ioReactor = ioReactor;
this.connFactory = connFactory;
this.addressResolver = addressResolver;
this.sessionRequestCallback = new InternalSessionRequestCallback();
@@ -230,7 +230,7 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>>
this.pending.clear();
this.available.clear();
this.leasingRequests.clear();
- this.ioreactor.shutdown(waitMs);
+ this.ioReactor.shutdown(waitMs);
} finally {
this.lock.unlock();
}
@@ -255,9 +255,9 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>>
public Future<E> lease(
final T route, final Object state,
- final long connectTimeout, final TimeUnit tunit,
+ final long connectTimeout, final TimeUnit timeUnit,
final FutureCallback<E> callback) {
- return this.lease(route, state, connectTimeout, connectTimeout, tunit, callback);
+ return this.lease(route, state, connectTimeout, connectTimeout, timeUnit, callback);
}
/**
@@ -265,15 +265,15 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>>
*/
public Future<E> lease(
final T route, final Object state,
- final long connectTimeout, final long leaseTimeout, final TimeUnit tunit,
+ final long connectTimeout, final long leaseTimeout, final TimeUnit timeUnit,
final FutureCallback<E> callback) {
Args.notNull(route, "Route");
- Args.notNull(tunit, "Time unit");
+ Args.notNull(timeUnit, "Time unit");
Asserts.check(!this.isShutDown.get(), "Connection pool shut down");
final BasicFuture<E> future = new BasicFuture<E>(callback);
final LeaseRequest<T, C, E> leaseRequest = new LeaseRequest<T, C, E>(route, state,
- connectTimeout >= 0 ? tunit.toMillis(connectTimeout) : -1,
- leaseTimeout > 0 ? tunit.toMillis(leaseTimeout) : 0,
+ connectTimeout >= 0 ? timeUnit.toMillis(connectTimeout) : -1,
+ leaseTimeout > 0 ? timeUnit.toMillis(leaseTimeout) : 0,
future);
this.lock.lock();
try {
@@ -478,7 +478,7 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>>
return false;
}
- final SessionRequest sessionRequest = this.ioreactor.connect(
+ final SessionRequest sessionRequest = this.ioReactor.connect(
remoteAddress, localAddress, route, this.sessionRequestCallback);
request.attachSessionRequest(sessionRequest);
final long connectTimeout = request.getConnectTimeout();
@@ -562,7 +562,7 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>>
onLease(entry);
} else {
this.available.add(entry);
- if (this.ioreactor.getStatus().compareTo(IOReactorStatus.ACTIVE) <= 0) {
+ if (this.ioReactor.getStatus().compareTo(IOReactorStatus.ACTIVE) <= 0) {
processNextPendingRequest();
}
}
@@ -587,7 +587,7 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>>
this.pending.remove(request);
final RouteSpecificPool<T, C, E> pool = getPool(route);
pool.cancelled(request);
- if (this.ioreactor.getStatus().compareTo(IOReactorStatus.ACTIVE) <= 0) {
+ if (this.ioReactor.getStatus().compareTo(IOReactorStatus.ACTIVE) <= 0) {
processNextPendingRequest();
}
} finally {
@@ -831,9 +831,9 @@ public abstract class AbstractNIOConnPool<T, C, E extends PoolEntry<T, C>>
}
}
- public void closeIdle(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
- long time = tunit.toMillis(idletime);
+ public void closeIdle(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
+ long time = timeUnit.toMillis(idletime);
if (time < 0) {
time = 0;
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java b/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java
index 297989b..641059b 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java
@@ -65,8 +65,8 @@ import org.apache.http.util.Asserts;
* SSLContext sslContext = SSLContext.getInstance("SSL");
* sslContext.init(null, null, null);
* SSLIOSession sslsession = new SSLIOSession(
- * iosession, SSLMode.CLIENT, sslContext, null);
- * iosession.setAttribute(SSLIOSession.SESSION_KEY, sslsession);
+ * ioSession, SSLMode.CLIENT, sslContext, null);
+ * ioSession.setAttribute(SSLIOSession.SESSION_KEY, sslsession);
* </pre>
*
* @since 4.2
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java b/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java
index 78f9cdc..25e2781 100644
--- a/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java
+++ b/httpcore-nio/src/test/java/org/apache/http/impl/nio/pool/TestBasicNIOConnPool.java
@@ -52,16 +52,16 @@ public class TestBasicNIOConnPool {
static class LocalPool extends BasicNIOConnPool {
public LocalPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final NIOConnFactory<HttpHost, NHttpClientConnection> connFactory,
final int connectTimeout) {
- super(ioreactor, connFactory, connectTimeout);
+ super(ioReactor, connFactory, connectTimeout);
}
public LocalPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final ConnectionConfig config) {
- super(ioreactor, config);
+ super(ioReactor, config);
}
@Override
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultListeningIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultListeningIOReactor.java b/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultListeningIOReactor.java
index fab6a58..784b423 100644
--- a/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultListeningIOReactor.java
+++ b/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultListeningIOReactor.java
@@ -74,14 +74,14 @@ public class TestDefaultListeningIOReactor {
public void testEndpointUpAndDown() throws Exception {
final IOEventDispatch eventDispatch = createIOEventDispatch();
final IOReactorConfig config = IOReactorConfig.custom().setIoThreadCount(1).build();
- final ListeningIOReactor ioreactor = new DefaultListeningIOReactor(config);
+ final ListeningIOReactor ioReactor = new DefaultListeningIOReactor(config);
final Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
- ioreactor.execute(eventDispatch);
+ ioReactor.execute(eventDispatch);
} catch (final IOException ex) {
}
}
@@ -90,24 +90,24 @@ public class TestDefaultListeningIOReactor {
t.start();
- Set<ListenerEndpoint> endpoints = ioreactor.getEndpoints();
+ Set<ListenerEndpoint> endpoints = ioReactor.getEndpoints();
Assert.assertNotNull(endpoints);
Assert.assertEquals(0, endpoints.size());
- final ListenerEndpoint endpoint1 = ioreactor.listen(new InetSocketAddress(0));
+ final ListenerEndpoint endpoint1 = ioReactor.listen(new InetSocketAddress(0));
endpoint1.waitFor();
- final ListenerEndpoint endpoint2 = ioreactor.listen(new InetSocketAddress(0));
+ final ListenerEndpoint endpoint2 = ioReactor.listen(new InetSocketAddress(0));
endpoint2.waitFor();
final int port = ((InetSocketAddress) endpoint2.getAddress()).getPort();
- endpoints = ioreactor.getEndpoints();
+ endpoints = ioReactor.getEndpoints();
Assert.assertNotNull(endpoints);
Assert.assertEquals(2, endpoints.size());
endpoint1.close();
- endpoints = ioreactor.getEndpoints();
+ endpoints = ioReactor.getEndpoints();
Assert.assertNotNull(endpoints);
Assert.assertEquals(1, endpoints.size());
@@ -115,17 +115,17 @@ public class TestDefaultListeningIOReactor {
Assert.assertEquals(port, ((InetSocketAddress) endpoint.getAddress()).getPort());
- ioreactor.shutdown(1000);
+ ioReactor.shutdown(1000);
t.join(1000);
- Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
+ Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioReactor.getStatus());
}
@Test
public void testEndpointAlreadyBoundFatal() throws Exception {
final IOEventDispatch eventDispatch = createIOEventDispatch();
final IOReactorConfig config = IOReactorConfig.custom().setIoThreadCount(1).build();
- final ListeningIOReactor ioreactor = new DefaultListeningIOReactor(config);
+ final ListeningIOReactor ioReactor = new DefaultListeningIOReactor(config);
final CountDownLatch latch = new CountDownLatch(1);
@@ -134,7 +134,7 @@ public class TestDefaultListeningIOReactor {
@Override
public void run() {
try {
- ioreactor.execute(eventDispatch);
+ ioReactor.execute(eventDispatch);
Assert.fail("IOException should have been thrown");
} catch (final IOException ex) {
latch.countDown();
@@ -145,35 +145,35 @@ public class TestDefaultListeningIOReactor {
t.start();
- final ListenerEndpoint endpoint1 = ioreactor.listen(new InetSocketAddress(0));
+ final ListenerEndpoint endpoint1 = ioReactor.listen(new InetSocketAddress(0));
endpoint1.waitFor();
final int port = ((InetSocketAddress) endpoint1.getAddress()).getPort();
- final ListenerEndpoint endpoint2 = ioreactor.listen(new InetSocketAddress(port));
+ final ListenerEndpoint endpoint2 = ioReactor.listen(new InetSocketAddress(port));
endpoint2.waitFor();
Assert.assertNotNull(endpoint2.getException());
// I/O reactor is now expected to be shutting down
latch.await(2000, TimeUnit.MILLISECONDS);
- Assert.assertTrue(ioreactor.getStatus().compareTo(IOReactorStatus.SHUTTING_DOWN) >= 0);
+ Assert.assertTrue(ioReactor.getStatus().compareTo(IOReactorStatus.SHUTTING_DOWN) >= 0);
- final Set<ListenerEndpoint> endpoints = ioreactor.getEndpoints();
+ final Set<ListenerEndpoint> endpoints = ioReactor.getEndpoints();
Assert.assertNotNull(endpoints);
Assert.assertEquals(0, endpoints.size());
- ioreactor.shutdown(1000);
+ ioReactor.shutdown(1000);
t.join(1000);
- Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
+ Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioReactor.getStatus());
}
@Test
public void testEndpointAlreadyBoundNonFatal() throws Exception {
final IOEventDispatch eventDispatch = createIOEventDispatch();
final IOReactorConfig config = IOReactorConfig.custom().setIoThreadCount(1).build();
- final DefaultListeningIOReactor ioreactor = new DefaultListeningIOReactor(config);
+ final DefaultListeningIOReactor ioReactor = new DefaultListeningIOReactor(config);
- ioreactor.setExceptionHandler(new IOReactorExceptionHandler() {
+ ioReactor.setExceptionHandler(new IOReactorExceptionHandler() {
@Override
public boolean handle(final IOException ex) {
@@ -192,7 +192,7 @@ public class TestDefaultListeningIOReactor {
@Override
public void run() {
try {
- ioreactor.execute(eventDispatch);
+ ioReactor.execute(eventDispatch);
} catch (final IOException ex) {
}
}
@@ -201,22 +201,22 @@ public class TestDefaultListeningIOReactor {
t.start();
- final ListenerEndpoint endpoint1 = ioreactor.listen(new InetSocketAddress(9999));
+ final ListenerEndpoint endpoint1 = ioReactor.listen(new InetSocketAddress(9999));
endpoint1.waitFor();
- final ListenerEndpoint endpoint2 = ioreactor.listen(new InetSocketAddress(9999));
+ final ListenerEndpoint endpoint2 = ioReactor.listen(new InetSocketAddress(9999));
endpoint2.waitFor();
Assert.assertNotNull(endpoint2.getException());
// Sleep a little to make sure the I/O reactor is not shutting down
Thread.sleep(500);
- Assert.assertEquals(IOReactorStatus.ACTIVE, ioreactor.getStatus());
+ Assert.assertEquals(IOReactorStatus.ACTIVE, ioReactor.getStatus());
- ioreactor.shutdown(1000);
+ ioReactor.shutdown(1000);
t.join(1000);
- Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioreactor.getStatus());
+ Assert.assertEquals(IOReactorStatus.SHUT_DOWN, ioReactor.getStatus());
}
}
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d956f67e/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestCustomSSL.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestCustomSSL.java b/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestCustomSSL.java
index 435c0c8..f3f96f3 100644
--- a/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestCustomSSL.java
+++ b/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestCustomSSL.java
@@ -93,9 +93,9 @@ public class TestCustomSSL {
@Override
public void verify(
- final IOSession iosession, final SSLSession sslsession) throws SSLException {
+ final IOSession ioSession, final SSLSession sslsession) throws SSLException {
final BigInteger sslid = new BigInteger(sslsession.getId());
- iosession.setAttribute("ssl-id", sslid);
+ ioSession.setAttribute("ssl-id", sslid);
}
};