You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2018/08/05 11:09:07 UTC

[1/8] httpcomponents-core git commit: * Refactor timeout APIs to include the actual timeout value. * Refactor timeout APIs to include the scale in the method name; for example 'int getSocketTimeout()' vs. int 'getSocketTimeoutMillis()'. [Forced Update!]

Repository: httpcomponents-core
Updated Branches:
  refs/heads/api_javadocs 7d4ae9d5b -> 3e0d1aa8e (forced update)


* Refactor timeout APIs to include the actual timeout value.
* Refactor timeout APIs to include the scale in the method name; for
example 'int getSocketTimeout()' vs. int 'getSocketTimeoutMillis()'.


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/f434e591
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/f434e591
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/f434e591

Branch: refs/heads/api_javadocs
Commit: f434e5913bd51b58dbe7cde26be7dfb7b3c731f3
Parents: 872dcf2
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 08:25:52 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sat Aug 4 21:44:41 2018 +0200

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |  6 ++
 .../impl/nio/AbstractHttp2IOEventHandler.java   | 12 ++--
 .../nio/AbstractHttp2StreamMultiplexer.java     | 26 ++++++---
 .../impl/nio/ClientHttpProtocolNegotiator.java  | 14 ++---
 .../nio/Http2OnlyClientProtocolNegotiator.java  | 14 ++---
 .../impl/nio/ServerHttpProtocolNegotiator.java  | 14 ++---
 .../hc/core5/http2/nio/pool/H2ConnPool.java     |  6 +-
 .../hc/core5/benchmark/BenchmarkWorker.java     |  6 +-
 .../hc/core5/benchmark/CommandLineUtils.java    |  2 +-
 .../org/apache/hc/core5/benchmark/Config.java   |  4 +-
 .../hc/core5/testing/nio/LoggingIOSession.java  |  8 +--
 .../core5/testing/nio/Http1IntegrationTest.java |  2 +-
 .../nio/TestDefaultListeningIOReactor.java      |  2 +-
 .../apache/hc/core5/http/HttpConnection.java    |  4 +-
 .../apache/hc/core5/http/config/H1Config.java   | 14 ++---
 .../http/impl/bootstrap/HttpAsyncRequester.java |  2 +-
 .../core5/http/impl/io/BHttpConnectionBase.java |  4 +-
 .../impl/nio/AbstractHttp1IOEventHandler.java   | 12 ++--
 .../impl/nio/AbstractHttp1StreamDuplexer.java   | 24 ++++----
 .../impl/nio/ClientHttp1StreamDuplexer.java     |  8 +--
 .../http/impl/nio/ClientHttp1StreamHandler.java |  8 +--
 .../core5/http/impl/nio/Http1StreamChannel.java |  4 +-
 .../impl/nio/ServerHttp1StreamDuplexer.java     | 16 +++---
 .../apache/hc/core5/reactor/IOEventHandler.java |  3 +-
 .../org/apache/hc/core5/reactor/IOSession.java  |  4 +-
 .../apache/hc/core5/reactor/IOSessionImpl.java  |  4 +-
 .../hc/core5/reactor/InternalChannel.java       | 12 ++--
 .../core5/reactor/InternalConnectChannel.java   |  8 +--
 .../hc/core5/reactor/InternalDataChannel.java   | 16 +++---
 .../hc/core5/reactor/SingleCoreIOReactor.java   |  4 +-
 .../hc/core5/reactor/ssl/SSLIOSession.java      | 12 ++--
 .../util/SocketTimeoutExceptionFactory.java     | 58 ++++++++++++++++++++
 .../http/impl/io/TestBHttpConnectionBase.java   | 12 ++--
 33 files changed, 209 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index d55f155..b8a1fa3 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -52,6 +52,12 @@ adds several incremental improvements.
 * Refactor duplicate messages into a new 0-arg constructor for org.apache.hc.core5.http.StreamClosedException.
   Contributed by Gary Gregory <ggregory at apache.org>
 
+* Refactor timeout APIs to include the actual timeout value.
+  Contributed by Gary Gregory <ggregory at apache.org>
+
+* Refactor timeout APIs to include the scale in the method name; for example 'int getSocketTimeout()' vs. int 'getSocketTimeoutMillis()'.
+  Contributed by Gary Gregory <ggregory at apache.org>
+
 Release 5.0-BETA2
 -------------------
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2IOEventHandler.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2IOEventHandler.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2IOEventHandler.java
index 24c2967..d79914d 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2IOEventHandler.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2IOEventHandler.java
@@ -76,9 +76,9 @@ class AbstractHttp2IOEventHandler implements HttpConnectionEventHandler {
     }
 
     @Override
-    public void timeout(final IOSession session) throws IOException {
+    public void timeout(final IOSession session, final int timeoutMillis) throws IOException {
         try {
-            streamMultiplexer.onTimeout();
+            streamMultiplexer.onTimeout(timeoutMillis);
         } catch (final HttpException ex) {
             streamMultiplexer.onException(ex);
         }
@@ -110,8 +110,8 @@ class AbstractHttp2IOEventHandler implements HttpConnectionEventHandler {
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
-        streamMultiplexer.setSocketTimeout(timeout);
+    public void setSocketTimeoutMillis(final int timeout) {
+        streamMultiplexer.setSocketTimeoutMillis(timeout);
     }
 
     @Override
@@ -125,8 +125,8 @@ class AbstractHttp2IOEventHandler implements HttpConnectionEventHandler {
     }
 
     @Override
-    public int getSocketTimeout() {
-        return streamMultiplexer.getSocketTimeout();
+    public int getSocketTimeoutMillis() {
+        return streamMultiplexer.getSocketTimeoutMillis();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
index 572ff8c..56808e8 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
@@ -90,6 +90,7 @@ import org.apache.hc.core5.reactor.ssl.TlsDetails;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.ByteArrayBuffer;
 import org.apache.hc.core5.util.Identifiable;
+import org.apache.hc.core5.util.SocketTimeoutExceptionFactory;
 
 abstract class AbstractHttp2StreamMultiplexer implements Identifiable, HttpConnection {
 
@@ -528,20 +529,27 @@ abstract class AbstractHttp2StreamMultiplexer implements Identifiable, HttpConne
         }
     }
 
-    public final void onTimeout() throws HttpException, IOException {
+    public final void onTimeout(final int timeoutMillis) throws HttpException, IOException {
         connState = ConnectionHandshake.SHUTDOWN;
 
         final RawFrame goAway;
         if (localSettingState != SettingsHandshake.ACKED) {
-            goAway = frameFactory.createGoAway(processedRemoteStreamId, H2Error.SETTINGS_TIMEOUT, "Setting timeout");
+            goAway = frameFactory.createGoAway(processedRemoteStreamId, H2Error.SETTINGS_TIMEOUT,
+                            "Setting timeout ("
+                                            + SocketTimeoutExceptionFactory.toMessage(timeoutMillis)
+                                            + ")");
         } else {
-            goAway = frameFactory.createGoAway(processedRemoteStreamId, H2Error.NO_ERROR, "Timeout due to inactivity");
+            goAway = frameFactory.createGoAway(processedRemoteStreamId, H2Error.NO_ERROR,
+                            "Timeout due to inactivity "
+                                            + SocketTimeoutExceptionFactory.toMessage(timeoutMillis)
+                                            + ")");
         }
         commitFrame(goAway);
         for (final Iterator<Map.Entry<Integer, Http2Stream>> it = streamMap.entrySet().iterator(); it.hasNext(); ) {
             final Map.Entry<Integer, Http2Stream> entry = it.next();
             final Http2Stream stream = entry.getValue();
-            stream.reset(new H2StreamResetException(H2Error.NO_ERROR, "Timeout due to inactivity"));
+            stream.reset(new H2StreamResetException(H2Error.NO_ERROR, "Timeout due to inactivity ("
+                            + SocketTimeoutExceptionFactory.toMessage(timeoutMillis) + ")"));
         }
         streamMap.clear();
     }
@@ -1198,8 +1206,8 @@ abstract class AbstractHttp2StreamMultiplexer implements Identifiable, HttpConne
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
-        ioSession.setSocketTimeout(timeout);
+    public void setSocketTimeoutMillis(final int timeout) {
+        ioSession.setSocketTimeoutMillis(timeout);
     }
 
     @Override
@@ -1212,14 +1220,14 @@ abstract class AbstractHttp2StreamMultiplexer implements Identifiable, HttpConne
     public EndpointDetails getEndpointDetails() {
         if (endpointDetails == null) {
             endpointDetails = new BasicEndpointDetails(ioSession.getRemoteAddress(),
-                            ioSession.getLocalAddress(), connMetrics, ioSession.getSocketTimeout());
+                            ioSession.getLocalAddress(), connMetrics, ioSession.getSocketTimeoutMillis());
         }
         return endpointDetails;
     }
 
     @Override
-    public int getSocketTimeout() {
-        return ioSession.getSocketTimeout();
+    public int getSocketTimeoutMillis() {
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java
index b8f8fa7..4213ccf 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java
@@ -29,7 +29,6 @@ package org.apache.hc.core5.http2.impl.nio;
 
 import java.io.IOException;
 import java.net.SocketAddress;
-import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 import java.nio.channels.ByteChannel;
 
@@ -55,6 +54,7 @@ import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.reactor.ProtocolIOSession;
 import org.apache.hc.core5.reactor.ssl.TlsDetails;
 import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.SocketTimeoutExceptionFactory;
 
 /**
  * @since 5.0
@@ -160,8 +160,8 @@ public class ClientHttpProtocolNegotiator implements HttpConnectionEventHandler
     }
 
     @Override
-    public void timeout(final IOSession session) {
-        exception(session, new SocketTimeoutException());
+    public void timeout(final IOSession session, final int timeoutMillis) {
+        exception(session, SocketTimeoutExceptionFactory.create(timeoutMillis));
     }
 
     @Override
@@ -218,13 +218,13 @@ public class ClientHttpProtocolNegotiator implements HttpConnectionEventHandler
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
-        ioSession.setSocketTimeout(timeout);
+    public void setSocketTimeoutMillis(final int timeout) {
+        ioSession.setSocketTimeoutMillis(timeout);
     }
 
     @Override
-    public int getSocketTimeout() {
-        return ioSession.getSocketTimeout();
+    public int getSocketTimeoutMillis() {
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/Http2OnlyClientProtocolNegotiator.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/Http2OnlyClientProtocolNegotiator.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/Http2OnlyClientProtocolNegotiator.java
index 04957d4..7d4e6ac 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/Http2OnlyClientProtocolNegotiator.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/Http2OnlyClientProtocolNegotiator.java
@@ -29,7 +29,6 @@ package org.apache.hc.core5.http2.impl.nio;
 
 import java.io.IOException;
 import java.net.SocketAddress;
-import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 import java.nio.channels.ByteChannel;
 
@@ -52,6 +51,7 @@ import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.reactor.ProtocolIOSession;
 import org.apache.hc.core5.reactor.ssl.TlsDetails;
 import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.SocketTimeoutExceptionFactory;
 import org.apache.hc.core5.util.TextUtils;
 
 /**
@@ -132,8 +132,8 @@ public class Http2OnlyClientProtocolNegotiator implements HttpConnectionEventHan
     }
 
     @Override
-    public void timeout(final IOSession session) {
-        exception(session, new SocketTimeoutException());
+    public void timeout(final IOSession session, final int timeoutMillis) {
+        exception(session, SocketTimeoutExceptionFactory.create(timeoutMillis));
     }
 
     @Override
@@ -190,13 +190,13 @@ public class Http2OnlyClientProtocolNegotiator implements HttpConnectionEventHan
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
-        ioSession.setSocketTimeout(timeout);
+    public void setSocketTimeoutMillis(final int timeout) {
+        ioSession.setSocketTimeoutMillis(timeout);
     }
 
     @Override
-    public int getSocketTimeout() {
-        return ioSession.getSocketTimeout();
+    public int getSocketTimeoutMillis() {
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
index afa1839..87891bd 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
@@ -29,7 +29,6 @@ package org.apache.hc.core5.http2.impl.nio;
 
 import java.io.IOException;
 import java.net.SocketAddress;
-import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 
 import javax.net.ssl.SSLSession;
@@ -52,6 +51,7 @@ import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.reactor.ProtocolIOSession;
 import org.apache.hc.core5.reactor.ssl.TlsDetails;
 import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.SocketTimeoutExceptionFactory;
 
 /**
  * @since 5.0
@@ -161,8 +161,8 @@ public class ServerHttpProtocolNegotiator implements HttpConnectionEventHandler
     }
 
     @Override
-    public void timeout(final IOSession session) {
-        exception(session, new SocketTimeoutException());
+    public void timeout(final IOSession session, final int timeoutMillis) {
+        exception(session, SocketTimeoutExceptionFactory.create(timeoutMillis));
     }
 
     @Override
@@ -186,13 +186,13 @@ public class ServerHttpProtocolNegotiator implements HttpConnectionEventHandler
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
-        ioSession.setSocketTimeout(timeout);
+    public void setSocketTimeoutMillis(final int timeout) {
+        ioSession.setSocketTimeoutMillis(timeout);
     }
 
     @Override
-    public int getSocketTimeout() {
-        return ioSession.getSocketTimeout();
+    public int getSocketTimeoutMillis() {
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/pool/H2ConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/pool/H2ConnPool.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/pool/H2ConnPool.java
index 78098e7..a18552f 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/pool/H2ConnPool.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/pool/H2ConnPool.java
@@ -111,7 +111,7 @@ public final class H2ConnPool extends AbstractIOSessionPool<HttpHost> {
                             ioSession.getLocalAddress(),
                             ioSession.getRemoteAddress(),
                             null);
-                    ioSession.setSocketTimeout(requestTimeout.toMillisIntBound());
+                    ioSession.setSocketTimeoutMillis(requestTimeout.toMillisIntBound());
                 }
                 callback.completed(ioSession);
             }
@@ -138,12 +138,12 @@ public final class H2ConnPool extends AbstractIOSessionPool<HttpHost> {
             final long lastAccessTime = Math.min(ioSession.getLastReadTime(), ioSession.getLastWriteTime());
             final long deadline = lastAccessTime + timeValue.toMillis();
             if (deadline <= System.currentTimeMillis()) {
-                final int socketTimeout = ioSession.getSocketTimeout();
+                final int socketTimeoutMillis = ioSession.getSocketTimeoutMillis();
                 ioSession.enqueue(new PingCommand(new BasicPingHandler(new Callback<Boolean>() {
 
                     @Override
                     public void execute(final Boolean result) {
-                        ioSession.setSocketTimeout(socketTimeout);
+                        ioSession.setSocketTimeoutMillis(socketTimeoutMillis);
                         callback.execute(result);
                     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
index 5c1979e..4715bc5 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
@@ -142,9 +142,9 @@ class BenchmarkWorker implements Runnable {
                         socket = new Socket();
                     }
 
-                    final int timeout = config.getSocketTimeout();
-                    socket.setSoTimeout(timeout);
-                    socket.connect(new InetSocketAddress(hostname, port), timeout);
+                    final int timeoutMillis = config.getSocketTimeoutMillis();
+                    socket.setSoTimeout(timeoutMillis);
+                    socket.connect(new InetSocketAddress(hostname, port), timeoutMillis);
 
                     conn.bind(socket);
                 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/CommandLineUtils.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/CommandLineUtils.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/CommandLineUtils.java
index b36b0d1..acdb785 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/CommandLineUtils.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/CommandLineUtils.java
@@ -187,7 +187,7 @@ public class CommandLineUtils {
         if (cmd.hasOption('t')) {
             final String t = cmd.getOptionValue('t');
             try {
-                config.setSocketTimeout(Integer.parseInt(t));
+                config.setSocketTimeoutMillis(Integer.parseInt(t));
             } catch (final NumberFormatException ex) {
                 printError("Invalid socket timeout: " + t);
             }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/Config.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/Config.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/Config.java
index 9388618..d8a346b 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/Config.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/Config.java
@@ -153,11 +153,11 @@ public class Config {
         this.headers = headers;
     }
 
-    public int getSocketTimeout() {
+    public int getSocketTimeoutMillis() {
         return socketTimeout;
     }
 
-    public void setSocketTimeout(final int socketTimeout) {
+    public void setSocketTimeoutMillis(final int socketTimeout) {
         this.socketTimeout = socketTimeout;
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
index bc66fa0..43e5ebc 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
@@ -177,16 +177,16 @@ public class LoggingIOSession implements IOSession {
     }
 
     @Override
-    public int getSocketTimeout() {
-        return this.session.getSocketTimeout();
+    public int getSocketTimeoutMillis() {
+        return this.session.getSocketTimeoutMillis();
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
+    public void setSocketTimeoutMillis(final int timeout) {
         if (this.log.isDebugEnabled()) {
             this.log.debug(this.session + " Set timeout " + timeout);
         }
-        this.session.setSocketTimeout(timeout);
+        this.session.setSocketTimeoutMillis(timeout);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
index e8810de..cc1f5ab 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
@@ -872,7 +872,7 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
         });
         final InetSocketAddress serverEndpoint = server.start();
 
-        client.start(H1Config.custom().setWaitForContinueTimeout(100).build());
+        client.start(H1Config.custom().setWaitForContinueTimeoutMillis(100).build());
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
                 "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java
index 3ce6bff..629847d 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/TestDefaultListeningIOReactor.java
@@ -73,7 +73,7 @@ public class TestDefaultListeningIOReactor {
                 }
 
                 @Override
-                public void timeout(final IOSession session) {
+                public void timeout(final IOSession session, final int timeoutMillis) {
                 }
 
                 @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnection.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnection.java b/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnection.java
index 5523e68..b65856f 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnection.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/HttpConnection.java
@@ -72,7 +72,7 @@ public interface HttpConnection extends ModalCloseable {
      *
      * @param timeout timeout value in milliseconds
      */
-    void setSocketTimeout(int timeout);
+    void setSocketTimeoutMillis(int timeout);
 
     /**
      * Returns the socket timeout value.
@@ -81,7 +81,7 @@ public interface HttpConnection extends ModalCloseable {
      * {@code 0} if timeout is disabled or {@code -1} if
      * timeout is undefined.
      */
-    int getSocketTimeout();
+    int getSocketTimeoutMillis();
 
     /**
      * Returns protocol version used by this connection or {@code null} if unknown.

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java b/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java
index 405378a..47bfb0f 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/config/H1Config.java
@@ -45,7 +45,7 @@ public class H1Config {
 
     private final int bufferSize;
     private final int chunkSizeHint;
-    private final int waitForContinueTimeout;
+    private final int waitForContinueTimeoutMillis;
     private final int maxLineLength;
     private final int maxHeaderCount;
     private final int maxEmptyLineCount;
@@ -55,7 +55,7 @@ public class H1Config {
         super();
         this.bufferSize = bufferSize;
         this.chunkSizeHint = chunkSizeHint;
-        this.waitForContinueTimeout = waitForContinueTimeout;
+        this.waitForContinueTimeoutMillis = waitForContinueTimeout;
         this.maxLineLength = maxLineLength;
         this.maxHeaderCount = maxHeaderCount;
         this.maxEmptyLineCount = maxEmptyLineCount;
@@ -69,8 +69,8 @@ public class H1Config {
         return chunkSizeHint;
     }
 
-    public int getWaitForContinueTimeout() {
-        return waitForContinueTimeout;
+    public int getWaitForContinueTimeoutMillis() {
+        return waitForContinueTimeoutMillis;
     }
 
     public int getMaxLineLength() {
@@ -90,7 +90,7 @@ public class H1Config {
         final StringBuilder builder = new StringBuilder();
         builder.append("[bufferSize=").append(bufferSize)
                 .append(", chunkSizeHint=").append(chunkSizeHint)
-                .append(", waitForContinueTimeout=").append(waitForContinueTimeout)
+                .append(", waitForContinueTimeout=").append(waitForContinueTimeoutMillis)
                 .append(", maxLineLength=").append(maxLineLength)
                 .append(", maxHeaderCount=").append(maxHeaderCount)
                 .append(", maxEmptyLineCount=").append(maxEmptyLineCount)
@@ -107,7 +107,7 @@ public class H1Config {
         return new Builder()
                 .setBufferSize(config.getBufferSize())
                 .setChunkSizeHint(config.getChunkSizeHint())
-                .setWaitForContinueTimeout(config.getWaitForContinueTimeout())
+                .setWaitForContinueTimeoutMillis(config.getWaitForContinueTimeoutMillis())
                 .setMaxHeaderCount(config.getMaxHeaderCount())
                 .setMaxLineLength(config.getMaxLineLength())
                 .setMaxEmptyLineCount(config.maxEmptyLineCount);
@@ -141,7 +141,7 @@ public class H1Config {
             return this;
         }
 
-        public Builder setWaitForContinueTimeout(final int waitForContinueTimeout) {
+        public Builder setWaitForContinueTimeoutMillis(final int waitForContinueTimeout) {
             this.waitForContinueTimeout = waitForContinueTimeout;
             return this;
         }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java
index b855e6f..00ffc4a 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java
@@ -204,7 +204,7 @@ public class HttpAsyncRequester extends AsyncRequester implements ConnPoolContro
                                         session.getRemoteAddress(),
                                         attachment);
                             }
-                            session.setSocketTimeout(timeout.toMillisIntBound());
+                            session.setSocketTimeoutMillis(timeout.toMillisIntBound());
                             poolEntry.assignConnection(session);
                             resultFuture.completed(endpoint);
                         }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
index 628c39c..1ce2083 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
@@ -191,7 +191,7 @@ class BHttpConnectionBase implements BHttpConnection {
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
+    public void setSocketTimeoutMillis(final int timeout) {
         final SocketHolder socketHolder = this.socketHolderRef.get();
         if (socketHolder != null) {
             try {
@@ -205,7 +205,7 @@ class BHttpConnectionBase implements BHttpConnection {
     }
 
     @Override
-    public int getSocketTimeout() {
+    public int getSocketTimeoutMillis() {
         final SocketHolder socketHolder = this.socketHolderRef.get();
         if (socketHolder != null) {
             try {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1IOEventHandler.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1IOEventHandler.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1IOEventHandler.java
index 37113ab..f90e164 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1IOEventHandler.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1IOEventHandler.java
@@ -75,9 +75,9 @@ class AbstractHttp1IOEventHandler implements HttpConnectionEventHandler {
     }
 
     @Override
-    public void timeout(final IOSession session) throws IOException {
+    public void timeout(final IOSession session, final int timeoutMillis) throws IOException {
         try {
-            streamDuplexer.onTimeout();
+            streamDuplexer.onTimeout(timeoutMillis);
         } catch (final HttpException ex) {
             streamDuplexer.onException(ex);
         }
@@ -109,8 +109,8 @@ class AbstractHttp1IOEventHandler implements HttpConnectionEventHandler {
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
-        streamDuplexer.setSocketTimeout(timeout);
+    public void setSocketTimeoutMillis(final int timeout) {
+        streamDuplexer.setSocketTimeoutMillis(timeout);
     }
 
     @Override
@@ -124,8 +124,8 @@ class AbstractHttp1IOEventHandler implements HttpConnectionEventHandler {
     }
 
     @Override
-    public int getSocketTimeout() {
-        return streamDuplexer.getSocketTimeout();
+    public int getSocketTimeoutMillis() {
+        return streamDuplexer.getSocketTimeoutMillis();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
index c5cea79..21a1433 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
@@ -29,7 +29,6 @@ package org.apache.hc.core5.http.impl.nio;
 
 import java.io.IOException;
 import java.net.SocketAddress;
-import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.ReadableByteChannel;
@@ -77,6 +76,7 @@ import org.apache.hc.core5.reactor.ProtocolIOSession;
 import org.apache.hc.core5.reactor.ssl.TlsDetails;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.Identifiable;
+import org.apache.hc.core5.util.SocketTimeoutExceptionFactory;
 
 abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage, OutgoingMessage extends HttpMessage>
         implements Identifiable, HttpConnection {
@@ -390,9 +390,9 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
         }
     }
 
-    public final void onTimeout() throws IOException, HttpException {
+    public final void onTimeout(final int timeoutMillis) throws IOException, HttpException {
         if (!handleTimeout()) {
-            onException(new SocketTimeoutException());
+            onException(SocketTimeoutExceptionFactory.create(timeoutMillis));
         }
     }
 
@@ -483,12 +483,12 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
         ioSession.setEvent(SelectionKey.OP_WRITE);
     }
 
-    int getSessionTimeout() {
-        return ioSession.getSocketTimeout();
+    int getSessionTimeoutMillis() {
+        return ioSession.getSocketTimeoutMillis();
     }
 
-    void setSessionTimeout(final int timeout) {
-        ioSession.setSocketTimeout(timeout);
+    void setSessionTimeoutMillis(final int timeout) {
+        ioSession.setSocketTimeoutMillis(timeout);
     }
 
     void suspendSessionOutput() {
@@ -563,22 +563,22 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
-        ioSession.setSocketTimeout(timeout);
+    public void setSocketTimeoutMillis(final int timeout) {
+        ioSession.setSocketTimeoutMillis(timeout);
     }
 
     @Override
     public EndpointDetails getEndpointDetails() {
         if (endpointDetails == null) {
             endpointDetails = new BasicEndpointDetails(ioSession.getRemoteAddress(),
-                            ioSession.getLocalAddress(), connMetrics, ioSession.getSocketTimeout());
+                            ioSession.getLocalAddress(), connMetrics, ioSession.getSocketTimeoutMillis());
         }
         return endpointDetails;
     }
 
     @Override
-    public int getSocketTimeout() {
-        return ioSession.getSocketTimeout();
+    public int getSocketTimeoutMillis() {
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
index a7f5ed6..1762a57 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
@@ -124,13 +124,13 @@ public class ClientHttp1StreamDuplexer extends AbstractHttp1StreamDuplexer<HttpR
             }
 
             @Override
-            public int getSocketTimeout() {
-                return getSessionTimeout();
+            public int getSocketTimeoutMillis() {
+                return getSessionTimeoutMillis();
             }
 
             @Override
-            public void setSocketTimeout(final int timeout) {
-                setSessionTimeout(timeout);
+            public void setSocketTimeoutMillis(final int timeout) {
+                setSessionTimeoutMillis(timeout);
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java
index 75cda22..b0485a4 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamHandler.java
@@ -162,8 +162,8 @@ class ClientHttp1StreamHandler implements ResourceHolder {
                 final boolean expectContinue = h != null && "100-continue".equalsIgnoreCase(h.getValue());
                 if (expectContinue) {
                     requestState = MessageState.ACK;
-                    timeout = outputChannel.getSocketTimeout();
-                    outputChannel.setSocketTimeout(h1Config.getWaitForContinueTimeout());
+                    timeout = outputChannel.getSocketTimeoutMillis();
+                    outputChannel.setSocketTimeoutMillis(h1Config.getWaitForContinueTimeoutMillis());
                 } else {
                     requestState = MessageState.BODY;
                     exchangeHandler.produce(internalDataChannel);
@@ -219,7 +219,7 @@ class ClientHttp1StreamHandler implements ResourceHolder {
         }
         if (requestState == MessageState.ACK) {
             if (status == HttpStatus.SC_CONTINUE || status >= HttpStatus.SC_SUCCESS) {
-                outputChannel.setSocketTimeout(timeout);
+                outputChannel.setSocketTimeoutMillis(timeout);
                 requestState = MessageState.BODY;
                 if (status < HttpStatus.SC_CLIENT_ERROR) {
                     exchangeHandler.produce(internalDataChannel);
@@ -277,7 +277,7 @@ class ClientHttp1StreamHandler implements ResourceHolder {
     boolean handleTimeout() {
         if (requestState == MessageState.ACK) {
             requestState = MessageState.BODY;
-            outputChannel.setSocketTimeout(timeout);
+            outputChannel.setSocketTimeoutMillis(timeout);
             outputChannel.requestOutput();
             return true;
         }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/Http1StreamChannel.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/Http1StreamChannel.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/Http1StreamChannel.java
index 2e562a5..59847f7 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/Http1StreamChannel.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/Http1StreamChannel.java
@@ -46,8 +46,8 @@ interface Http1StreamChannel<OutgoingMessage extends HttpMessage> extends Conten
 
     boolean abortGracefully() throws IOException;
 
-    int getSocketTimeout();
+    int getSocketTimeoutMillis();
 
-    void setSocketTimeout(int timeout);
+    void setSocketTimeoutMillis(int timeout);
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java
index 3d24e6d..edfca1e 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java
@@ -129,13 +129,13 @@ public class ServerHttp1StreamDuplexer extends AbstractHttp1StreamDuplexer<HttpR
             }
 
             @Override
-            public int getSocketTimeout() {
-                return getSessionTimeout();
+            public int getSocketTimeoutMillis() {
+                return getSessionTimeoutMillis();
             }
 
             @Override
-            public void setSocketTimeout(final int timeout) {
-                setSessionTimeout(timeout);
+            public void setSocketTimeoutMillis(final int timeout) {
+                setSessionTimeoutMillis(timeout);
             }
 
             @Override
@@ -437,13 +437,13 @@ public class ServerHttp1StreamDuplexer extends AbstractHttp1StreamDuplexer<HttpR
         }
 
         @Override
-        public int getSocketTimeout() {
-            return channel.getSocketTimeout();
+        public int getSocketTimeoutMillis() {
+            return channel.getSocketTimeoutMillis();
         }
 
         @Override
-        public void setSocketTimeout(final int timeout) {
-            channel.setSocketTimeout(timeout);
+        public void setSocketTimeoutMillis(final int timeout) {
+            channel.setSocketTimeoutMillis(timeout);
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOEventHandler.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOEventHandler.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOEventHandler.java
index 0a256b6..51a6283 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOEventHandler.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOEventHandler.java
@@ -65,8 +65,9 @@ public interface IOEventHandler {
      * Triggered when the given session as timed out.
      *
      * @param session the I/O session.
+     * @param timeoutMillis the timeout in milliseconds.
      */
-    void timeout(IOSession session) throws IOException;
+    void timeout(IOSession session, int timeoutMillis) throws IOException;
 
     /**
      * Triggered when the given session throws a exception.

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
index 144824f..01ce0ac 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
@@ -172,7 +172,7 @@ public interface IOSession extends ModalCloseable, Identifiable {
      *
      * @return socket timeout.
      */
-    int getSocketTimeout();
+    int getSocketTimeoutMillis();
 
     /**
      * Sets value of the socket timeout in milliseconds. The value of
@@ -180,7 +180,7 @@ public interface IOSession extends ModalCloseable, Identifiable {
      *
      * @param timeout socket timeout.
      */
-    void setSocketTimeout(int timeout);
+    void setSocketTimeoutMillis(int timeout);
 
     /**
      * Returns timestamp of the last read event.

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
index 3db047a..c5aff5e 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
@@ -165,12 +165,12 @@ class IOSessionImpl implements IOSession {
     }
 
     @Override
-    public int getSocketTimeout() {
+    public int getSocketTimeoutMillis() {
         return this.socketTimeout;
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
+    public void setSocketTimeoutMillis(final int timeout) {
         this.socketTimeout = timeout;
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalChannel.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalChannel.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalChannel.java
index 59319d9..22cbc7f 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalChannel.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalChannel.java
@@ -37,11 +37,11 @@ abstract class InternalChannel implements ModalCloseable {
 
     abstract void onIOEvent(final int ops) throws IOException;
 
-    abstract void onTimeout() throws IOException;
+    abstract void onTimeout(int timeoutMillis) throws IOException;
 
     abstract void onException(final Exception cause);
 
-    abstract int getTimeout();
+    abstract int getTimeoutMillis();
 
     abstract long getLastReadTime();
 
@@ -57,12 +57,12 @@ abstract class InternalChannel implements ModalCloseable {
     }
 
     final boolean checkTimeout(final long currentTime) {
-        final int timeout = getTimeout();
-        if (timeout > 0) {
-            final long deadline = getLastReadTime() + timeout;
+        final int timeoutMillis = getTimeoutMillis();
+        if (timeoutMillis > 0) {
+            final long deadline = getLastReadTime() + timeoutMillis;
             if (currentTime > deadline) {
                 try {
-                    onTimeout();
+                    onTimeout(timeoutMillis);
                 } catch (final CancelledKeyException ex) {
                     close(CloseMode.GRACEFUL);
                 } catch (final Exception ex) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalConnectChannel.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalConnectChannel.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalConnectChannel.java
index e7bc153..4cde455 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalConnectChannel.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalConnectChannel.java
@@ -28,11 +28,11 @@
 package org.apache.hc.core5.reactor;
 
 import java.io.IOException;
-import java.net.SocketTimeoutException;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.SocketChannel;
 
 import org.apache.hc.core5.io.CloseMode;
+import org.apache.hc.core5.util.SocketTimeoutExceptionFactory;
 import org.apache.hc.core5.util.TimeValue;
 
 final class InternalConnectChannel extends InternalChannel {
@@ -78,7 +78,7 @@ final class InternalConnectChannel extends InternalChannel {
     }
 
     @Override
-    int getTimeout() {
+    int getTimeoutMillis() {
         return TimeValue.defaultsToZeroMillis(sessionRequest.timeout).toMillisIntBound();
     }
 
@@ -88,8 +88,8 @@ final class InternalConnectChannel extends InternalChannel {
     }
 
     @Override
-    void onTimeout() throws IOException {
-        sessionRequest.failed(new SocketTimeoutException());
+    void onTimeout(final int timeoutMillis) throws IOException {
+        sessionRequest.failed(SocketTimeoutExceptionFactory.create(timeoutMillis));
         close();
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
index dfe4e86..2b0cc00 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
@@ -172,14 +172,14 @@ final class InternalDataChannel extends InternalChannel implements ProtocolIOSes
     }
 
     @Override
-    int getTimeout() {
-        return ioSession.getSocketTimeout();
+    int getTimeoutMillis() {
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override
-    void onTimeout() throws IOException {
+    void onTimeout(final int timeoutMillis) throws IOException {
         final IOEventHandler handler = ensureHandler();
-        handler.timeout(this);
+        handler.timeout(this, timeoutMillis);
         final SSLIOSession tlsSession = tlsSessionRef.get();
         if (tlsSession != null) {
             if (tlsSession.isOutboundDone() && !tlsSession.isInboundDone()) {
@@ -349,13 +349,13 @@ final class InternalDataChannel extends InternalChannel implements ProtocolIOSes
     }
 
     @Override
-    public int getSocketTimeout() {
-        return ioSession.getSocketTimeout();
+    public int getSocketTimeoutMillis() {
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
-        ioSession.setSocketTimeout(timeout);
+    public void setSocketTimeoutMillis(final int timeout) {
+        ioSession.setSocketTimeoutMillis(timeout);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
index edc5c8b..9761ba1 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
@@ -205,7 +205,7 @@ class SingleCoreIOReactor extends AbstractSingleCoreIOReactor implements Connect
             }
             final InternalDataChannel dataChannel = new InternalDataChannel(ioSession, null, sessionListener, closedSessions);
             dataChannel.upgrade(this.eventHandlerFactory.createHandler(dataChannel, null));
-            dataChannel.setSocketTimeout(this.reactorConfig.getSoTimeout().toMillisIntBound());
+            dataChannel.setSocketTimeoutMillis(this.reactorConfig.getSoTimeout().toMillisIntBound());
             key.attach(dataChannel);
             dataChannel.handleIOEvent(SelectionKey.OP_CONNECT);
         }
@@ -332,7 +332,7 @@ class SingleCoreIOReactor extends AbstractSingleCoreIOReactor implements Connect
                 }
                 final InternalDataChannel dataChannel = new InternalDataChannel(ioSession, namedEndpoint, sessionListener, closedSessions);
                 dataChannel.upgrade(eventHandlerFactory.createHandler(dataChannel, attachment));
-                dataChannel.setSocketTimeout(reactorConfig.getSoTimeout().toMillisIntBound());
+                dataChannel.setSocketTimeoutMillis(reactorConfig.getSoTimeout().toMillisIntBound());
                 return dataChannel;
             }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
index 0f1aa70..7bb0f66 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
@@ -658,8 +658,8 @@ public class SSLIOSession implements IOSession {
                 return;
             }
             this.status = CLOSING;
-            if (this.session.getSocketTimeout() == 0) {
-                this.session.setSocketTimeout(1000);
+            if (this.session.getSocketTimeoutMillis() == 0) {
+                this.session.setSocketTimeoutMillis(1000);
             }
             try {
                 updateEventMask();
@@ -779,13 +779,13 @@ public class SSLIOSession implements IOSession {
     }
 
     @Override
-    public int getSocketTimeout() {
-        return this.session.getSocketTimeout();
+    public int getSocketTimeoutMillis() {
+        return this.session.getSocketTimeoutMillis();
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
-        this.session.setSocketTimeout(timeout);
+    public void setSocketTimeoutMillis(final int timeout) {
+        this.session.setSocketTimeoutMillis(timeout);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/main/java/org/apache/hc/core5/util/SocketTimeoutExceptionFactory.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/SocketTimeoutExceptionFactory.java b/httpcore5/src/main/java/org/apache/hc/core5/util/SocketTimeoutExceptionFactory.java
new file mode 100644
index 0000000..6af2bb7
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/util/SocketTimeoutExceptionFactory.java
@@ -0,0 +1,58 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.util;
+
+import java.net.SocketTimeoutException;
+
+/**
+ * Creates SocketTimeoutException instances.
+ */
+public class SocketTimeoutExceptionFactory {
+
+    /**
+     * Creates a new SocketTimeoutException with a message for the given timeout.
+     *
+     * @param timeoutMillis
+     *            a timeout in milliseconds.
+     * @return a new SocketTimeoutException with a message for the given timeout.
+     */
+    static public SocketTimeoutException create(final int timeoutMillis) {
+        return new SocketTimeoutException(toMessage(timeoutMillis));
+    }
+
+    /**
+     * Creates a message for the given timeout.
+     *
+     * @param timeoutMillis
+     *            a timeout in milliseconds.
+     * @return a message for the given timeout.
+     */
+    public static String toMessage(final int timeoutMillis) {
+        return String.format("%,d millisecond", timeoutMillis);
+    }
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/f434e591/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
index 1e84b8a..2913f55 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
@@ -202,7 +202,7 @@ public class TestBHttpConnectionBase {
     public void testSetSocketTimeout() throws Exception {
         conn.bind(socket);
 
-        conn.setSocketTimeout(123);
+        conn.setSocketTimeoutMillis(123);
 
         Mockito.verify(socket, Mockito.times(1)).setSoTimeout(123);
     }
@@ -213,29 +213,29 @@ public class TestBHttpConnectionBase {
 
         Mockito.doThrow(new SocketException()).when(socket).setSoTimeout(Mockito.anyInt());
 
-        conn.setSocketTimeout(123);
+        conn.setSocketTimeoutMillis(123);
 
         Mockito.verify(socket, Mockito.times(1)).setSoTimeout(123);
     }
 
     @Test
     public void testGetSocketTimeout() throws Exception {
-        Assert.assertEquals(-1, conn.getSocketTimeout());
+        Assert.assertEquals(-1, conn.getSocketTimeoutMillis());
 
         Mockito.when(socket.getSoTimeout()).thenReturn(345);
         conn.bind(socket);
 
-        Assert.assertEquals(345, conn.getSocketTimeout());
+        Assert.assertEquals(345, conn.getSocketTimeoutMillis());
     }
 
     @Test
     public void testGetSocketTimeoutException() throws Exception {
-        Assert.assertEquals(-1, conn.getSocketTimeout());
+        Assert.assertEquals(-1, conn.getSocketTimeoutMillis());
 
         Mockito.when(socket.getSoTimeout()).thenThrow(new SocketException());
         conn.bind(socket);
 
-        Assert.assertEquals(-1, conn.getSocketTimeout());
+        Assert.assertEquals(-1, conn.getSocketTimeoutMillis());
     }
 
     @Test


[5/8] httpcomponents-core git commit: Removed unused interface

Posted by ol...@apache.org.
Removed unused interface


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/e0041dd2
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/e0041dd2
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/e0041dd2

Branch: refs/heads/api_javadocs
Commit: e0041dd2c40726b7cc4f04bdbb9dd4b6ddb30f54
Parents: 3c39a38
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Aug 5 12:19:08 2018 +0200
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Aug 5 12:19:08 2018 +0200

----------------------------------------------------------------------
 .../hc/core5/function/Transformation.java       | 39 --------------------
 1 file changed, 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/e0041dd2/httpcore5/src/main/java/org/apache/hc/core5/function/Transformation.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/function/Transformation.java b/httpcore5/src/main/java/org/apache/hc/core5/function/Transformation.java
deleted file mode 100644
index 84da663..0000000
--- a/httpcore5/src/main/java/org/apache/hc/core5/function/Transformation.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.core5.function;
-
-/**
- * Abstract transformation from input to output.
- *
- * @since 5.0
- */
-public interface Transformation<I, O> {
-
-    O transform(I object);
-
-}


[2/8] httpcomponents-core git commit: No need to nest else clauses. Replace some if/else with a ternary return. Remove unnecessary semicolons. Remove unnecessary cast. Remove unnecessary @SuppressWarnings. Access static methods directly. Remove exception

Posted by ol...@apache.org.
http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
index 1762a57..e9f1acd 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java
@@ -154,9 +154,8 @@ public class ClientHttp1StreamDuplexer extends AbstractHttp1StreamDuplexer<HttpR
                 if (messageDelineation == MessageDelineation.MESSAGE_HEAD) {
                     requestShutdown(CloseMode.GRACEFUL);
                     return false;
-                } else {
-                    return true;
                 }
+                return true;
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/message/MessageSupport.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/message/MessageSupport.java b/httpcore5/src/main/java/org/apache/hc/core5/http/message/MessageSupport.java
index 91226bd..f015ed3 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/message/MessageSupport.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/message/MessageSupport.java
@@ -127,11 +127,10 @@ public class MessageSupport {
             final ParserCursor cursor = new ParserCursor(0, buf.length());
             cursor.updatePos(((FormattedHeader) header).getValuePos());
             return parseTokens(buf, cursor);
-        } else {
-            final String value = header.getValue();
-            final ParserCursor cursor = new ParserCursor(0, value.length());
-            return parseTokens(value, cursor);
         }
+        final String value = header.getValue();
+        final ParserCursor cursor = new ParserCursor(0, value.length());
+        return parseTokens(value, cursor);
     }
 
     public static void addContentTypeHeader(final HttpMessage message, final EntityDetails entity) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncServerAuthFilter.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncServerAuthFilter.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncServerAuthFilter.java
index 443af98..24ccd01 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncServerAuthFilter.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncServerAuthFilter.java
@@ -94,41 +94,39 @@ public abstract class AbstractAsyncServerAuthFilter<T> implements AsyncFilterHan
                 responseTrigger.sendInformation(new BasicClassicHttpResponse(HttpStatus.SC_CONTINUE));
             }
             return chain.proceed(request, entityDetails, context, responseTrigger);
-        } else {
-            final HttpResponse unauthorized = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED);
-            unauthorized.addHeader(HttpHeaders.WWW_AUTHENTICATE, generateChallenge(challengeResponse, authority, requestUri, context));
-            final AsyncEntityProducer responseContentProducer = generateResponseContent(unauthorized);
-            if (respondImmediately || expectContinue || entityDetails == null) {
+        }
+        final HttpResponse unauthorized = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED);
+        unauthorized.addHeader(HttpHeaders.WWW_AUTHENTICATE, generateChallenge(challengeResponse, authority, requestUri, context));
+        final AsyncEntityProducer responseContentProducer = generateResponseContent(unauthorized);
+        if (respondImmediately || expectContinue || entityDetails == null) {
+            responseTrigger.submitResponse(unauthorized, responseContentProducer);
+            return null;
+        }
+        return new AsyncDataConsumer() {
+
+            @Override
+            public void updateCapacity(final CapacityChannel capacityChannel) throws IOException {
+                capacityChannel.update(Integer.MAX_VALUE);
+            }
+
+            @Override
+            public int consume(final ByteBuffer src) throws IOException {
+                return Integer.MAX_VALUE;
+            }
+
+            @Override
+            public void streamEnd(final List<? extends Header> trailers) throws HttpException, IOException {
                 responseTrigger.submitResponse(unauthorized, responseContentProducer);
-                return null;
-            } else {
-                return new AsyncDataConsumer() {
-
-                    @Override
-                    public void updateCapacity(final CapacityChannel capacityChannel) throws IOException {
-                        capacityChannel.update(Integer.MAX_VALUE);
-                    }
-
-                    @Override
-                    public int consume(final ByteBuffer src) throws IOException {
-                        return Integer.MAX_VALUE;
-                    }
-
-                    @Override
-                    public void streamEnd(final List<? extends Header> trailers) throws HttpException, IOException {
-                        responseTrigger.submitResponse(unauthorized, responseContentProducer);
-                    }
-
-                    @Override
-                    public void releaseResources() {
-                        if (responseContentProducer != null) {
-                            responseContentProducer.releaseResources();
-                        }
-                    }
-
-                };
             }
-        }
+
+            @Override
+            public void releaseResources() {
+                if (responseContentProducer != null) {
+                    responseContentProducer.releaseResources();
+                }
+            }
+
+        };
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncServerFilterChainExchangeHandlerFactory.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncServerFilterChainExchangeHandlerFactory.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncServerFilterChainExchangeHandlerFactory.java
index c74c3c7..c70a8c3 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncServerFilterChainExchangeHandlerFactory.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AsyncServerFilterChainExchangeHandlerFactory.java
@@ -119,11 +119,7 @@ public final class AsyncServerFilterChainExchangeHandlerFactory implements Handl
             @Override
             public int consume(final ByteBuffer src) throws IOException {
                 final AsyncDataConsumer dataConsumer = dataConsumerRef.get();
-                if (dataConsumer != null) {
-                    return dataConsumer.consume(src);
-                } else {
-                    return Integer.MAX_VALUE;
-                }
+                return dataConsumer != null ? dataConsumer.consume(src) : Integer.MAX_VALUE;
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncServerExpectationDecorator.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncServerExpectationDecorator.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncServerExpectationDecorator.java
index bfaf6fa..7fecddc 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncServerExpectationDecorator.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncServerExpectationDecorator.java
@@ -99,11 +99,7 @@ public class BasicAsyncServerExpectationDecorator implements AsyncServerExchange
     @Override
     public final int consume(final ByteBuffer src) throws IOException {
         final AsyncResponseProducer responseProducer = responseProducerRef.get();
-        if (responseProducer == null) {
-            return handler.consume(src);
-        } else {
-            return Integer.MAX_VALUE;
-        }
+        return responseProducer == null ? handler.consume(src) : Integer.MAX_VALUE;
     }
 
     @Override
@@ -117,11 +113,7 @@ public class BasicAsyncServerExpectationDecorator implements AsyncServerExchange
     @Override
     public final int available() {
         final AsyncResponseProducer responseProducer = responseProducerRef.get();
-        if (responseProducer == null) {
-            return handler.available();
-        } else {
-            return responseProducer.available();
-        }
+        return responseProducer == null ? handler.available() : responseProducer.available();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/DefaultAsyncResponseExchangeHandlerFactory.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/DefaultAsyncResponseExchangeHandlerFactory.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/DefaultAsyncResponseExchangeHandlerFactory.java
index 28d0ee5..1097a08 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/DefaultAsyncResponseExchangeHandlerFactory.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/DefaultAsyncResponseExchangeHandlerFactory.java
@@ -57,16 +57,16 @@ public final class DefaultAsyncResponseExchangeHandlerFactory implements Handler
         this(mapper, null);
     }
 
-    private AsyncServerExchangeHandler createHandler(final HttpRequest request, final HttpContext context) throws HttpException {
+    private AsyncServerExchangeHandler createHandler(final HttpRequest request,
+                    final HttpContext context) throws HttpException {
         try {
             final Supplier<AsyncServerExchangeHandler> supplier = mapper.resolve(request, context);
-            if (supplier != null) {
-                return supplier.get();
-            } else {
-                return new ImmediateResponseExchangeHandler(HttpStatus.SC_NOT_FOUND, "Resource not found");
-            }
+            return supplier != null
+                            ? supplier.get()
+                            : new ImmediateResponseExchangeHandler(HttpStatus.SC_NOT_FOUND, "Resource not found");
         } catch (final MisdirectedRequestException ex) {
-            return new ImmediateResponseExchangeHandler(HttpStatus.SC_MISDIRECTED_REQUEST, "Not authoritative");
+            return new ImmediateResponseExchangeHandler(HttpStatus.SC_MISDIRECTED_REQUEST,
+                            "Not authoritative");
         }
     }
 
@@ -75,9 +75,8 @@ public final class DefaultAsyncResponseExchangeHandlerFactory implements Handler
         final AsyncServerExchangeHandler handler = createHandler(request, context);
         if (handler != null) {
             return decorator != null ? decorator.decorate(handler) : handler;
-        } else {
-            return null;
         }
+        return null;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/TerminalAsyncServerFilter.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/TerminalAsyncServerFilter.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/TerminalAsyncServerFilter.java
index 348f69e..efc9804 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/TerminalAsyncServerFilter.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/TerminalAsyncServerFilter.java
@@ -142,10 +142,9 @@ public final class TerminalAsyncServerFilter implements AsyncFilterHandler {
 
             }, context);
             return exchangeHandler;
-        } else {
-            responseTrigger.submitResponse(new BasicHttpResponse(HttpStatus.SC_NOT_FOUND), new BasicAsyncEntityProducer("Not found"));
-            return null;
         }
+        responseTrigger.submitResponse(new BasicHttpResponse(HttpStatus.SC_NOT_FOUND), new BasicAsyncEntityProducer("Not found"));
+        return null;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java b/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
index ba138a1..9f8b2b7 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
@@ -65,9 +65,8 @@ public final class Host implements NamedEndpoint, Serializable {
                 throw new URISyntaxException(s, "hostname contains blanks");
             }
             return new Host(hostname, port);
-        } else {
-            throw new URISyntaxException(s, "port not found");
         }
+        throw new URISyntaxException(s, "port not found");
     }
 
     @Override
@@ -88,9 +87,8 @@ public final class Host implements NamedEndpoint, Serializable {
         if (o instanceof Host) {
             final Host that = (Host) o;
             return this.lcName.equals(that.lcName) && this.port == that.port;
-        } else {
-            return false;
         }
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java b/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
index 6990eb6..f6cc1c0 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java
@@ -509,11 +509,8 @@ public class URIBuilder {
     }
 
     public List<NameValuePair> getQueryParams() {
-        if (this.queryParams != null) {
-            return new ArrayList<>(this.queryParams);
-        } else {
-            return new ArrayList<>();
-        }
+        return this.queryParams != null ? new ArrayList<>(this.queryParams)
+                        : new ArrayList<NameValuePair>();
     }
 
     public String getFragment() {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOWorkers.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOWorkers.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOWorkers.java
index abd81db..cc80ff7 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOWorkers.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOWorkers.java
@@ -37,11 +37,9 @@ final class IOWorkers {
     }
 
     static Selector newSelector(final SingleCoreIOReactor[] dispatchers) {
-        if (isPowerOfTwo(dispatchers.length)) {
-            return new PowerOfTwoSelector(dispatchers);
-        } else {
-            return new GenericSelector(dispatchers);
-        }
+        return isPowerOfTwo(dispatchers.length)
+                        ? new PowerOfTwoSelector(dispatchers)
+                        : new GenericSelector(dispatchers);
     }
 
     private static boolean isPowerOfTwo(final int val) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
index 2b0cc00..30cf0cc 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
@@ -259,11 +259,7 @@ final class InternalDataChannel extends InternalChannel implements ProtocolIOSes
 
     private IOSession getSessionImpl() {
         final SSLIOSession tlsSession = tlsSessionRef.get();
-        if (tlsSession != null) {
-            return tlsSession;
-        } else {
-            return ioSession;
-        }
+        return tlsSession != null ? tlsSession : ioSession;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/ssl/ReflectionSupport.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/ssl/ReflectionSupport.java b/httpcore5/src/main/java/org/apache/hc/core5/ssl/ReflectionSupport.java
index 308bbab..8b1ab6d 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/ssl/ReflectionSupport.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/ssl/ReflectionSupport.java
@@ -40,7 +40,6 @@ public final class ReflectionSupport {
         }
     }
 
-    @SuppressWarnings("unchecked")
     public static <T> T callGetter(final Object object, final String getterName, final Class<T> resultType) {
         try {
             final Class<?> clazz = object.getClass();

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/http/WritableByteChannelMock.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/WritableByteChannelMock.java b/httpcore5/src/test/java/org/apache/hc/core5/http/WritableByteChannelMock.java
index 9ca574e..99b001c 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/WritableByteChannelMock.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/WritableByteChannelMock.java
@@ -81,13 +81,11 @@ public class WritableByteChannelMock implements WritableByteChannel {
                 src.limit(limit);
                 this.capacityUsed += chunk;
                 return chunk;
-            } else {
-                return 0;
             }
-        } else {
-            this.buf.put(src);
-            return len;
+            return 0;
         }
+        this.buf.put(src);
+        return len;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
index 2913f55..e667001 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestBHttpConnectionBase.java
@@ -44,6 +44,7 @@ import org.apache.hc.core5.io.CloseMode;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
@@ -113,7 +114,7 @@ public class TestBHttpConnectionBase {
         Assert.assertFalse(conn.isOpen());
 
         Mockito.verify(outstream, Mockito.times(1)).write(
-                Mockito.<byte[]>any(), Mockito.anyInt(), Mockito.anyInt());
+                ArgumentMatchers.<byte[]>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
         Mockito.verify(socket, Mockito.times(1)).shutdownInput();
         Mockito.verify(socket, Mockito.times(1)).shutdownOutput();
         Mockito.verify(socket, Mockito.times(1)).close();
@@ -121,7 +122,7 @@ public class TestBHttpConnectionBase {
         conn.close();
         Mockito.verify(socket, Mockito.times(1)).close();
         Mockito.verify(outstream, Mockito.times(1)).write(
-                Mockito.<byte[]>any(), Mockito.anyInt(), Mockito.anyInt());
+                ArgumentMatchers.<byte[]>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
     }
 
     @Test
@@ -142,7 +143,7 @@ public class TestBHttpConnectionBase {
         Assert.assertFalse(conn.isOpen());
 
         Mockito.verify(outstream, Mockito.never()).write(
-                Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt());
+                ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
         Mockito.verify(socket, Mockito.never()).shutdownInput();
         Mockito.verify(socket, Mockito.never()).shutdownOutput();
         Mockito.verify(socket, Mockito.times(1)).close();
@@ -211,7 +212,7 @@ public class TestBHttpConnectionBase {
     public void testSetSocketTimeoutException() throws Exception {
         conn.bind(socket);
 
-        Mockito.doThrow(new SocketException()).when(socket).setSoTimeout(Mockito.anyInt());
+        Mockito.doThrow(new SocketException()).when(socket).setSoTimeout(ArgumentMatchers.anyInt());
 
         conn.setSocketTimeoutMillis(123);
 
@@ -250,9 +251,9 @@ public class TestBHttpConnectionBase {
 
         Assert.assertTrue(conn.awaitInput(432));
 
-        Mockito.verify(socket, Mockito.never()).setSoTimeout(Mockito.anyInt());
+        Mockito.verify(socket, Mockito.never()).setSoTimeout(ArgumentMatchers.anyInt());
         Mockito.verify(instream, Mockito.times(1)).read(
-                Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt());
+                ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
     }
 
     @Test
@@ -270,14 +271,14 @@ public class TestBHttpConnectionBase {
         Mockito.verify(socket, Mockito.times(1)).setSoTimeout(432);
         Mockito.verify(socket, Mockito.times(1)).setSoTimeout(345);
         Mockito.verify(instream, Mockito.times(1)).read(
-                Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt());
+                ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
     }
 
     @Test
     public void testAwaitInputNoData() throws Exception {
         final InputStream instream = Mockito.mock(InputStream.class);
         Mockito.when(socket.getInputStream()).thenReturn(instream);
-        Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
+        Mockito.when(instream.read(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
             .thenReturn(-1);
 
         conn.bind(socket);
@@ -314,7 +315,7 @@ public class TestBHttpConnectionBase {
     public void testStaleWhenEndOfStream() throws Exception {
         final InputStream instream = Mockito.mock(InputStream.class);
         Mockito.when(socket.getInputStream()).thenReturn(instream);
-        Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
+        Mockito.when(instream.read(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
             .thenReturn(-1);
 
         conn.bind(socket);
@@ -327,7 +328,7 @@ public class TestBHttpConnectionBase {
     public void testNotStaleWhenTimeout() throws Exception {
         final InputStream instream = Mockito.mock(InputStream.class);
         Mockito.when(socket.getInputStream()).thenReturn(instream);
-        Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
+        Mockito.when(instream.read(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
             .thenThrow(new SocketTimeoutException());
 
         conn.bind(socket);
@@ -340,7 +341,7 @@ public class TestBHttpConnectionBase {
     public void testStaleWhenIOError() throws Exception {
         final InputStream instream = Mockito.mock(InputStream.class);
         Mockito.when(socket.getInputStream()).thenReturn(instream);
-        Mockito.when(instream.read(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt()))
+        Mockito.when(instream.read(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt()))
             .thenThrow(new SocketException());
 
         conn.bind(socket);

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpRequestExecutor.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpRequestExecutor.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpRequestExecutor.java
index d60ba6d..5bb06aa 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpRequestExecutor.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpRequestExecutor.java
@@ -45,6 +45,7 @@ import org.apache.hc.core5.http.protocol.HttpProcessor;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
 
 public class TestHttpRequestExecutor {
@@ -169,7 +170,7 @@ public class TestHttpRequestExecutor {
         Mockito.verify(conn, Mockito.times(1)).receiveResponseEntity(response);
 
         final ArgumentCaptor<HttpResponse> responseCaptor = ArgumentCaptor.forClass(HttpResponse.class);
-        Mockito.verify(callback, Mockito.times(2)).execute(responseCaptor.capture(), Mockito.eq(conn), Mockito.eq(context));
+        Mockito.verify(callback, Mockito.times(2)).execute(responseCaptor.capture(), ArgumentMatchers.eq(conn), ArgumentMatchers.eq(context));
         final List<HttpResponse> infos = responseCaptor.getAllValues();
         Assert.assertNotNull(infos);
         Assert.assertEquals(2, infos.size());
@@ -283,7 +284,7 @@ public class TestHttpRequestExecutor {
         Mockito.when(conn.receiveResponseHeader()).thenReturn(
                 new BasicClassicHttpResponse(100, "Continue"),
                 new BasicClassicHttpResponse(200, "OK"));
-        Mockito.when(conn.isDataAvailable(Mockito.anyInt())).thenReturn(Boolean.TRUE);
+        Mockito.when(conn.isDataAvailable(ArgumentMatchers.anyInt())).thenReturn(Boolean.TRUE);
 
         final ClassicHttpResponse response = executor.execute(request, conn, context);
         Mockito.verify(conn).sendRequestHeader(request);
@@ -314,7 +315,7 @@ public class TestHttpRequestExecutor {
 
         Mockito.when(conn.receiveResponseHeader()).thenReturn(
                 new BasicClassicHttpResponse(402, "OK"));
-        Mockito.when(conn.isDataAvailable(Mockito.anyInt())).thenReturn(Boolean.TRUE);
+        Mockito.when(conn.isDataAvailable(ArgumentMatchers.anyInt())).thenReturn(Boolean.TRUE);
 
         final ClassicHttpResponse response = executor.execute(request, conn, context);
         Mockito.verify(conn).sendRequestHeader(request);
@@ -349,7 +350,7 @@ public class TestHttpRequestExecutor {
                 new BasicClassicHttpResponse(100, "Continue"),
                 new BasicClassicHttpResponse(111, "Huh?"),
                 new BasicClassicHttpResponse(200, "OK"));
-        Mockito.when(conn.isDataAvailable(Mockito.anyInt())).thenReturn(Boolean.TRUE);
+        Mockito.when(conn.isDataAvailable(ArgumentMatchers.anyInt())).thenReturn(Boolean.TRUE);
 
         final HttpResponseInformationCallback callback = Mockito.mock(HttpResponseInformationCallback.class);
 
@@ -362,7 +363,7 @@ public class TestHttpRequestExecutor {
         Mockito.verify(conn).receiveResponseEntity(response);
 
         final ArgumentCaptor<HttpResponse> responseCaptor = ArgumentCaptor.forClass(HttpResponse.class);
-        Mockito.verify(callback, Mockito.times(2)).execute(responseCaptor.capture(), Mockito.eq(conn), Mockito.eq(context));
+        Mockito.verify(callback, Mockito.times(2)).execute(responseCaptor.capture(), ArgumentMatchers.eq(conn), ArgumentMatchers.eq(context));
         final List<HttpResponse> infos = responseCaptor.getAllValues();
         Assert.assertNotNull(infos);
         Assert.assertEquals(2, infos.size());
@@ -394,7 +395,7 @@ public class TestHttpRequestExecutor {
 
         Mockito.when(conn.receiveResponseHeader()).thenReturn(
                 new BasicClassicHttpResponse(200, "OK"));
-        Mockito.when(conn.isDataAvailable(Mockito.anyInt())).thenReturn(Boolean.FALSE);
+        Mockito.when(conn.isDataAvailable(ArgumentMatchers.anyInt())).thenReturn(Boolean.FALSE);
 
         final ClassicHttpResponse response = executor.execute(request, conn, context);
         Mockito.verify(conn).sendRequestHeader(request);

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpService.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpService.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpService.java
index 7dd9717..1dcd472 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpService.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestHttpService.java
@@ -57,6 +57,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.ArgumentMatcher;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
@@ -138,14 +139,14 @@ public class TestHttpService {
 
         Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
         Mockito.when(responseFactory.newHttpResponse(200)).thenReturn(response);
-        Mockito.when(connReuseStrategy.keepAlive(Mockito.eq(request), Mockito.argThat(new ArgumentMatcher<HttpResponse>() {
+        Mockito.when(connReuseStrategy.keepAlive(ArgumentMatchers.eq(request), ArgumentMatchers.argThat(new ArgumentMatcher<HttpResponse>() {
 
             @Override
             public boolean matches(final HttpResponse errorResponse) {
                 return errorResponse.getCode() == HttpStatus.SC_NOT_IMPLEMENTED;
             }
 
-        }), Mockito.eq(context))).thenReturn(Boolean.TRUE);
+        }), ArgumentMatchers.eq(context))).thenReturn(Boolean.TRUE);
 
         httpservice.handleRequest(conn, context);
         final ArgumentCaptor<ClassicHttpResponse> responseCaptor = ArgumentCaptor.forClass(ClassicHttpResponse.class);
@@ -178,14 +179,14 @@ public class TestHttpService {
 
         Mockito.when(conn.receiveRequestHeader()).thenReturn(request);
         Mockito.when(responseFactory.newHttpResponse(200)).thenReturn(response);
-        Mockito.when(connReuseStrategy.keepAlive(Mockito.eq(request), Mockito.argThat(new ArgumentMatcher<HttpResponse>() {
+        Mockito.when(connReuseStrategy.keepAlive(ArgumentMatchers.eq(request), ArgumentMatchers.argThat(new ArgumentMatcher<HttpResponse>() {
 
             @Override
             public boolean matches(final HttpResponse errorResponse) {
                 return errorResponse.getCode() == HttpStatus.SC_NOT_IMPLEMENTED;
             }
 
-        }), Mockito.eq(context))).thenReturn(Boolean.TRUE);
+        }), ArgumentMatchers.eq(context))).thenReturn(Boolean.TRUE);
 
         httpservice.handleRequest(conn, context);
         final ArgumentCaptor<ClassicHttpResponse> responseCaptor = ArgumentCaptor.forClass(ClassicHttpResponse.class);
@@ -343,7 +344,7 @@ public class TestHttpService {
         Mockito.verify(httprocessor).process(response, response.getEntity(), context);
 
         Mockito.verify(conn).sendResponseHeader(response);
-        Mockito.verify(conn, Mockito.never()).sendResponseEntity(Mockito.<ClassicHttpResponse>any());
+        Mockito.verify(conn, Mockito.never()).sendResponseEntity(ArgumentMatchers.<ClassicHttpResponse>any());
         Mockito.verify(conn).flush();
         Mockito.verify(conn, Mockito.never()).close();
         Mockito.verify(response).close();
@@ -367,7 +368,7 @@ public class TestHttpService {
         Mockito.verify(requestHandler).handle(request, response, context);
 
         Mockito.verify(conn).sendResponseHeader(response);
-        Mockito.verify(conn, Mockito.never()).sendResponseEntity(Mockito.<ClassicHttpResponse>any());
+        Mockito.verify(conn, Mockito.never()).sendResponseEntity(ArgumentMatchers.<ClassicHttpResponse>any());
         Mockito.verify(conn).flush();
         Mockito.verify(conn, Mockito.never()).close();
         Mockito.verify(response).close();

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
index f532c81..64f8891 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
@@ -44,6 +44,7 @@ import org.apache.hc.core5.http.io.SessionOutputBuffer;
 import org.apache.hc.core5.util.CharArrayBuffer;
 import org.junit.Assert;
 import org.junit.Test;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
 
 public class TestSessionInOutBuffers {
@@ -376,8 +377,8 @@ public class TestSessionInOutBuffers {
         outbuffer.write(new byte[] {1, 2}, outputStream);
         outbuffer.write(new byte[]{3, 4}, outputStream);
         outbuffer.flush(outputStream);
-        Mockito.verify(outputStream, Mockito.times(1)).write(Mockito.<byte[]>any(), Mockito.anyInt(), Mockito.anyInt());
-        Mockito.verify(outputStream, Mockito.never()).write(Mockito.anyInt());
+        Mockito.verify(outputStream, Mockito.times(1)).write(ArgumentMatchers.<byte[]>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
+        Mockito.verify(outputStream, Mockito.never()).write(ArgumentMatchers.anyInt());
     }
 
     @Test
@@ -388,8 +389,8 @@ public class TestSessionInOutBuffers {
         outbuffer.write(2, outputStream);
         outbuffer.write(new byte[] {1, 2}, outputStream);
         outbuffer.write(new byte[]{3, 4}, outputStream);
-        Mockito.verify(outputStream, Mockito.times(2)).write(Mockito.<byte []>any(), Mockito.anyInt(), Mockito.anyInt());
-        Mockito.verify(outputStream, Mockito.times(2)).write(Mockito.anyInt());
+        Mockito.verify(outputStream, Mockito.times(2)).write(ArgumentMatchers.<byte []>any(), ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt());
+        Mockito.verify(outputStream, Mockito.times(2)).write(ArgumentMatchers.anyInt());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
index 2417b7d..97bdf49 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/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/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java
index b1fb8db..614b02a 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java
@@ -29,7 +29,6 @@ package org.apache.hc.core5.http.impl.nio;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.nio.channels.Channels;
 import java.nio.channels.ReadableByteChannel;
@@ -61,13 +60,11 @@ public class TestSessionInOutBuffers {
         return Channels.newChannel(new ByteArrayInputStream(bytes));
     }
 
-    private static ReadableByteChannel newChannel(final String s, final Charset charset)
-            throws UnsupportedEncodingException {
+    private static ReadableByteChannel newChannel(final String s, final Charset charset) {
         return Channels.newChannel(new ByteArrayInputStream(s.getBytes(charset)));
     }
 
-    private static ReadableByteChannel newChannel(final String s)
-            throws UnsupportedEncodingException {
+    private static ReadableByteChannel newChannel(final String s) {
         return newChannel(s, StandardCharsets.US_ASCII);
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicLineParser.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicLineParser.java b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicLineParser.java
index a3813a2..03356b8 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicLineParser.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicLineParser.java
@@ -45,7 +45,7 @@ public class TestBasicLineParser {
 
     @Before
     public void setup() {
-        this.parser = this.parser.INSTANCE;
+        this.parser = BasicLineParser.INSTANCE;
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractBinAsyncEntityConsumer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractBinAsyncEntityConsumer.java b/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractBinAsyncEntityConsumer.java
index 29b62a1..a118c32 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractBinAsyncEntityConsumer.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractBinAsyncEntityConsumer.java
@@ -83,7 +83,7 @@ public class TestAbstractBinAsyncEntityConsumer {
         public void releaseResources() {
         }
 
-    };
+    }
 
     @Test
     public void testConsumeData() throws Exception {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractBinAsyncEntityProducer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractBinAsyncEntityProducer.java b/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractBinAsyncEntityProducer.java
index a38b968..ba026fe 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractBinAsyncEntityProducer.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractBinAsyncEntityProducer.java
@@ -90,7 +90,7 @@ public class TestAbstractBinAsyncEntityProducer {
         public void releaseResources() {
         }
 
-    };
+    }
 
     @Test
     public void testProduceDataNoBuffering() throws Exception {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractCharAsyncEntityConsumer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractCharAsyncEntityConsumer.java b/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractCharAsyncEntityConsumer.java
index 68898a9..54f20cb 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractCharAsyncEntityConsumer.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractCharAsyncEntityConsumer.java
@@ -75,7 +75,7 @@ public class TestAbstractCharAsyncEntityConsumer {
             buffer.setLength(0);
         }
 
-    };
+    }
 
     @Test
     public void testConsumeData() throws Exception {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractCharAsyncEntityProducer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractCharAsyncEntityProducer.java b/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractCharAsyncEntityProducer.java
index 221ea42..329302c 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractCharAsyncEntityProducer.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/nio/entity/TestAbstractCharAsyncEntityProducer.java
@@ -86,7 +86,7 @@ public class TestAbstractCharAsyncEntityProducer {
         public void failed(final Exception cause) {
         }
 
-    };
+    }
 
     @Test
     public void testProduceDataNoBuffering() throws Exception {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/pool/TestLaxConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/pool/TestLaxConnPool.java b/httpcore5/src/test/java/org/apache/hc/core5/pool/TestLaxConnPool.java
index 5f0284b..9b95d35 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/pool/TestLaxConnPool.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/pool/TestLaxConnPool.java
@@ -36,6 +36,7 @@ import org.apache.hc.core5.util.TimeValue;
 import org.apache.hc.core5.util.Timeout;
 import org.junit.Assert;
 import org.junit.Test;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
 
 public class TestLaxConnPool {
@@ -90,8 +91,8 @@ public class TestLaxConnPool {
         pool.release(entry1, true);
         pool.release(entry2, true);
         pool.release(entry3, false);
-        Mockito.verify(conn1, Mockito.never()).close(Mockito.<CloseMode>any());
-        Mockito.verify(conn2, Mockito.never()).close(Mockito.<CloseMode>any());
+        Mockito.verify(conn1, Mockito.never()).close(ArgumentMatchers.<CloseMode>any());
+        Mockito.verify(conn2, Mockito.never()).close(ArgumentMatchers.<CloseMode>any());
         Mockito.verify(conn3, Mockito.times(1)).close(CloseMode.GRACEFUL);
 
         final PoolStats totals = pool.getTotalStats();
@@ -258,7 +259,7 @@ public class TestLaxConnPool {
         pool.closeExpired();
 
         Mockito.verify(conn1).close(CloseMode.GRACEFUL);
-        Mockito.verify(conn2, Mockito.never()).close(Mockito.<CloseMode>any());
+        Mockito.verify(conn2, Mockito.never()).close(ArgumentMatchers.<CloseMode>any());
 
         final PoolStats totals = pool.getTotalStats();
         Assert.assertEquals(1, totals.getAvailable());
@@ -300,7 +301,7 @@ public class TestLaxConnPool {
         pool.closeIdle(TimeValue.of(50, TimeUnit.MILLISECONDS));
 
         Mockito.verify(conn1).close(CloseMode.GRACEFUL);
-        Mockito.verify(conn2, Mockito.never()).close(Mockito.<CloseMode>any());
+        Mockito.verify(conn2, Mockito.never()).close(ArgumentMatchers.<CloseMode>any());
 
         PoolStats totals = pool.getTotalStats();
         Assert.assertEquals(1, totals.getAvailable());

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/pool/TestStrictConnPool.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/pool/TestStrictConnPool.java b/httpcore5/src/test/java/org/apache/hc/core5/pool/TestStrictConnPool.java
index a7e4087..3eedf45 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/pool/TestStrictConnPool.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/pool/TestStrictConnPool.java
@@ -36,6 +36,7 @@ import org.apache.hc.core5.util.TimeValue;
 import org.apache.hc.core5.util.Timeout;
 import org.junit.Assert;
 import org.junit.Test;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
 
 public class TestStrictConnPool {
@@ -95,8 +96,8 @@ public class TestStrictConnPool {
         pool.release(entry1, true);
         pool.release(entry2, true);
         pool.release(entry3, false);
-        Mockito.verify(conn1, Mockito.never()).close(Mockito.<CloseMode>any());
-        Mockito.verify(conn2, Mockito.never()).close(Mockito.<CloseMode>any());
+        Mockito.verify(conn1, Mockito.never()).close(ArgumentMatchers.<CloseMode>any());
+        Mockito.verify(conn2, Mockito.never()).close(ArgumentMatchers.<CloseMode>any());
         Mockito.verify(conn3, Mockito.times(1)).close(CloseMode.GRACEFUL);
 
         final PoolStats totals = pool.getTotalStats();
@@ -349,7 +350,7 @@ public class TestStrictConnPool {
         Assert.assertTrue(future5.isDone());
 
         Mockito.verify(conn2).close(CloseMode.GRACEFUL);
-        Mockito.verify(conn1, Mockito.never()).close(Mockito.<CloseMode>any());
+        Mockito.verify(conn1, Mockito.never()).close(ArgumentMatchers.<CloseMode>any());
 
         totals = pool.getTotalStats();
         Assert.assertEquals(1, totals.getAvailable());
@@ -419,7 +420,7 @@ public class TestStrictConnPool {
         pool.closeExpired();
 
         Mockito.verify(conn1).close(CloseMode.GRACEFUL);
-        Mockito.verify(conn2, Mockito.never()).close(Mockito.<CloseMode>any());
+        Mockito.verify(conn2, Mockito.never()).close(ArgumentMatchers.<CloseMode>any());
 
         final PoolStats totals = pool.getTotalStats();
         Assert.assertEquals(1, totals.getAvailable());
@@ -461,7 +462,7 @@ public class TestStrictConnPool {
         pool.closeIdle(TimeValue.of(50, TimeUnit.MILLISECONDS));
 
         Mockito.verify(conn1).close(CloseMode.GRACEFUL);
-        Mockito.verify(conn2, Mockito.never()).close(Mockito.<CloseMode>any());
+        Mockito.verify(conn2, Mockito.never()).close(ArgumentMatchers.<CloseMode>any());
 
         PoolStats totals = pool.getTotalStats();
         Assert.assertEquals(1, totals.getAvailable());

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java b/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java
index bb38e29..1247524 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/reactor/TestAbstractIOSessionPool.java
@@ -40,6 +40,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
 import org.mockito.ArgumentMatcher;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
@@ -63,7 +64,6 @@ public class TestAbstractIOSessionPool {
     private AbstractIOSessionPool<String> impl;
 
     @Before
-    @SuppressWarnings("unchecked")
     public void setup() {
         impl = Mockito.mock(AbstractIOSessionPool.class, Mockito.withSettings()
                 .defaultAnswer(Answers.CALLS_REAL_METHODS)
@@ -74,9 +74,9 @@ public class TestAbstractIOSessionPool {
     public void testGetSessions() throws Exception {
 
         Mockito.when(impl.connectSession(
-                Mockito.anyString(),
-                Mockito.<Timeout>any(),
-                Mockito.<FutureCallback<IOSession>>any())).thenReturn(connectFuture);
+                ArgumentMatchers.anyString(),
+                ArgumentMatchers.<Timeout>any(),
+                ArgumentMatchers.<FutureCallback<IOSession>>any())).thenReturn(connectFuture);
 
         Mockito.doAnswer(new Answer() {
 
@@ -87,7 +87,7 @@ public class TestAbstractIOSessionPool {
                 return null;
             }
 
-        }).when(impl).validateSession(Mockito.<IOSession>any(), Mockito.<Callback<Boolean>>any());
+        }).when(impl).validateSession(ArgumentMatchers.<IOSession>any(), ArgumentMatchers.<Callback<Boolean>>any());
 
         final Future<IOSession> future1 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
         Assert.assertThat(future1, CoreMatchers.notNullValue());
@@ -95,9 +95,9 @@ public class TestAbstractIOSessionPool {
         Assert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
 
         Mockito.verify(impl).connectSession(
-                Mockito.eq("somehost"),
-                Mockito.eq(Timeout.ofSeconds(123L)),
-                Mockito.<FutureCallback<IOSession>>any());
+                ArgumentMatchers.eq("somehost"),
+                ArgumentMatchers.eq(Timeout.ofSeconds(123L)),
+                ArgumentMatchers.<FutureCallback<IOSession>>any());
 
         final Future<IOSession> future2 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
         Assert.assertThat(future2, CoreMatchers.notNullValue());
@@ -105,9 +105,9 @@ public class TestAbstractIOSessionPool {
         Assert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
 
         Mockito.verify(impl, Mockito.times(1)).connectSession(
-                Mockito.eq("somehost"),
-                Mockito.<Timeout>any(),
-                Mockito.argThat(new ArgumentMatcher<FutureCallback<IOSession>>() {
+                ArgumentMatchers.eq("somehost"),
+                ArgumentMatchers.<Timeout>any(),
+                ArgumentMatchers.argThat(new ArgumentMatcher<FutureCallback<IOSession>>() {
 
                     @Override
                     public boolean matches(final FutureCallback<IOSession> callback) {
@@ -123,16 +123,16 @@ public class TestAbstractIOSessionPool {
         Assert.assertThat(future2.isDone(), CoreMatchers.equalTo(true));
         Assert.assertThat(future2.get(), CoreMatchers.sameInstance(ioSession1));
 
-        Mockito.verify(impl, Mockito.times(2)).validateSession(Mockito.<IOSession>any(), Mockito.<Callback<Boolean>>any());
+        Mockito.verify(impl, Mockito.times(2)).validateSession(ArgumentMatchers.<IOSession>any(), ArgumentMatchers.<Callback<Boolean>>any());
 
         final Future<IOSession> future3 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
 
         Mockito.verify(impl, Mockito.times(1)).connectSession(
-                Mockito.eq("somehost"),
-                Mockito.<Timeout>any(),
-                Mockito.<FutureCallback<IOSession>>any());
+                ArgumentMatchers.eq("somehost"),
+                ArgumentMatchers.<Timeout>any(),
+                ArgumentMatchers.<FutureCallback<IOSession>>any());
 
-        Mockito.verify(impl, Mockito.times(3)).validateSession(Mockito.<IOSession>any(), Mockito.<Callback<Boolean>>any());
+        Mockito.verify(impl, Mockito.times(3)).validateSession(ArgumentMatchers.<IOSession>any(), ArgumentMatchers.<Callback<Boolean>>any());
 
         Assert.assertThat(future3.isDone(), CoreMatchers.equalTo(true));
         Assert.assertThat(future3.get(), CoreMatchers.sameInstance(ioSession1));
@@ -142,9 +142,9 @@ public class TestAbstractIOSessionPool {
     public void testGetSessionFailure() throws Exception {
 
         Mockito.when(impl.connectSession(
-                Mockito.anyString(),
-                Mockito.<Timeout>any(),
-                Mockito.<FutureCallback<IOSession>>any())).thenReturn(connectFuture);
+                ArgumentMatchers.anyString(),
+                ArgumentMatchers.<Timeout>any(),
+                ArgumentMatchers.<FutureCallback<IOSession>>any())).thenReturn(connectFuture);
 
         final Future<IOSession> future1 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
         Assert.assertThat(future1, CoreMatchers.notNullValue());
@@ -152,9 +152,9 @@ public class TestAbstractIOSessionPool {
         Assert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
 
         Mockito.verify(impl).connectSession(
-                Mockito.eq("somehost"),
-                Mockito.eq(Timeout.ofSeconds(123L)),
-                Mockito.<FutureCallback<IOSession>>any());
+                ArgumentMatchers.eq("somehost"),
+                ArgumentMatchers.eq(Timeout.ofSeconds(123L)),
+                ArgumentMatchers.<FutureCallback<IOSession>>any());
 
         final Future<IOSession> future2 = impl.getSession("somehost", Timeout.ofSeconds(123L), null);
         Assert.assertThat(future2, CoreMatchers.notNullValue());
@@ -162,9 +162,9 @@ public class TestAbstractIOSessionPool {
         Assert.assertThat(impl.getRoutes(), CoreMatchers.hasItem("somehost"));
 
         Mockito.verify(impl, Mockito.times(1)).connectSession(
-                Mockito.eq("somehost"),
-                Mockito.<Timeout>any(),
-                Mockito.argThat(new ArgumentMatcher<FutureCallback<IOSession>>() {
+                ArgumentMatchers.eq("somehost"),
+                ArgumentMatchers.<Timeout>any(),
+                ArgumentMatchers.argThat(new ArgumentMatcher<FutureCallback<IOSession>>() {
 
                     @Override
                     public boolean matches(final FutureCallback<IOSession> callback) {
@@ -198,7 +198,7 @@ public class TestAbstractIOSessionPool {
 
         Mockito.verify(impl).closeSession(ioSession1, CloseMode.GRACEFUL);
         Mockito.verify(impl).closeSession(ioSession2, CloseMode.GRACEFUL);
-        Mockito.verify(connectFuture).cancel(Mockito.anyBoolean());
+        Mockito.verify(connectFuture).cancel(ArgumentMatchers.anyBoolean());
         Mockito.verify(callback1).cancelled();
         Mockito.verify(callback2).cancelled();
     }
@@ -260,14 +260,14 @@ public class TestAbstractIOSessionPool {
                 return null;
             }
 
-        }).when(impl).validateSession(Mockito.<IOSession>any(), Mockito.<Callback<Boolean>>any());
+        }).when(impl).validateSession(ArgumentMatchers.<IOSession>any(), ArgumentMatchers.<Callback<Boolean>>any());
 
         impl.getSession("somehost", Timeout.ofSeconds(123L), null);
 
         Mockito.verify(impl, Mockito.times(1)).connectSession(
-                Mockito.eq("somehost"),
-                Mockito.eq(Timeout.ofSeconds(123L)),
-                Mockito.<FutureCallback<IOSession>>any());
+                ArgumentMatchers.eq("somehost"),
+                ArgumentMatchers.eq(Timeout.ofSeconds(123L)),
+                ArgumentMatchers.<FutureCallback<IOSession>>any());
     }
 
     @Test
@@ -281,9 +281,9 @@ public class TestAbstractIOSessionPool {
         impl.getSession("somehost", Timeout.ofSeconds(123L), null);
 
         Mockito.verify(impl).connectSession(
-                Mockito.eq("somehost"),
-                Mockito.eq(Timeout.ofSeconds(123L)),
-                Mockito.<FutureCallback<IOSession>>any());
+                ArgumentMatchers.eq("somehost"),
+                ArgumentMatchers.eq(Timeout.ofSeconds(123L)),
+                ArgumentMatchers.<FutureCallback<IOSession>>any());
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java b/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
index 1e77179..ba2db45 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java
@@ -562,12 +562,9 @@ public class TestSSLContextBuilder {
 
         final PrivateKeyStrategy privateKeyStrategy = new PrivateKeyStrategy() {
             @Override
-            public String chooseAlias(final Map<String, PrivateKeyDetails> aliases, final SSLParameters sslParameters) {
-                if (aliases.keySet().contains("client2")) {
-                    return "client2";
-                } else {
-                    return null;
-                }
+            public String chooseAlias(final Map<String, PrivateKeyDetails> aliases,
+                            final SSLParameters sslParameters) {
+                return aliases.keySet().contains("client2") ? "client2" : null;
             }
         };
 


[7/8] httpcomponents-core git commit: Javadocs for abstract data channels, data producers and data consumers

Posted by ol...@apache.org.
Javadocs for abstract data channels, data producers and data consumers


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/936ac6f1
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/936ac6f1
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/936ac6f1

Branch: refs/heads/api_javadocs
Commit: 936ac6f1428a77a578f0cf0c136f6f00c8f0241f
Parents: 49c6296
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sat Aug 4 13:34:01 2018 +0200
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Aug 5 13:06:12 2018 +0200

----------------------------------------------------------------------
 .../hc/core5/http/nio/AsyncDataConsumer.java    | 24 ++++++++++++++++
 .../hc/core5/http/nio/AsyncDataProducer.java    | 14 ++++++++++
 .../hc/core5/http/nio/CapacityChannel.java      |  9 ++++++
 .../hc/core5/http/nio/DataStreamChannel.java    | 29 +++++++++++++++++++-
 .../hc/core5/http/nio/ResourceHolder.java       |  7 +++++
 .../apache/hc/core5/http/nio/StreamChannel.java | 21 +++++++++++++-
 .../apache/hc/core5/http/nio/package-info.java  | 12 ++++++++
 7 files changed, 114 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/936ac6f1/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncDataConsumer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncDataConsumer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncDataConsumer.java
index 6f3456e..4044837 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncDataConsumer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncDataConsumer.java
@@ -40,10 +40,34 @@ import org.apache.hc.core5.http.HttpException;
  */
 public interface AsyncDataConsumer extends ResourceHolder {
 
+    /**
+     * Triggered to signal ability of the underlying data stream to receive
+     * data capacity update. The data consumer can choose to write data
+     * immediately inside the call or asynchronously at some later point.
+     *
+     * @param capacityChannel the channel for capacity updates.
+     */
     void updateCapacity(CapacityChannel capacityChannel) throws IOException;
 
+    /**
+     * Triggered to pass incoming data to the data consumer. The consumer must
+     * consume the entire content of the data buffer. The consumer must stop
+     * incrementing its capacity on the capacity channel and must return zero
+     * capacity from this method if it is unable to accept more data.
+     * Once the data consumer has handled accumulated data or allocated more
+     * intermediate storage it can update its capacity information on the capacity
+     * channel.
+     *
+     * @param src data source.
+     * @return current capacity of the data consumer
+     */
     int consume(ByteBuffer src) throws IOException;
 
+    /**
+     * Triggered to signal termination of the data stream.
+     *
+     * @param trailers data stream trailers.
+     */
     void streamEnd(List<? extends Header> trailers) throws HttpException, IOException;
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/936ac6f1/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncDataProducer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncDataProducer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncDataProducer.java
index 4e4a839..5965636 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncDataProducer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/AsyncDataProducer.java
@@ -35,8 +35,22 @@ import java.io.IOException;
  */
 public interface AsyncDataProducer extends ResourceHolder {
 
+    /**
+     * Returns the number of bytes immediately available for output.
+     * This method can be used as a hint to control output events
+     * of the underlying I/O session.
+     *
+     * @return the number of bytes immediately available for output
+     */
     int available();
 
+    /**
+     * Triggered to signal the ability of the underlying data channel
+     * to accept more data. The data producer can choose to write data
+     * immediately inside the call or asynchronously at some later point.
+     *
+     * @param channel the data channel capable to accepting more data.
+     */
     void produce(DataStreamChannel channel) throws IOException;
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/936ac6f1/httpcore5/src/main/java/org/apache/hc/core5/http/nio/CapacityChannel.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/CapacityChannel.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/CapacityChannel.java
index efc0304..4e724ef 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/CapacityChannel.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/CapacityChannel.java
@@ -35,12 +35,21 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
  * Abstract capacity update channel.
  * <p>
  * Implementations are expected to be thread-safe.
+ * </p>
  *
  * @since 5.0
  */
 @Contract(threading = ThreadingBehavior.SAFE)
 public interface CapacityChannel {
 
+    /**
+     * Updates data capacity information. The total number of
+     * bytes the consumer is capable of accepting is incremented
+     * by the given increment number.
+     *
+     * @param increment non-negative number of extra bytes the consumer
+     * can accept.
+     */
     void update(int increment) throws IOException;
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/936ac6f1/httpcore5/src/main/java/org/apache/hc/core5/http/nio/DataStreamChannel.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/DataStreamChannel.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/DataStreamChannel.java
index 2934242..e30e42d 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/DataStreamChannel.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/DataStreamChannel.java
@@ -36,17 +36,44 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.Header;
 
 /**
- * Abstract data stream channel
+ * Abstract byte stream channel
  * <p>
  * Implementations are expected to be thread-safe.
+ * </p>
  *
  * @since 5.0
  */
 @Contract(threading = ThreadingBehavior.SAFE)
 public interface DataStreamChannel extends StreamChannel<ByteBuffer> {
 
+    /**
+     * Signals intent by the data producer to produce more data.
+     * Once the channel is able to accept data its handler is expected
+     * to trigger an event to notify the data producer.
+     */
     void requestOutput();
 
+    /**
+     * Writes data from the buffer into the underlying byte stream.
+     * If the underlying byte stream is temporarily unable to accept more data
+     * it can return zero to indicate that no data could be written to the data
+     * stream. The data producer can choose to call {@link #requestOutput()}
+     * to signal its intent to produce more data.
+     *
+     * @param src source of data
+     *
+     * @return The number of bytes written, possibly zero
+     */
+    int write(ByteBuffer src) throws IOException;
+
+    /**
+     * Terminates the underlying data stream and optionally writes
+     * a closing sequence with the given trailers.
+     * <p>
+     * Please note that some data streams may not support trailers
+     * and may silently ignore the trailers parameter.
+     * </p>
+     */
     void endStream(List<? extends Header> trailers) throws IOException;
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/936ac6f1/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ResourceHolder.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ResourceHolder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ResourceHolder.java
index 5c1a7ef..255b2f5 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ResourceHolder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/ResourceHolder.java
@@ -26,15 +26,22 @@
  */
 package org.apache.hc.core5.http.nio;
 
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+
 /**
  * Abstract resource holder.
  * <p>
  * Implementations are expected to ensure that {@link #releaseResources()} methods is idempotent and is
  * safe to invoke multiple times.
  * </p>
+ * <p>
+ * Implementations are expected to be thread-safe.
+ * </p>
  *
  * @since 5.0
  */
+@Contract(threading = ThreadingBehavior.SAFE)
 public interface ResourceHolder {
 
     void releaseResources();

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/936ac6f1/httpcore5/src/main/java/org/apache/hc/core5/http/nio/StreamChannel.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/StreamChannel.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/StreamChannel.java
index 00bf209..49fc1fd 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/StreamChannel.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/StreamChannel.java
@@ -30,14 +30,33 @@ package org.apache.hc.core5.http.nio;
 import java.io.IOException;
 import java.nio.Buffer;
 
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+
 /**
- * Abstract stream channel.
+ * Abstract data stream channel.
+ * <p>
+ * Implementations are expected to be thread-safe.
+ * </p>
+ *
+ * @param <T> data container accepted by the channel.
  *
  * @since 5.0
  */
+@Contract(threading = ThreadingBehavior.SAFE)
 public interface StreamChannel<T extends Buffer> {
 
+    /**
+     * Writes data from the data container into the underlying data stream.
+     *
+     * @param src source of data
+     * @return The number of elements written, possibly zero
+     */
     int write(T src) throws IOException;
 
+    /**
+     * Terminates the underlying data stream and optionally writes
+     * a closing sequence.
+     */
     void endStream() throws IOException;
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/936ac6f1/httpcore5/src/main/java/org/apache/hc/core5/http/nio/package-info.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/package-info.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/package-info.java
index 00b5fd9..0101117 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/package-info.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/package-info.java
@@ -28,5 +28,17 @@
 /**
  * Core HTTP component APIs and primitives for asynchronous, event
  * driven communication.
+ * <p>
+ * The application programming interface is based on the concept
+ * of channels and event handlers. The channels act as conduits
+ * for asynchronous data output. They are generally expected to
+ * be thread-safe and could be used by multiple threads concurrently.
+ * The event handlers react to as asynchronous signal or event and
+ * handle them. Event handlers can be specialized as data producers,
+ * data consumers or can be both. Generally event handlers can only
+ * be used by a signle thread at a time and do not require synchronization
+ * as long as they do not interact with event handlers run by separate
+ * threads.
+ * <p/>
  */
 package org.apache.hc.core5.http.nio;


[4/8] httpcomponents-core git commit: Refactor common code in a new Closer utility class.

Posted by ol...@apache.org.
Refactor common code in a new Closer utility class.

Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/3c39a387
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/3c39a387
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/3c39a387

Branch: refs/heads/api_javadocs
Commit: 3c39a3874ddb2b3699f8294952d3d638dfea39eb
Parents: 27ee7a1
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 14:24:12 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sat Aug 4 23:47:03 2018 +0200

----------------------------------------------------------------------
 .../core5/http/impl/io/BHttpConnectionBase.java |  6 +--
 .../core5/http/impl/io/HttpRequestExecutor.java | 10 +---
 .../apache/hc/core5/reactor/IOSessionImpl.java  |  7 +--
 .../hc/core5/reactor/SingleCoreIOReactor.java   |  7 +--
 .../reactor/SingleCoreListeningIOReactor.java   |  6 +--
 .../java/org/apache/hc/core5/util/Closer.java   | 53 ++++++++++++++++++++
 6 files changed, 63 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3c39a387/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
index 1ce2083..c1979d4 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
@@ -61,6 +61,7 @@ import org.apache.hc.core5.http.io.SessionOutputBuffer;
 import org.apache.hc.core5.io.CloseMode;
 import org.apache.hc.core5.net.InetAddressUtils;
 import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.Closer;
 
 class BHttpConnectionBase implements BHttpConnection {
 
@@ -229,10 +230,7 @@ class BHttpConnectionBase implements BHttpConnection {
                 }
             } catch (final IOException ignore) {
             } finally {
-                try {
-                    socket.close();
-                } catch (final IOException ignore) {
-                }
+                Closer.closeQuietly(socket);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3c39a387/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
index 86155e3..93ddb47 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
@@ -53,6 +53,7 @@ import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.http.protocol.HttpCoreContext;
 import org.apache.hc.core5.http.protocol.HttpProcessor;
 import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.Closer;
 
 /**
  * {@code HttpRequestExecutor} is a client side HTTP protocol handler based
@@ -198,7 +199,7 @@ public class HttpRequestExecutor {
             return response;
 
         } catch (final HttpException | IOException | RuntimeException ex) {
-            closeConnection(conn);
+            Closer.closeQuietly(conn);
             throw ex;
         }
     }
@@ -222,13 +223,6 @@ public class HttpRequestExecutor {
         return execute(request, conn, null, context);
     }
 
-    private static void closeConnection(final HttpClientConnection conn) {
-        try {
-            conn.close();
-        } catch (final IOException ignore) {
-        }
-    }
-
     /**
      * Pre-process the given request using the given protocol processor and
      * initiates the process of request execution.

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3c39a387/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
index c5aff5e..98b3b7a 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
@@ -27,7 +27,6 @@
 
 package org.apache.hc.core5.reactor;
 
-import java.io.IOException;
 import java.net.SocketAddress;
 import java.nio.channels.ByteChannel;
 import java.nio.channels.SelectionKey;
@@ -41,6 +40,7 @@ import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.hc.core5.io.CloseMode;
 import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.Closer;
 
 class IOSessionImpl implements IOSession {
 
@@ -199,10 +199,7 @@ class IOSessionImpl implements IOSession {
         if (this.status.compareAndSet(ACTIVE, CLOSED)) {
             this.key.cancel();
             this.key.attach(null);
-            try {
-                this.key.channel().close();
-            } catch (final IOException ignore) {
-            }
+            Closer.closeQuietly(this.key.channel());
             if (this.key.selector().isOpen()) {
                 this.key.selector().wakeup();
             }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3c39a387/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
index 9761ba1..0b16bed 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
@@ -48,6 +48,7 @@ import org.apache.hc.core5.function.Decorator;
 import org.apache.hc.core5.io.CloseMode;
 import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.Closer;
 import org.apache.hc.core5.util.TimeValue;
 
 class SingleCoreIOReactor extends AbstractSingleCoreIOReactor implements ConnectionInitiator {
@@ -293,11 +294,7 @@ class SingleCoreIOReactor extends AbstractSingleCoreIOReactor implements Connect
                 try {
                     processConnectionRequest(socketChannel, sessionRequest);
                 } catch (final IOException | SecurityException ex) {
-                    try {
-                        socketChannel.close();
-                    } catch (final IOException ignore) {
-                        // Ignore
-                    }
+                    Closer.closeQuietly(socketChannel);
                     sessionRequest.failed(ex);
                 }
             }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3c39a387/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java
index b83cc5c..a30dd2e 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java
@@ -47,6 +47,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.hc.core5.concurrent.BasicFuture;
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.function.Callback;
+import org.apache.hc.core5.util.Closer;
 
 class SingleCoreListeningIOReactor extends AbstractSingleCoreIOReactor implements ConnectionAcceptor {
 
@@ -167,10 +168,7 @@ class SingleCoreListeningIOReactor extends AbstractSingleCoreIOReactor implement
                 this.endpoints.put(endpoint, Boolean.TRUE);
                 request.completed(endpoint);
             } catch (final IOException ex) {
-                try {
-                    serverChannel.close();
-                } catch (final IOException ignore) {
-                }
+                Closer.closeQuietly(serverChannel);
                 request.failed(ex);
             }
         }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3c39a387/httpcore5/src/main/java/org/apache/hc/core5/util/Closer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/Closer.java b/httpcore5/src/main/java/org/apache/hc/core5/util/Closer.java
new file mode 100644
index 0000000..6886688
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/util/Closer.java
@@ -0,0 +1,53 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.util;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+/**
+ * Closes resources.
+ */
+public class Closer {
+
+    /**
+     * Closes the given closeable quietly even in the event of an exception.
+     *
+     * @param closeable
+     *            what to close.
+     */
+    public static void closeQuietly(final Closeable closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (final IOException e) {
+                // Quietly ignore
+            }
+        }
+    }
+}


[3/8] httpcomponents-core git commit: No need to nest else clauses. Replace some if/else with a ternary return. Remove unnecessary semicolons. Remove unnecessary cast. Remove unnecessary @SuppressWarnings. Access static methods directly. Remove exception

Posted by ol...@apache.org.
No need to nest else clauses. Replace some if/else with a ternary
return. Remove unnecessary semicolons. Remove unnecessary cast. Remove
unnecessary @SuppressWarnings. Access static methods directly. Remove
exception not thrown from method signatures.


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/27ee7a10
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/27ee7a10
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/27ee7a10

Branch: refs/heads/api_javadocs
Commit: 27ee7a105b71b1b3a56412bedddca9bd17403b6e
Parents: f434e59
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 07:57:13 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sat Aug 4 21:45:07 2018 +0200

----------------------------------------------------------------------
 .../hc/core5/http2/H2ConnectionException.java   |  2 +-
 .../hc/core5/http2/H2CorruptFrameException.java |  2 +-
 .../java/org/apache/hc/core5/http2/H2Error.java |  2 +-
 .../hc/core5/http2/H2StreamResetException.java  |  2 +-
 .../hc/core5/http2/HttpVersionPolicy.java       |  2 +-
 .../apache/hc/core5/http2/config/H2Param.java   |  2 +-
 .../apache/hc/core5/http2/config/H2Setting.java |  2 +-
 .../hc/core5/http2/frame/FrameConsts.java       |  2 +-
 .../apache/hc/core5/http2/frame/FrameFlag.java  |  2 +-
 .../apache/hc/core5/http2/frame/FrameType.java  |  2 +-
 .../apache/hc/core5/http2/frame/RawFrame.java   |  6 +-
 .../apache/hc/core5/http2/hpack/FifoBuffer.java |  6 +-
 .../hc/core5/http2/hpack/FifoLinkedList.java    |  5 +-
 .../hc/core5/http2/hpack/HPackDecoder.java      | 30 ++++-----
 .../hc/core5/http2/hpack/HPackEncoder.java      | 31 +++++----
 .../hc/core5/http2/hpack/HPackException.java    |  2 +-
 .../core5/http2/hpack/InboundDynamicTable.java  |  8 +--
 .../core5/http2/hpack/OutboundDynamicTable.java |  8 +--
 .../hc/core5/http2/impl/Http2Processors.java    |  2 +-
 .../nio/AbstractHttp2StreamMultiplexer.java     |  3 +-
 .../impl/nio/ClientHttp2StreamMultiplexer.java  |  3 +-
 .../impl/nio/ServerHttpProtocolNegotiator.java  |  3 +-
 .../nio/bootstrap/CancellableExecution.java     |  5 +-
 .../DefaultAsyncPushConsumerFactory.java        |  6 +-
 .../hc/core5/http2/WritableByteChannelMock.java |  8 +--
 .../http2/frame/TestDefaultFrameFactory.java    |  2 +-
 .../hc/core5/http2/frame/TestFrameFlag.java     |  2 +-
 .../hc/core5/http2/frame/TestH2Settings.java    |  2 +-
 .../impl/nio/entity/TestSharedInputBuffer.java  |  3 +-
 .../testing/classic/ClassicTestServer.java      |  6 +-
 .../framework/ClassicTestClientAdapter.java     |  4 +-
 .../testing/framework/ClientPOJOAdapter.java    |  2 +-
 .../testing/framework/ClientTestingAdapter.java |  4 +-
 .../core5/testing/framework/FrameworkTest.java  | 10 +--
 .../testing/framework/TestingFramework.java     | 19 +++---
 .../TestingFrameworkRequestHandler.java         |  4 +-
 .../TestClassicTestClientTestingAdapter.java    | 36 +++++------
 .../framework/TestClientPOJOAdapter.java        |  4 +-
 .../testing/framework/TestFrameworkTest.java    |  8 +--
 .../testing/framework/TestTestingFramework.java | 67 ++++++++++----------
 .../http/examples/AsyncServerFilterExample.java | 45 +++++++------
 .../hc/core5/concurrent/ComplexCancellable.java |  5 +-
 .../org/apache/hc/core5/http/ContentType.java   |  2 +-
 .../hc/core5/http/config/NamedElementChain.java | 24 ++-----
 .../hc/core5/http/impl/HttpProcessors.java      |  2 +-
 .../http/impl/bootstrap/HttpRequester.java      |  3 +-
 .../hc/core5/http/impl/io/HttpService.java      | 23 ++++---
 .../hc/core5/http/impl/io/SocketHolder.java     | 24 +++----
 .../impl/nio/AbstractHttp1StreamDuplexer.java   | 19 +++---
 .../impl/nio/ClientHttp1StreamDuplexer.java     |  3 +-
 .../hc/core5/http/message/MessageSupport.java   |  7 +-
 .../support/AbstractAsyncServerAuthFilter.java  | 64 +++++++++----------
 ...ServerFilterChainExchangeHandlerFactory.java |  6 +-
 .../BasicAsyncServerExpectationDecorator.java   | 12 +---
 ...aultAsyncResponseExchangeHandlerFactory.java | 17 +++--
 .../nio/support/TerminalAsyncServerFilter.java  |  5 +-
 .../main/java/org/apache/hc/core5/net/Host.java |  6 +-
 .../org/apache/hc/core5/net/URIBuilder.java     |  7 +-
 .../org/apache/hc/core5/reactor/IOWorkers.java  |  8 +--
 .../hc/core5/reactor/InternalDataChannel.java   |  6 +-
 .../apache/hc/core5/ssl/ReflectionSupport.java  |  1 -
 .../hc/core5/http/WritableByteChannelMock.java  |  8 +--
 .../http/impl/io/TestBHttpConnectionBase.java   | 23 +++----
 .../http/impl/io/TestHttpRequestExecutor.java   | 13 ++--
 .../hc/core5/http/impl/io/TestHttpService.java  | 13 ++--
 .../http/impl/io/TestSessionInOutBuffers.java   |  9 +--
 .../impl/io/TimeoutByteArrayInputStream.java    |  8 +--
 .../http/impl/nio/TestSessionInOutBuffers.java  |  7 +-
 .../core5/http/message/TestBasicLineParser.java |  2 +-
 .../TestAbstractBinAsyncEntityConsumer.java     |  2 +-
 .../TestAbstractBinAsyncEntityProducer.java     |  2 +-
 .../TestAbstractCharAsyncEntityConsumer.java    |  2 +-
 .../TestAbstractCharAsyncEntityProducer.java    |  2 +-
 .../apache/hc/core5/pool/TestLaxConnPool.java   |  9 +--
 .../hc/core5/pool/TestStrictConnPool.java       | 11 ++--
 .../reactor/TestAbstractIOSessionPool.java      | 66 +++++++++----------
 .../hc/core5/ssl/TestSSLContextBuilder.java     |  9 +--
 77 files changed, 354 insertions(+), 440 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2ConnectionException.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2ConnectionException.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2ConnectionException.java
index c77dae4..66e2c1c 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2ConnectionException.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2ConnectionException.java
@@ -51,4 +51,4 @@ public class H2ConnectionException extends IOException {
         return code;
     }
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2CorruptFrameException.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2CorruptFrameException.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2CorruptFrameException.java
index 2fb1c91..275a9cb 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2CorruptFrameException.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2CorruptFrameException.java
@@ -34,4 +34,4 @@ public class H2CorruptFrameException extends IOException {
         super(message);
     }
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2Error.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2Error.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2Error.java
index 130d5e2..6787c48 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2Error.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2Error.java
@@ -153,4 +153,4 @@ public enum H2Error {
         return MAP_BY_CODE.get(code);
     }
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2StreamResetException.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2StreamResetException.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2StreamResetException.java
index 3ee9101..7c497c2 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2StreamResetException.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/H2StreamResetException.java
@@ -51,4 +51,4 @@ public class H2StreamResetException extends IOException {
         return code;
     }
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/HttpVersionPolicy.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/HttpVersionPolicy.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/HttpVersionPolicy.java
index 237c864..867c619 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/HttpVersionPolicy.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/HttpVersionPolicy.java
@@ -30,4 +30,4 @@ public enum HttpVersionPolicy {
 
     FORCE_HTTP_1, FORCE_HTTP_2, NEGOTIATE
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Param.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Param.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Param.java
index 668e9eb..cc7294b 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Param.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Param.java
@@ -66,4 +66,4 @@ public enum H2Param {
         return LOOKUP_TABLE[code - 1].name();
     }
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Setting.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Setting.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Setting.java
index a29242e..a57c8da 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Setting.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/config/H2Setting.java
@@ -53,4 +53,4 @@ public final class H2Setting {
         final StringBuilder sb = new StringBuilder().append(param).append(": ").append(value);
         return sb.toString();
     }
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameConsts.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameConsts.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameConsts.java
index 71d2207..cd47ee2 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameConsts.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameConsts.java
@@ -37,4 +37,4 @@ public final class FrameConsts {
     public final static int MIN_FRAME_SIZE = 16384;    // 2 ^ 14
     public final static int MAX_FRAME_SIZE = 16777215; // 2 ^ 24 - 1;
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFlag.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFlag.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFlag.java
index 763aefb..eed6d9e 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFlag.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFlag.java
@@ -52,4 +52,4 @@ public enum FrameFlag {
         return value;
     }
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameType.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameType.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameType.java
index 235d851..bc7f9d9 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameType.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameType.java
@@ -70,4 +70,4 @@ public enum FrameType {
         return LOOKUP_TABLE[value].name();
     }
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/RawFrame.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/RawFrame.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/RawFrame.java
index 8cf9455..d043b8c 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/RawFrame.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/RawFrame.java
@@ -65,12 +65,10 @@ public final class RawFrame extends Frame<ByteBuffer> {
                 }
                 dup.limit(dup.limit() - padding);
                 return dup;
-            } else {
-                return payload.duplicate();
             }
-        } else {
-            return null;
+            return payload.duplicate();
         }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/FifoBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/FifoBuffer.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/FifoBuffer.java
index 0c0a183..73a03ec 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/FifoBuffer.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/FifoBuffer.java
@@ -81,11 +81,7 @@ final class FifoBuffer {
     }
 
     public HPackHeader getFirst() {
-        if (head > 0) {
-            return array[head - 1];
-        } else {
-            return array[array.length - 1];
-        }
+        return array[head > 0 ? head - 1 : array.length - 1];
     }
 
     public HPackHeader getLast() {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/FifoLinkedList.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/FifoLinkedList.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/FifoLinkedList.java
index 9813ac3..a9b3ee9 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/FifoLinkedList.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/FifoLinkedList.java
@@ -101,10 +101,9 @@ final class FifoLinkedList {
             last.seqNum = 0;
             length--;
             return last;
-        } else {
-            master.seqNum = 0;
-            return null;
         }
+        master.seqNum = 0;
+        return null;
     }
 
     public void clear() {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackDecoder.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackDecoder.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackDecoder.java
index 8fad602..bc460f4 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackDecoder.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackDecoder.java
@@ -96,23 +96,22 @@ public final class HPackDecoder {
         int value = readByte(src) & nbits;
         if (value < nbits) {
             return value;
-        } else {
-            int m = 0;
-            while (m < 32) {
-                final int b = readByte(src);
-                if ((b & 0x80) != 0) {
-                    value += (b & 0x7f) << m;
-                    m += 7;
-                } else {
-                    if (m == 28 && (b & 0xf8) != 0) {
-                        break;
-                    }
-                    value += b << m;
-                    return value;
+        }
+        int m = 0;
+        while (m < 32) {
+            final int b = readByte(src);
+            if ((b & 0x80) != 0) {
+                value += (b & 0x7f) << m;
+                m += 7;
+            } else {
+                if (m == 28 && (b & 0xf8) != 0) {
+                    break;
                 }
+                value += b << m;
+                return value;
             }
-            throw new HPackException(MAX_LIMIT_EXCEEDED);
         }
+        throw new HPackException(MAX_LIMIT_EXCEEDED);
     }
 
     static void decodePlainString(final ByteArrayBuffer buffer, final ByteBuffer src) throws HPackException {
@@ -287,9 +286,8 @@ public final class HPackDecoder {
             final Header header = decodeHeader(src);
             if (header == null) {
                 break;
-            } else {
-                list.add(header);
             }
+            list.add(header);
         }
         return list;
     }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackEncoder.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackEncoder.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackEncoder.java
index de5176d..8d46253 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackEncoder.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackEncoder.java
@@ -163,29 +163,28 @@ public final class HPackEncoder {
                 dst.ensureCapacity(len + 8);
                 encodeInt(dst, 7, len, 0x0);
                 for (int i = 0; i < len; i++) {
-                    dst.append((int) charSequence.charAt(off + i));
+                    dst.append(charSequence.charAt(off + i));
                 }
             }
             return len;
-        } else {
-            final CharBuffer in = CharBuffer.wrap(charSequence, off, len);
-            while (in.hasRemaining()) {
-                ensureCapacity((int) (in.remaining() * this.charsetEncoder.averageBytesPerChar()) + 8);
-                final CoderResult result = this.charsetEncoder.encode(in, this.tmpBuf, true);
-                if (result.isError()) {
-                    result.throwException();
-                }
-            }
-            ensureCapacity(8);
-            final CoderResult result = this.charsetEncoder.flush(this.tmpBuf);
+        }
+        final CharBuffer in = CharBuffer.wrap(charSequence, off, len);
+        while (in.hasRemaining()) {
+            ensureCapacity((int) (in.remaining() * this.charsetEncoder.averageBytesPerChar()) + 8);
+            final CoderResult result = this.charsetEncoder.encode(in, this.tmpBuf, true);
             if (result.isError()) {
                 result.throwException();
             }
-            this.tmpBuf.flip();
-            final int binaryLen = this.tmpBuf.remaining();
-            encodeString(dst, this.tmpBuf, huffman);
-            return binaryLen;
         }
+        ensureCapacity(8);
+        final CoderResult result = this.charsetEncoder.flush(this.tmpBuf);
+        if (result.isError()) {
+            result.throwException();
+        }
+        this.tmpBuf.flip();
+        final int binaryLen = this.tmpBuf.remaining();
+        encodeString(dst, this.tmpBuf, huffman);
+        return binaryLen;
     }
 
     int encodeString(final ByteArrayBuffer dst, final String s, final boolean huffman) throws CharacterCodingException {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackException.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackException.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackException.java
index 55ca547..224d6d6 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackException.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/HPackException.java
@@ -38,4 +38,4 @@ public class HPackException extends HttpException {
         super(message, cause);
     }
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/InboundDynamicTable.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/InboundDynamicTable.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/InboundDynamicTable.java
index bd0f528..d04c9c5 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/InboundDynamicTable.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/InboundDynamicTable.java
@@ -82,11 +82,9 @@ final class InboundDynamicTable {
         if (index < 1 || index > length()) {
             throw new IndexOutOfBoundsException();
         }
-        if (index <= staticTable.length()) {
-            return staticTable.get(index);
-        } else {
-            return headers.get(index - staticTable.length() - 1);
-        }
+        return index <= staticTable.length()
+                        ? staticTable.get(index)
+                        : headers.get(index - staticTable.length() - 1);
     }
 
     public void add(final HPackHeader header) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/OutboundDynamicTable.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/OutboundDynamicTable.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/OutboundDynamicTable.java
index cc709e8..a1c2e6a 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/OutboundDynamicTable.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/hpack/OutboundDynamicTable.java
@@ -89,11 +89,9 @@ final class OutboundDynamicTable {
         if (index < 1 || index > length()) {
             throw new IndexOutOfBoundsException();
         }
-        if (index <= staticTable.length()) {
-            return staticTable.get(index);
-        } else {
-            return headers.get(index - staticTable.length() - 1);
-        }
+        return index <= staticTable.length()
+                        ? staticTable.get(index)
+                        : headers.get(index - staticTable.length() - 1);
     }
 
     public void add(final HPackHeader header) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/Http2Processors.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/Http2Processors.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/Http2Processors.java
index 0f636b6..3468a7b 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/Http2Processors.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/Http2Processors.java
@@ -78,7 +78,7 @@ public final class Http2Processors {
                         new RequestUserAgent(!TextUtils.isBlank(agentInfo) ? agentInfo :
                                 VersionInfo.getSoftwareInfo(SOFTWARE, "org.apache.hc.core5", HttpProcessors.class)),
                         new RequestExpectContinue());
-    };
+    }
 
     public static HttpProcessor client(final String agentInfo) {
         return customClient(agentInfo).build();

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
index 56808e8..51a87d7 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
@@ -363,9 +363,8 @@ abstract class AbstractHttp2StreamMultiplexer implements Identifiable, HttpConne
             payload.position(payload.position() + chunk);
             ioSession.setEvent(SelectionKey.OP_WRITE);
             return chunk;
-        } else {
-            return 0;
         }
+        return 0;
     }
 
     private void updateInputCapacity(

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamMultiplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamMultiplexer.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamMultiplexer.java
index 6a46b96..fcc1337 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamMultiplexer.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttp2StreamMultiplexer.java
@@ -114,9 +114,8 @@ public class ClientHttp2StreamMultiplexer extends AbstractHttp2StreamMultiplexer
             return new ClientHttp2StreamHandler(channel, httpProcessor, connMetrics, exchangeHandler,
                     pushHandlerFactory != null ? pushHandlerFactory : this.pushHandlerFactory,
                     context);
-        } else {
-            throw new H2ConnectionException(H2Error.INTERNAL_ERROR, "Unexpected executable command");
         }
+        throw new H2ConnectionException(H2Error.INTERNAL_ERROR, "Unexpected executable command");
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
index 87891bd..e097e00 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
@@ -126,9 +126,8 @@ public class ServerHttpProtocolNegotiator implements HttpConnectionEventHandler
                     if (bytebuf.get() != PREFACE[i]) {
                         if (expectValidH2Preface) {
                             throw new HttpException("Unexpected HTTP/2 preface");
-                        } else {
-                            validH2Preface = false;
                         }
+                        validH2Preface = false;
                     }
                 }
                 if (validH2Preface) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/CancellableExecution.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/CancellableExecution.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/CancellableExecution.java
index e96a036..7257782 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/CancellableExecution.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/CancellableExecution.java
@@ -32,7 +32,7 @@ import java.util.concurrent.atomic.AtomicReference;
 import org.apache.hc.core5.concurrent.Cancellable;
 import org.apache.hc.core5.concurrent.CancellableDependency;
 
-final class CancellableExecution implements CancellableDependency, Cancellable {
+final class CancellableExecution implements CancellableDependency {
 
     private final AtomicBoolean cancelled;
     private final AtomicReference<Cancellable> dependencyRef;
@@ -66,9 +66,8 @@ final class CancellableExecution implements CancellableDependency, Cancellable {
                 dependency.cancel();
             }
             return true;
-        } else {
-            return false;
         }
+        return false;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/support/DefaultAsyncPushConsumerFactory.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/support/DefaultAsyncPushConsumerFactory.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/support/DefaultAsyncPushConsumerFactory.java
index 2e76c23..271040e 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/support/DefaultAsyncPushConsumerFactory.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/nio/support/DefaultAsyncPushConsumerFactory.java
@@ -51,11 +51,7 @@ public final class DefaultAsyncPushConsumerFactory implements HandlerFactory<Asy
     public AsyncPushConsumer create(final HttpRequest request, final HttpContext context) throws HttpException {
         try {
             final Supplier<AsyncPushConsumer> supplier = mapper.resolve(request, context);
-            if (supplier != null) {
-                return supplier.get();
-            } else {
-                return null;
-            }
+            return supplier != null ? supplier.get() : null;
         } catch (final MisdirectedRequestException ex) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/WritableByteChannelMock.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/WritableByteChannelMock.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/WritableByteChannelMock.java
index d4a45b8..54377f3 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/WritableByteChannelMock.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/WritableByteChannelMock.java
@@ -78,13 +78,11 @@ public class WritableByteChannelMock implements WritableByteChannel {
                 src.limit(limit);
                 this.capacityUsed += chunk;
                 return chunk;
-            } else {
-                return 0;
             }
-        } else {
-            this.buf.put(src);
-            return len;
+            return 0;
         }
+        this.buf.put(src);
+        return len;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java
index 4a7bd4b..05946bb 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestDefaultFrameFactory.java
@@ -99,4 +99,4 @@ public class TestDefaultFrameFactory {
         Assert.assertEquals("Oopsie", new String(tmp, StandardCharsets.US_ASCII));
     }
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java
index 53912e1..1a52618 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestFrameFlag.java
@@ -38,4 +38,4 @@ public class TestFrameFlag {
         Assert.assertEquals(0x01 | 0x08 | 0x20, flags);
     }
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestH2Settings.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestH2Settings.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestH2Settings.java
index 6f73e08..5090b1a 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestH2Settings.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/frame/TestH2Settings.java
@@ -55,4 +55,4 @@ public class TestH2Settings {
         Assert.assertEquals("INITIAL_WINDOW_SIZE: 1024", setting2.toString());
     }
 
-};
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/entity/TestSharedInputBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/entity/TestSharedInputBuffer.java b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/entity/TestSharedInputBuffer.java
index 158efdb..7c259c7 100644
--- a/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/entity/TestSharedInputBuffer.java
+++ b/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/impl/nio/entity/TestSharedInputBuffer.java
@@ -41,6 +41,7 @@ import org.apache.hc.core5.http.nio.entity.SharedInputBuffer;
 import org.apache.hc.core5.http.nio.CapacityChannel;
 import org.junit.Assert;
 import org.junit.Test;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
 
 public class TestSharedInputBuffer {
@@ -200,7 +201,7 @@ public class TestSharedInputBuffer {
 
         Assert.assertEquals(Boolean.TRUE, task1.get(5, TimeUnit.SECONDS));
         Assert.assertEquals("12345678901234567890123456789012345678901234567890", task2.get(5, TimeUnit.SECONDS));
-        Mockito.verify(capacityChannel, Mockito.atLeast(1)).update(Mockito.anyInt());
+        Mockito.verify(capacityChannel, Mockito.atLeast(1)).update(ArgumentMatchers.anyInt());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
index f194e08..75398a6 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
@@ -88,18 +88,16 @@ public class ClassicTestServer {
         final HttpServer server = this.serverRef.get();
         if (server != null) {
             return server.getLocalPort();
-        } else {
-            throw new IllegalStateException("Server not running");
         }
+        throw new IllegalStateException("Server not running");
     }
 
     public InetAddress getInetAddress() {
         final HttpServer server = this.serverRef.get();
         if (server != null) {
             return server.getInetAddress();
-        } else {
-            throw new IllegalStateException("Server not running");
         }
+        throw new IllegalStateException("Server not running");
     }
 
     public void start(final HttpProcessor httpProcessor, final Decorator<HttpServerRequestHandler> handlerDecorator) throws IOException {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClassicTestClientAdapter.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClassicTestClientAdapter.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClassicTestClientAdapter.java
index e2cf0a7..660d46c 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClassicTestClientAdapter.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClassicTestClientAdapter.java
@@ -147,11 +147,11 @@ public class ClassicTestClientAdapter extends ClientPOJOAdapter {
             final String contentType = entity == null ? null : entity.getContentType();
 
             // prepare the returned information
-            final Map<String, Object> ret = new HashMap<String, Object>();
+            final Map<String, Object> ret = new HashMap<>();
             ret.put(STATUS, response.getCode());
 
             // convert the headers to a Map
-            final Map<String, Object> headerMap = new HashMap<String, Object>();
+            final Map<String, Object> headerMap = new HashMap<>();
             for (final Header header : response.getAllHeaders()) {
                 headerMap.put(header.getName(), header.getValue());
             }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClientPOJOAdapter.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClientPOJOAdapter.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClientPOJOAdapter.java
index 1c17128..946ba6c 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClientPOJOAdapter.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClientPOJOAdapter.java
@@ -151,5 +151,5 @@ public abstract class ClientPOJOAdapter {
      */
     public Map<String, Object> modifyRequest(final Map<String, Object> request) {
         return request;
-    };
+    }
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClientTestingAdapter.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClientTestingAdapter.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClientTestingAdapter.java
index 33ba080..ee2282e 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClientTestingAdapter.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClientTestingAdapter.java
@@ -111,14 +111,14 @@ public class ClientTestingAdapter {
      */
     public boolean isRequestSupported(final Map<String, Object> request) {
         return (adapter == null) || adapter.checkRequestSupport(request) == null;
-    };
+    }
 
     /**
      * See the documentation for the same method in {@link ClientPOJOAdapter}.
      */
     public Map<String, Object> modifyRequest(final Map<String, Object> request) {
        return (adapter == null) ? request : adapter.modifyRequest(request);
-    };
+    }
 
     /**
      * Generally a test's response expectations should not need to be modified, but

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/FrameworkTest.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/FrameworkTest.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/FrameworkTest.java
index 6e61583..326a8f1 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/FrameworkTest.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/FrameworkTest.java
@@ -87,12 +87,12 @@ public class FrameworkTest {
      */
     public Map<String, Object> initRequest() throws TestingFrameworkException {
         // initialize to some helpful defaults
-        final Map<String, Object> ret = new HashMap<String, Object>();
+        final Map<String, Object> ret = new HashMap<>();
         ret.put(PATH, TestingFramework.DEFAULT_REQUEST_PATH);
         ret.put(BODY, TestingFramework.DEFAULT_REQUEST_BODY);
         ret.put(CONTENT_TYPE, TestingFramework.DEFAULT_REQUEST_CONTENT_TYPE);
-        ret.put(QUERY, new HashMap<String, String>(TestingFramework.DEFAULT_REQUEST_QUERY));
-        ret.put(HEADERS, new HashMap<String, String>(TestingFramework.DEFAULT_REQUEST_HEADERS));
+        ret.put(QUERY, new HashMap<>(TestingFramework.DEFAULT_REQUEST_QUERY));
+        ret.put(HEADERS, new HashMap<>(TestingFramework.DEFAULT_REQUEST_HEADERS));
         ret.put(PROTOCOL_VERSION, TestingFramework.DEFAULT_REQUEST_PROTOCOL_VERSION);
 
         // GET is the default method.
@@ -138,11 +138,11 @@ public class FrameworkTest {
             response.put(STATUS, 200);
         }
 
-        final Map<String, Object> responseExpectations = new HashMap<String, Object>();
+        final Map<String, Object> responseExpectations = new HashMap<>();
         // initialize to some helpful defaults
         responseExpectations.put(BODY, TestingFramework.DEFAULT_RESPONSE_BODY);
         responseExpectations.put(CONTENT_TYPE, TestingFramework.DEFAULT_RESPONSE_CONTENT_TYPE);
-        responseExpectations.put(HEADERS, new HashMap<String, String>(TestingFramework.DEFAULT_RESPONSE_HEADERS));
+        responseExpectations.put(HEADERS, new HashMap<>(TestingFramework.DEFAULT_RESPONSE_HEADERS));
 
         // Now override any defaults with what is requested.
         responseExpectations.putAll(response);

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFramework.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFramework.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFramework.java
index 371ea7d..36761d3 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFramework.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFramework.java
@@ -56,6 +56,7 @@ import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.apache.hc.core5.io.CloseMode;
 
 public class TestingFramework {
+
     /**
      * Use the ALL_METHODS list to conveniently cycle through all HTTP methods.
      */
@@ -120,17 +121,17 @@ public class TestingFramework {
     public static final Map<String, String> DEFAULT_RESPONSE_HEADERS;
 
     static {
-        final Map<String, String> request = new HashMap<String, String>();
+        final Map<String, String> request = new HashMap<>();
         request.put("p1", "this");
         request.put("p2", "that");
         DEFAULT_REQUEST_QUERY = Collections.unmodifiableMap(request);
 
-        Map<String, String> headers = new HashMap<String, String>();
+        Map<String, String> headers = new HashMap<>();
         headers.put("header1", "stuff");
         headers.put("header2", "more stuff");
         DEFAULT_REQUEST_HEADERS = Collections.unmodifiableMap(headers);
 
-        headers = new HashMap<String, String>();
+        headers = new HashMap<>();
         headers.put("header3", "header_three");
         headers.put("header4", "header_four");
         DEFAULT_RESPONSE_HEADERS = Collections.unmodifiableMap(headers);
@@ -138,7 +139,7 @@ public class TestingFramework {
 
     private ClientTestingAdapter adapter;
     private TestingFrameworkRequestHandler requestHandler = new TestingFrameworkRequestHandler();
-    private List<FrameworkTest> tests = new ArrayList<FrameworkTest>();
+    private List<FrameworkTest> tests = new ArrayList<>();
 
     private HttpServer server;
     private int port;
@@ -156,13 +157,13 @@ public class TestingFramework {
         for (final String method : ALL_METHODS) {
             final List<Integer> statusList = Arrays.asList(200, 201);
             for (final Integer status : statusList) {
-                final Map<String, Object> request = new HashMap<String, Object>();
+                final Map<String, Object> request = new HashMap<>();
                 request.put(METHOD, method);
 
-                final Map<String, Object> response = new HashMap<String, Object>();
+                final Map<String, Object> response = new HashMap<>();
                 response.put(STATUS, status);
 
-                final Map<String, Object> test = new HashMap<String, Object>();
+                final Map<String, Object> test = new HashMap<>();
                 test.put(REQUEST, request);
                 test.put(RESPONSE, response);
 
@@ -372,7 +373,7 @@ public class TestingFramework {
         if (expectedHeaders == null) {
             return;
         }
-        for (final Map.Entry<String, String> expectedHeader : ((Map<String, String>) expectedHeaders).entrySet()) {
+        for (final Map.Entry<String, String> expectedHeader : expectedHeaders.entrySet()) {
             final String expectedHeaderName = expectedHeader.getKey();
             if (! actualHeaders.containsKey(expectedHeaderName)) {
                 throw new TestingFrameworkException("Expected header not found: name=" + expectedHeaderName);
@@ -402,7 +403,7 @@ public class TestingFramework {
      * Deletes all tests.
      */
     public void deleteTests() {
-        tests = new ArrayList<FrameworkTest>();
+        tests = new ArrayList<>();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFrameworkRequestHandler.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFrameworkRequestHandler.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFrameworkRequestHandler.java
index 9b460f6..2ab78eb 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFrameworkRequestHandler.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFrameworkRequestHandler.java
@@ -138,7 +138,7 @@ public class TestingFrameworkRequestHandler implements HttpRequestHandler {
             if (expectedQuery != null) {
                 final URI uri = request.getUri();
                 final List<NameValuePair> actualParams = URLEncodedUtils.parse(uri, StandardCharsets.UTF_8);
-                final Map<String, String> actualParamsMap = new HashMap<String, String>();
+                final Map<String, String> actualParamsMap = new HashMap<>();
                 for (final NameValuePair actualParam : actualParams) {
                     actualParamsMap.put(actualParam.getName(), actualParam.getValue());
                 }
@@ -162,7 +162,7 @@ public class TestingFrameworkRequestHandler implements HttpRequestHandler {
             @SuppressWarnings("unchecked")
             final Map<String, String> expectedHeaders = (Map<String, String>) requestExpectations.get(HEADERS);
             if (expectedHeaders != null) {
-                final Map<String, String> actualHeadersMap = new HashMap<String, String>();
+                final Map<String, String> actualHeadersMap = new HashMap<>();
                 final Header[] actualHeaders = request.getAllHeaders();
                 for (final Header header : actualHeaders) {
                     actualHeadersMap.put(header.getName(), header.getValue());

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClassicTestClientTestingAdapter.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClassicTestClientTestingAdapter.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClassicTestClientTestingAdapter.java
index 0a22886..2df7f0c 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClassicTestClientTestingAdapter.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClassicTestClientTestingAdapter.java
@@ -77,9 +77,9 @@ public class TestClassicTestClientTestingAdapter {
         final ClientTestingAdapter adapter = new ClassicTestClientTestingAdapter();
 
         final String defaultURI = null;
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
-        final Map<String, Object> responseExpectations = new HashMap<String, Object>();
+        final Map<String, Object> responseExpectations = new HashMap<>();
 
         try {
             adapter.execute(defaultURI, request, requestHandler, responseExpectations);
@@ -96,7 +96,7 @@ public class TestClassicTestClientTestingAdapter {
         final String defaultURI = "";
         final Map<String, Object> request = null;
         final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
-        final Map<String, Object> responseExpectations = new HashMap<String, Object>();
+        final Map<String, Object> responseExpectations = new HashMap<>();
 
         try {
             adapter.execute(defaultURI, request, requestHandler, responseExpectations);
@@ -111,9 +111,9 @@ public class TestClassicTestClientTestingAdapter {
         final ClientTestingAdapter adapter = new ClassicTestClientTestingAdapter();
 
         final String defaultURI = "";
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         final TestingFrameworkRequestHandler requestHandler = null;
-        final Map<String, Object> responseExpectations = new HashMap<String, Object>();
+        final Map<String, Object> responseExpectations = new HashMap<>();
 
         try {
             adapter.execute(defaultURI, request, requestHandler, responseExpectations);
@@ -128,7 +128,7 @@ public class TestClassicTestClientTestingAdapter {
         final ClientTestingAdapter adapter = new ClassicTestClientTestingAdapter();
 
         final String defaultURI = "";
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
         final Map<String, Object> responseExpectations = null;
 
@@ -145,9 +145,9 @@ public class TestClassicTestClientTestingAdapter {
         final ClientTestingAdapter adapter = new ClassicTestClientTestingAdapter();
 
         final String defaultURI = "";
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
-        final Map<String, Object> responseExpectations = new HashMap<String, Object>();
+        final Map<String, Object> responseExpectations = new HashMap<>();
 
         try {
             adapter.execute(defaultURI, request, requestHandler, responseExpectations);
@@ -163,11 +163,11 @@ public class TestClassicTestClientTestingAdapter {
 
         final String defaultURI = "";
 
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         request.put(PATH, ECHO_PATH);
 
         final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
-        final Map<String, Object> responseExpectations = new HashMap<String, Object>();
+        final Map<String, Object> responseExpectations = new HashMap<>();
 
         try {
             adapter.execute(defaultURI, request, requestHandler, responseExpectations);
@@ -183,12 +183,12 @@ public class TestClassicTestClientTestingAdapter {
 
         final String defaultURI = "";
 
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         request.put(PATH, ECHO_PATH);
         request.put(METHOD, "JUNK");
 
         final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
-        final Map<String, Object> responseExpectations = new HashMap<String, Object>();
+        final Map<String, Object> responseExpectations = new HashMap<>();
 
         try {
             adapter.execute(defaultURI, request, requestHandler, responseExpectations);
@@ -210,13 +210,13 @@ public class TestClassicTestClientTestingAdapter {
         final HttpHost target = new HttpHost("localhost", this.server.getPort());
 
         final String defaultURI = target.toString();
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         request.put(PATH, ECHO_PATH);
         request.put(METHOD, "POST");
         final String body = "mybody";
         request.put(BODY, body);
 
-        final Map<String, Object> responseExpectations = new HashMap<String, Object>();
+        final Map<String, Object> responseExpectations = new HashMap<>();
 
         final TestingFrameworkRequestHandler requestHandler = Mockito.mock(TestingFrameworkRequestHandler.class);
         final Map<String, Object> response = adapter.execute(defaultURI, request, requestHandler, responseExpectations);
@@ -255,9 +255,9 @@ public class TestClassicTestClientTestingAdapter {
         this.server.start();
         final HttpHost target = new HttpHost("localhost", this.server.getPort());
         final String defaultURI = target.toString();
-        final Map<String, Object> responseExpectations = new HashMap<String, Object>();
+        final Map<String, Object> responseExpectations = new HashMap<>();
 
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         request.put(PATH, CUSTOM_PATH);
 
         for (final String method : TestingFramework.ALL_METHODS) {
@@ -271,7 +271,7 @@ public class TestClassicTestClientTestingAdapter {
     public void modifyRequest() {
         final ClientTestingAdapter adapter = new ClassicTestClientTestingAdapter();
 
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         final Map<String, Object> returnedRequest = adapter.modifyRequest(request);
 
         Assert.assertSame("Same request was not returned as expected.", request, returnedRequest);
@@ -281,7 +281,7 @@ public class TestClassicTestClientTestingAdapter {
     public void modifyResponseExpectations() {
         final ClientTestingAdapter adapter = new ClassicTestClientTestingAdapter();
 
-        final Map<String, Object> responseExpectations = new HashMap<String, Object>();
+        final Map<String, Object> responseExpectations = new HashMap<>();
         final Map<String, Object> returnedResponseExpectations = adapter.modifyResponseExpectations(null, responseExpectations);
 
         Assert.assertSame("Same response expectations were not returned as expected.", responseExpectations, returnedResponseExpectations);

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientPOJOAdapter.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientPOJOAdapter.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientPOJOAdapter.java
index 332d6ab..132e0ce 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientPOJOAdapter.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientPOJOAdapter.java
@@ -36,7 +36,7 @@ public class TestClientPOJOAdapter {
     @Test
     public void modifyRequest() throws Exception {
         final ClientPOJOAdapter adapter = new ClassicTestClientAdapter();
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         final Map<String, Object> request2 = adapter.modifyRequest(request);
 
         Assert.assertSame("request should have been returned", request, request2);
@@ -69,7 +69,7 @@ public class TestClientPOJOAdapter {
             @Override
             public String getClientName() {
                 return null;
-            };
+            }
         };
 
         try {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java
index 7b36152..57db424 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java
@@ -89,8 +89,8 @@ public class TestFrameworkTest {
 
     @Test
     public void changeStatus() throws Exception {
-        final Map<String, Object> testMap = new HashMap<String, Object>();
-        final Map<String, Object> response = new HashMap<String, Object>();
+        final Map<String, Object> testMap = new HashMap<>();
+        final Map<String, Object> response = new HashMap<>();
         testMap.put(RESPONSE, response);
         response.put(STATUS, 201);
 
@@ -102,8 +102,8 @@ public class TestFrameworkTest {
 
     @Test
     public void changeMethod() throws Exception {
-        final Map<String, Object> testMap = new HashMap<String, Object>();
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> testMap = new HashMap<>();
+        final Map<String, Object> request = new HashMap<>();
         testMap.put(REQUEST, request);
         request.put(METHOD, "POST");
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java
index fd720ee..c9b7980 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java
@@ -52,6 +52,7 @@ import org.hamcrest.Description;
 import org.hamcrest.Matcher;
 import org.junit.Assert;
 import org.junit.Test;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
 
 public class TestTestingFramework {
@@ -123,13 +124,12 @@ public class TestTestingFramework {
         }
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void goodAdapterWithConstructor() throws Exception {
         final ClientTestingAdapter adapter = Mockito.mock(ClientTestingAdapter.class);
 
         // Have isRequestSupported() return false so no test will run.
-        Mockito.when(adapter.isRequestSupported(Mockito.<String, Object>anyMap()))
+        Mockito.when(adapter.isRequestSupported(ArgumentMatchers.<String, Object>anyMap()))
                      .thenReturn(false);
 
         final TestingFramework framework = newWebServerTestingFramework(adapter);
@@ -140,10 +140,9 @@ public class TestTestingFramework {
         verifyCallMethodNeverCalled(adapter);
     }
 
-    @SuppressWarnings("unchecked")
     private void verifyCallMethodNeverCalled(final ClientTestingAdapter adapter) throws Exception {
-        Mockito.verify(adapter, Mockito.never()).execute(Mockito.anyString(), Mockito.<String, Object>anyMap(),
-                       Mockito.any(TestingFrameworkRequestHandler.class), Mockito.<String, Object>anyMap());
+        Mockito.verify(adapter, Mockito.never()).execute(ArgumentMatchers.anyString(), ArgumentMatchers.<String, Object>anyMap(),
+                       ArgumentMatchers.any(TestingFrameworkRequestHandler.class), ArgumentMatchers.<String, Object>anyMap());
     }
 
     private TestingFramework newFrameworkAndSetAdapter(final ClientTestingAdapter adapter)
@@ -196,7 +195,7 @@ public class TestTestingFramework {
                 Assert.assertEquals("The responseExpectations do not match the defaults",
                                     defaultResponseExpectations, responseExpectations);
 
-                final Map<String, Object> response = new HashMap<String, Object>();
+                final Map<String, Object> response = new HashMap<>();
                 response.put(STATUS, responseExpectations.get(STATUS));
                 response.put(BODY, responseExpectations.get(BODY));
                 response.put(CONTENT_TYPE, responseExpectations.get(CONTENT_TYPE));
@@ -247,7 +246,7 @@ public class TestTestingFramework {
                 Assert.assertEquals(200, responseExpectations.get(STATUS));
 
                 // return a different status than expected.
-                final Map<String, Object> response = new HashMap<String, Object>();
+                final Map<String, Object> response = new HashMap<>();
                 response.put(STATUS, 201);
                 return response;
             }
@@ -267,7 +266,7 @@ public class TestTestingFramework {
 
     private Map<String, Object> alreadyCheckedResponse() {
         // return an indication that the response has already been checked.
-        final Map<String, Object> response = new HashMap<String, Object>();
+        final Map<String, Object> response = new HashMap<>();
         response.put(STATUS, TestingFramework.ALREADY_CHECKED);
         response.put(BODY, TestingFramework.ALREADY_CHECKED);
         response.put(CONTENT_TYPE, TestingFramework.ALREADY_CHECKED);
@@ -308,7 +307,7 @@ public class TestTestingFramework {
 
                 Assert.assertEquals(TestingFramework.DEFAULT_RESPONSE_BODY, responseExpectations.get(BODY));
 
-                final Map<String, Object> response = new HashMap<String, Object>();
+                final Map<String, Object> response = new HashMap<>();
                 response.put(STATUS, TestingFramework.ALREADY_CHECKED);
 
                 // return a different body than expected.
@@ -341,7 +340,7 @@ public class TestTestingFramework {
 
                 Assert.assertEquals(TestingFramework.DEFAULT_RESPONSE_CONTENT_TYPE, responseExpectations.get(CONTENT_TYPE));
 
-                final Map<String, Object> response = new HashMap<String, Object>();
+                final Map<String, Object> response = new HashMap<>();
                 response.put(STATUS, TestingFramework.ALREADY_CHECKED);
                 response.put(HEADERS, TestingFramework.ALREADY_CHECKED);
 
@@ -372,7 +371,7 @@ public class TestTestingFramework {
         final Map<String, String> headersCopy = (Map<String, String>) TestingFramework.deepcopy(TestingFramework.DEFAULT_RESPONSE_HEADERS);
         Assert.assertEquals(TestingFramework.DEFAULT_RESPONSE_HEADERS, headersCopy);
 
-        final Map<String, Object> deepMap = new HashMap<String, Object>();
+        final Map<String, Object> deepMap = new HashMap<>();
         deepMap.put(HEADERS, TestingFramework.DEFAULT_RESPONSE_HEADERS);
 
         @SuppressWarnings("unchecked")
@@ -406,7 +405,7 @@ public class TestTestingFramework {
                 final String headerName = (String) headersCopy.keySet().toArray()[0];
                 headersCopy.remove(headerName);
 
-                final Map<String, Object> response = new HashMap<String, Object>();
+                final Map<String, Object> response = new HashMap<>();
                 response.put(STATUS, TestingFramework.ALREADY_CHECKED);
                 response.put(BODY, TestingFramework.ALREADY_CHECKED);
 
@@ -447,7 +446,7 @@ public class TestTestingFramework {
                 final String headerName = (String) headersCopy.keySet().toArray()[0];
                 headersCopy.put(headerName, headersCopy.get(headerName) + "junk");
 
-                final Map<String, Object> response = new HashMap<String, Object>();
+                final Map<String, Object> response = new HashMap<>();
                 response.put(STATUS, TestingFramework.ALREADY_CHECKED);
                 response.put(BODY, TestingFramework.ALREADY_CHECKED);
 
@@ -496,8 +495,8 @@ public class TestTestingFramework {
 
         final TestingFramework framework = newFrameworkAndSetAdapter(adapter);
 
-        final Map<String, Object> test = new HashMap<String, Object>();
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> test = new HashMap<>();
+        final Map<String, Object> request = new HashMap<>();
         test.put(REQUEST, request);
         request.put(NAME, "MyName");
 
@@ -531,8 +530,8 @@ public class TestTestingFramework {
 
         final TestingFramework framework = newFrameworkAndSetAdapter(adapter);
 
-        final Map<String, Object> test = new HashMap<String, Object>();
-        final Map<String, Object> response = new HashMap<String, Object>();
+        final Map<String, Object> test = new HashMap<>();
+        final Map<String, Object> response = new HashMap<>();
         test.put(RESPONSE, response);
         response.put(STATUS, 201);
 
@@ -559,8 +558,8 @@ public class TestTestingFramework {
 
         final TestingFramework framework = newFrameworkAndSetAdapter(adapter);
 
-        final Map<String, Object> test = new HashMap<String, Object>();
-        final Map<String, Object> response = new HashMap<String, Object>();
+        final Map<String, Object> test = new HashMap<>();
+        final Map<String, Object> response = new HashMap<>();
         test.put(RESPONSE, response);
         response.put(STATUS, 201);
 
@@ -828,7 +827,7 @@ public class TestTestingFramework {
 
                 // The next line is needed because we have to make a copy of the responseExpectations.
                 // It is an unmodifiable map.
-                final Map<String, Object> tempResponseExpectations = new HashMap<String, Object>(responseExpectations);
+                final Map<String, Object> tempResponseExpectations = new HashMap<>(responseExpectations);
                 tempResponseExpectations.put(STATUS, 201);
                 final Map<String, Object> response = super.execute(defaultURI, request, requestHandler, tempResponseExpectations);
                 Assert.assertEquals(200,  response.get(STATUS));
@@ -859,7 +858,7 @@ public class TestTestingFramework {
                 // make sure the modifyRequest method was called by seeing if the request was modified.
                 Assert.assertTrue("modifyRequest should have been called.", request.containsKey(UNLIKELY_ITEM));
 
-                final Map<String, Object> response = new HashMap<String, Object>();
+                final Map<String, Object> response = new HashMap<>();
                 response.put(STATUS, responseExpectations.get(STATUS));
                 response.put(BODY, responseExpectations.get(BODY));
                 response.put(CONTENT_TYPE, responseExpectations.get(CONTENT_TYPE));
@@ -901,7 +900,7 @@ public class TestTestingFramework {
                 // make sure the modifyRequest method was called by seeing if the request was modified.
                 Assert.assertTrue("modifyResponseExpectations should have been called.", responseExpectations.containsKey(UNLIKELY_ITEM));
 
-                final Map<String, Object> response = new HashMap<String, Object>();
+                final Map<String, Object> response = new HashMap<>();
                 response.put(STATUS, responseExpectations.get(STATUS));
                 response.put(BODY, responseExpectations.get(BODY));
                 response.put(CONTENT_TYPE, responseExpectations.get(CONTENT_TYPE));
@@ -960,7 +959,7 @@ public class TestTestingFramework {
 
     @Test
     public void defaultTestsWithMockedAdapter() throws Exception {
-        final Set<String> calledMethodSet = new HashSet<String>();
+        final Set<String> calledMethodSet = new HashSet<>();
 
         final ClientTestingAdapter adapter = new ClientTestingAdapter() {
             @Override
@@ -1023,20 +1022,20 @@ public class TestTestingFramework {
 //                              ],
 //          )
 
-        final Map<String, Object> test = new HashMap<String, Object>();
+        final Map<String, Object> test = new HashMap<>();
 
         // Add request.
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         test.put(REQUEST, request);
 
         request.put(PATH, "/stuff");
 
-        final Map<String, Object> queryMap = new HashMap<String, Object>();
+        final Map<String, Object> queryMap = new HashMap<>();
         request.put(QUERY, queryMap);
 
         queryMap.put("param", "something");
 
-        final Map<String, Object> requestHeadersMap = new HashMap<String, Object>();
+        final Map<String, Object> requestHeadersMap = new HashMap<>();
         request.put(HEADERS, requestHeadersMap);
 
         requestHeadersMap.put("header1", "stuff");
@@ -1046,12 +1045,12 @@ public class TestTestingFramework {
         request.put(BODY, "What is the meaning of life?");
 
         // Response
-        final Map<String, Object> response = new HashMap<String, Object>();
+        final Map<String, Object> response = new HashMap<>();
         test.put(RESPONSE, response);
 
         response.put(STATUS, 201);
 
-        final Map<String, Object> responseHeadersMap = new HashMap<String, Object>();
+        final Map<String, Object> responseHeadersMap = new HashMap<>();
         response.put(HEADERS, responseHeadersMap);
 
         responseHeadersMap.put("header3", "header_stuff");
@@ -1092,10 +1091,10 @@ public class TestTestingFramework {
 //                              ],
 //          )
 
-        final Map<String, Object> test = new HashMap<String, Object>();
+        final Map<String, Object> test = new HashMap<>();
 
         // Add request.
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         test.put(REQUEST, request);
 
         request.put(PATH, null);
@@ -1109,7 +1108,7 @@ public class TestTestingFramework {
         request.put(BODY, null);
 
         // Response
-        final Map<String, Object> response = new HashMap<String, Object>();
+        final Map<String, Object> response = new HashMap<>();
         test.put(RESPONSE, response);
 
         response.put(STATUS, null);
@@ -1150,10 +1149,10 @@ public class TestTestingFramework {
 
         final TestingFramework framework = newFrameworkAndSetAdapter(adapter);
 
-        final Map<String, Object> test = new HashMap<String, Object>();
+        final Map<String, Object> test = new HashMap<>();
 
         // Add request.
-        final Map<String, Object> request = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<>();
         test.put(REQUEST, request);
 
         request.put(PATH, "/stuff?stuffParm=stuff&stuffParm2=stuff2");

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncServerFilterExample.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncServerFilterExample.java b/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncServerFilterExample.java
index 6168b07..a23159f 100644
--- a/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncServerFilterExample.java
+++ b/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncServerFilterExample.java
@@ -126,30 +126,29 @@ public class AsyncServerFilterExample {
                                     new BasicHttpResponse(HttpStatus.SC_OK),
                                     new BasicAsyncEntityProducer("Welcome", ContentType.TEXT_PLAIN));
                             return null;
-                        } else {
-                            return chain.proceed(request, entityDetails, context, new AsyncFilterChain.ResponseTrigger() {
-
-                                @Override
-                                public void sendInformation(
-                                        final HttpResponse response) throws HttpException, IOException {
-                                    responseTrigger.sendInformation(response);
-                                }
-
-                                @Override
-                                public void submitResponse(
-                                        final HttpResponse response, final AsyncEntityProducer entityProducer) throws HttpException, IOException {
-                                    response.addHeader("X-Filter", "My-Filter");
-                                    responseTrigger.submitResponse(response, entityProducer);
-                                }
-
-                                @Override
-                                public void pushPromise(
-                                        final HttpRequest promise, final AsyncPushProducer responseProducer) throws HttpException, IOException {
-                                    responseTrigger.pushPromise(promise, responseProducer);
-                                }
-
-                            });
                         }
+                        return chain.proceed(request, entityDetails, context, new AsyncFilterChain.ResponseTrigger() {
+
+                            @Override
+                            public void sendInformation(
+                                    final HttpResponse response) throws HttpException, IOException {
+                                responseTrigger.sendInformation(response);
+                            }
+
+                            @Override
+                            public void submitResponse(
+                                    final HttpResponse response, final AsyncEntityProducer entityProducer) throws HttpException, IOException {
+                                response.addHeader("X-Filter", "My-Filter");
+                                responseTrigger.submitResponse(response, entityProducer);
+                            }
+
+                            @Override
+                            public void pushPromise(
+                                    final HttpRequest promise, final AsyncPushProducer responseProducer) throws HttpException, IOException {
+                                responseTrigger.pushPromise(promise, responseProducer);
+                            }
+
+                        });
                     }
 
                 })

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexCancellable.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexCancellable.java b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexCancellable.java
index 83b61d0..d2930b9 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexCancellable.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexCancellable.java
@@ -37,7 +37,7 @@ import org.apache.hc.core5.util.Args;
  *
  * @since 5.0
  */
-public final class ComplexCancellable implements Cancellable, CancellableDependency {
+public final class ComplexCancellable implements CancellableDependency {
 
     private final AtomicReference<Cancellable> dependencyRef;
     private final AtomicBoolean cancelled;
@@ -70,9 +70,8 @@ public final class ComplexCancellable implements Cancellable, CancellableDepende
                 dependency.cancel();
             }
             return true;
-        } else {
-            return false;
         }
+        return false;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java b/httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java
index 4e48d8d..c67e15a 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java
@@ -125,7 +125,7 @@ public final class ContentType implements Serializable {
             TEXT_HTML,
             TEXT_PLAIN,
             TEXT_XML };
-        final HashMap<String, ContentType> map = new HashMap<String, ContentType>();
+        final HashMap<String, ContentType> map = new HashMap<>();
         for (final ContentType contentType: contentTypes) {
             map.put(contentType.getMimeType(), contentType);
         }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/config/NamedElementChain.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/config/NamedElementChain.java b/httpcore5/src/main/java/org/apache/hc/core5/http/config/NamedElementChain.java
index 7759cbc..77f882a 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/config/NamedElementChain.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/config/NamedElementChain.java
@@ -49,19 +49,11 @@ public class NamedElementChain<E> {
     }
 
     public Node getFirst() {
-        if (master.next != master) {
-            return master.next;
-        } else {
-            return null;
-        }
+        return master.next != master ? master.next : null;
     }
 
     public Node getLast() {
-        if (master.previous != master) {
-            return master.previous;
-        } else {
-            return null;
-        }
+        return master.previous != master ? master.previous : null;
     }
 
     public Node addFirst(final E value, final String name) {
@@ -187,19 +179,11 @@ public class NamedElementChain<E> {
         }
 
         public Node getPrevious() {
-            if (previous != master) {
-                return previous;
-            } else {
-                return null;
-            }
+            return previous != master ? previous : null;
         }
 
         public Node getNext() {
-            if (next != master) {
-                return next;
-            } else {
-                return null;
-            }
+            return next != master ? next: null;
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/impl/HttpProcessors.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/HttpProcessors.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/HttpProcessors.java
index affbee1..803b679 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/HttpProcessors.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/HttpProcessors.java
@@ -77,7 +77,7 @@ public final class HttpProcessors {
                         new RequestUserAgent(!TextUtils.isBlank(agentInfo) ? agentInfo :
                                 VersionInfo.getSoftwareInfo(SOFTWARE, "org.apache.hc.core5", HttpProcessors.class)),
                         new RequestExpectContinue());
-    };
+    }
 
     public static HttpProcessor client(final String agentInfo) {
         return customClient(agentInfo).build();

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpRequester.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpRequester.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpRequester.java
index 2f2334b..7be2e36 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpRequester.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpRequester.java
@@ -238,9 +238,8 @@ public class HttpRequester implements ConnPoolControl<HttpHost>, ModalCloseable
         sock.connect(targetAddress, socketConfig.getSoTimeout().toMillisIntBound());
         if (URIScheme.HTTPS.same(targetHost.getSchemeName())) {
             return sslSocketFactory.createSocket(sock, targetHost.getHostName(), targetAddress.getPort(), true);
-        } else {
-            return sock;
         }
+        return sock;
     }
 
     public ClassicHttpResponse execute(

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java
index fe2715d..91a3955 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpService.java
@@ -241,20 +241,19 @@ public class HttpService {
         } catch (final HttpException ex) {
             if (responseSubmitted.get()) {
                 throw ex;
-            } else {
-                try (final ClassicHttpResponse errorResponse = new BasicClassicHttpResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR)) {
-                    handleException(ex, errorResponse);
-                    errorResponse.setHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE);
-                    context.setAttribute(HttpCoreContext.HTTP_RESPONSE, errorResponse);
-                    this.processor.process(errorResponse, errorResponse.getEntity(), context);
+            }
+            try (final ClassicHttpResponse errorResponse = new BasicClassicHttpResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR)) {
+                handleException(ex, errorResponse);
+                errorResponse.setHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE);
+                context.setAttribute(HttpCoreContext.HTTP_RESPONSE, errorResponse);
+                this.processor.process(errorResponse, errorResponse.getEntity(), context);
 
-                    conn.sendResponseHeader(errorResponse);
-                    if (streamListener != null) {
-                        streamListener.onResponseHead(conn, errorResponse);
-                    }
-                    conn.sendResponseEntity(errorResponse);
-                    conn.close();
+                conn.sendResponseHeader(errorResponse);
+                if (streamListener != null) {
+                    streamListener.onResponseHead(conn, errorResponse);
                 }
+                conn.sendResponseEntity(errorResponse);
+                conn.close();
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SocketHolder.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SocketHolder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SocketHolder.java
index 879d791..4a8496f 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SocketHolder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SocketHolder.java
@@ -61,14 +61,12 @@ public class SocketHolder {
         InputStream local = inputStreamRef.get();
         if (local != null) {
             return local;
-        } else {
-            local = getInputStream(socket);
-            if (inputStreamRef.compareAndSet(null, local)) {
-                return local;
-            } else {
-                return inputStreamRef.get();
-            }
         }
+        local = getInputStream(socket);
+        if (inputStreamRef.compareAndSet(null, local)) {
+            return local;
+        }
+        return inputStreamRef.get();
     }
 
     protected InputStream getInputStream(final Socket socket) throws IOException {
@@ -83,14 +81,12 @@ public class SocketHolder {
         OutputStream local = outputStreamRef.get();
         if (local != null) {
             return local;
-        } else {
-            local = getOutputStream(socket);
-            if (outputStreamRef.compareAndSet(null, local)) {
-                return local;
-            } else {
-                return outputStreamRef.get();
-            }
         }
+        local = getOutputStream(socket);
+        if (outputStreamRef.compareAndSet(null, local)) {
+            return local;
+        }
+        return outputStreamRef.get();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/27ee7a10/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
index 21a1433..9ae7b5f 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
@@ -276,13 +276,12 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
                         if (contentDecoder != null) {
                             incomingMessage = new Message<>(messageHead, contentDecoder);
                             break;
+                        }
+                        inputEnd();
+                        if (connState.compareTo(ConnectionState.ACTIVE) == 0) {
+                            ioSession.setEvent(SelectionKey.OP_READ);
                         } else {
-                            inputEnd();
-                            if (connState.compareTo(ConnectionState.ACTIVE) == 0) {
-                                ioSession.setEvent(SelectionKey.OP_READ);
-                            } else {
-                                break;
-                            }
+                            break;
                         }
                     }
                 } while (bytesRead > 0);
@@ -524,11 +523,9 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
             contentEncoder.complete(trailers);
             ioSession.setEvent(SelectionKey.OP_WRITE);
             outgoingMessage = null;
-            if (contentEncoder instanceof ChunkEncoder) {
-                return MessageDelineation.CHUNK_CODED;
-            } else {
-                return MessageDelineation.MESSAGE_HEAD;
-            }
+            return contentEncoder instanceof ChunkEncoder
+                            ? MessageDelineation.CHUNK_CODED
+                            : MessageDelineation.MESSAGE_HEAD;
         } finally {
             outputLock.unlock();
         }


[8/8] httpcomponents-core git commit: Javadocs for core non-HTTP specific APIs

Posted by ol...@apache.org.
Javadocs for core non-HTTP specific APIs


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/3e0d1aa8
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/3e0d1aa8
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/3e0d1aa8

Branch: refs/heads/api_javadocs
Commit: 3e0d1aa8eb0292d2a0759f896cdf0845ee573ca0
Parents: 936ac6f
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sat Aug 4 21:26:26 2018 +0200
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Aug 5 13:06:12 2018 +0200

----------------------------------------------------------------------
 .../apache/hc/core5/concurrent/Cancellable.java |  6 ++++
 .../core5/concurrent/CancellableDependency.java | 11 +++++--
 .../hc/core5/concurrent/ComplexCancellable.java |  5 ++--
 .../hc/core5/concurrent/ComplexFuture.java      |  6 ++--
 .../core5/concurrent/DefaultThreadFactory.java  |  2 ++
 .../hc/core5/concurrent/package-info.java       |  2 +-
 .../apache/hc/core5/function/package-info.java  | 31 ++++++++++++++++++++
 .../org/apache/hc/core5/http/EntityDetails.java |  1 +
 .../java/org/apache/hc/core5/http/HttpHost.java |  6 ++--
 .../org/apache/hc/core5/http/URIScheme.java     |  5 ++++
 .../org/apache/hc/core5/io/package-info.java    | 31 ++++++++++++++++++++
 .../main/java/org/apache/hc/core5/net/Host.java |  6 ++++
 .../org/apache/hc/core5/net/URIAuthority.java   |  2 +-
 .../org/apache/hc/core5/net/package-info.java   | 31 ++++++++++++++++++++
 .../org/apache/hc/core5/pool/package-info.java  | 31 ++++++++++++++++++++
 .../apache/hc/core5/reactor/package-info.java   |  6 +---
 .../apache/hc/core5/reactor/ssl/SSLBuffer.java  |  6 ----
 .../reactor/ssl/TransportSecurityLayer.java     | 16 ++++++++++
 .../hc/core5/reactor/ssl/package-info.java      |  2 +-
 19 files changed, 183 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/concurrent/Cancellable.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/Cancellable.java b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/Cancellable.java
index 6419e53..02da705 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/Cancellable.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/Cancellable.java
@@ -34,6 +34,12 @@ package org.apache.hc.core5.concurrent;
  */
 public interface Cancellable {
 
+    /**
+     * Cancels the ongoing operation or process.
+     *
+     * @return {@code frue} if the operation or process has been cancelled as a result of
+     * this method call or {@code false} if it has already been cancelled or not started.
+     */
     boolean cancel();
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/concurrent/CancellableDependency.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/CancellableDependency.java b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/CancellableDependency.java
index 941ea2f..6074558 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/CancellableDependency.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/CancellableDependency.java
@@ -27,17 +27,24 @@
 package org.apache.hc.core5.concurrent;
 
 /**
- * This interface represents an object dependent on a long running process.
+ * This interface represents {@link Cancellable} object dependent on another
+ * ongoing process or operation.
  *
  * @since 5.0
  */
 public interface CancellableDependency extends Cancellable {
 
     /**
-     * Sets {@link Cancellable} dependency for the ongoing operation.
+     * Sets {@link Cancellable} dependency on another ongoing process or
+     * operation represented by {@link Cancellable}.
      */
     void setDependency(Cancellable cancellable);
 
+    /**
+     * Determines whether the process or operation has been cancelled.
+     *
+     * @return cancelled flag.
+     */
     boolean isCancelled();
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexCancellable.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexCancellable.java b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexCancellable.java
index d2930b9..d306d6a 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexCancellable.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexCancellable.java
@@ -32,8 +32,9 @@ import java.util.concurrent.atomic.AtomicReference;
 import org.apache.hc.core5.util.Args;
 
 /**
- * Cancellable that represents a sequence of other {@link Cancellable} processes.
- * Dependent process will get cancelled if the future itself is cancelled.
+ * {@link Cancellable} that has a dependency on another {@link Cancellable}
+ * process or operation. Dependent process or operation will get cancelled
+ * if this {@link Cancellable} itself is cancelled.
  *
  * @since 5.0
  */

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexFuture.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexFuture.java b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexFuture.java
index 771d02e..18fa786 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexFuture.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexFuture.java
@@ -32,9 +32,9 @@ import java.util.concurrent.atomic.AtomicReference;
 import org.apache.hc.core5.util.Args;
 
 /**
- * Future whose result depends on another {@link Cancellable} processes or
- * {@link Future}. Dependent process will get cancelled if the future
- * itself is cancelled.
+ * {@link Future} whose result depends on another {@link Cancellable} process
+ * or operation or another {@link Future}. Dependent process will get cancelled
+ * if the future itself is cancelled.
  *
  * @param <T> the future result type of an asynchronous operation.
  * @since 5.0

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/concurrent/DefaultThreadFactory.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/DefaultThreadFactory.java b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/DefaultThreadFactory.java
index ab589e9..4ad6a6e 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/DefaultThreadFactory.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/DefaultThreadFactory.java
@@ -30,6 +30,8 @@ import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.atomic.AtomicLong;
 
 /**
+ * Default {@link ThreadFactory} implementation.
+ *
  * @since 5.0
  */
 public class DefaultThreadFactory implements ThreadFactory {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/concurrent/package-info.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/package-info.java b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/package-info.java
index 0f42d9b..7df1652 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/package-info.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/package-info.java
@@ -26,6 +26,6 @@
  */
 
 /**
- * Core concurrency APIs.
+ * Core concurrency component APIs.
  */
 package org.apache.hc.core5.concurrent;

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/function/package-info.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/function/package-info.java b/httpcore5/src/main/java/org/apache/hc/core5/function/package-info.java
new file mode 100644
index 0000000..4dcf8c6
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/function/package-info.java
@@ -0,0 +1,31 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+/**
+ * Commonly used functional interfaces.
+ */
+package org.apache.hc.core5.function;

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/http/EntityDetails.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/EntityDetails.java b/httpcore5/src/main/java/org/apache/hc/core5/http/EntityDetails.java
index 516a697..d46325c 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/EntityDetails.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/EntityDetails.java
@@ -56,6 +56,7 @@ public interface EntityDetails {
      * <p>
      * The behavior of wrapping entities is implementation dependent,
      * but should respect the primary purpose.
+     * </p>
      */
     boolean isChunked();
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java b/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
index dff7eab..cf58c08 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
@@ -42,8 +42,10 @@ import org.apache.hc.core5.util.LangUtils;
 import org.apache.hc.core5.util.TextUtils;
 
 /**
- * Holds all of the variables needed to describe an HTTP connection to a host.
- * This includes remote host name, port and scheme.
+ * Component that holds all details needed to describe an HTTP connection
+ * to a host. This includes remote host name, port and protocol scheme.
+ *
+ * @see org.apache.hc.core5.net.Host
  *
  * @since 4.0
  */

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/http/URIScheme.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/URIScheme.java b/httpcore5/src/main/java/org/apache/hc/core5/http/URIScheme.java
index 261bd1e..1a0a1b9 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/URIScheme.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/URIScheme.java
@@ -29,6 +29,11 @@ package org.apache.hc.core5.http;
 
 import org.apache.hc.core5.util.Args;
 
+/**
+ * Supported URI schemes
+ *
+ * @since 5.0
+ */
 public enum URIScheme {
 
     HTTP("http"), HTTPS("https");

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/io/package-info.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/io/package-info.java b/httpcore5/src/main/java/org/apache/hc/core5/io/package-info.java
new file mode 100644
index 0000000..d7b0c71
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/io/package-info.java
@@ -0,0 +1,31 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+/**
+ * Core I/O component APIs and utilities.
+ */
+package org.apache.hc.core5.io;

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java b/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
index 9f8b2b7..edd0e00 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
@@ -36,6 +36,12 @@ import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.LangUtils;
 import org.apache.hc.core5.util.TextUtils;
 
+/**
+ * Component that holds all details needed to describe a network connection
+ * to a host. This includes remote host name and port.
+ *
+ * @since 5.0
+ */
 @Contract(threading = ThreadingBehavior.IMMUTABLE)
 public final class Host implements NamedEndpoint, Serializable {
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java b/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
index 9484100..bbd093e 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
@@ -38,7 +38,7 @@ import org.apache.hc.core5.util.LangUtils;
 import org.apache.hc.core5.util.TextUtils;
 
 /**
- * Represents authority component of request URI.
+ * Represents authority component of request {@link java.net.URI}.
  *
  * @since 5.0
  */

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/net/package-info.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/net/package-info.java b/httpcore5/src/main/java/org/apache/hc/core5/net/package-info.java
new file mode 100644
index 0000000..af5033b
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/net/package-info.java
@@ -0,0 +1,31 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+/**
+ * Core network component APIs and utilities.
+ */
+package org.apache.hc.core5.net;

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/pool/package-info.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/pool/package-info.java b/httpcore5/src/main/java/org/apache/hc/core5/pool/package-info.java
new file mode 100644
index 0000000..9d53f3d
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/pool/package-info.java
@@ -0,0 +1,31 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+/**
+ * Client side connection pool component APIs.
+ */
+package org.apache.hc.core5.pool;

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/reactor/package-info.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/package-info.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/package-info.java
index d49a888..0d62035 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/package-info.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/package-info.java
@@ -26,12 +26,8 @@
  */
 
 /**
- * Event driven network communication APIs loosely based on
+ * Event driven network communication APIs and components loosely based on
  <a href="http://gee.cs.oswego.edu/dl/">Doug Lea</a>'s
  <a href="http://gee.cs.oswego.edu/dl/cpjslides/nio.pdf">reactor pattern</a>.
- <p>
- This API is not specific to HTTP communication. However, it is minimal
- in the sense that it defines only what is required within the scope
- of HTTP protocol.
  */
 package org.apache.hc.core5.reactor;

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBuffer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBuffer.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBuffer.java
index 18176b4..612e424 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBuffer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBuffer.java
@@ -28,12 +28,6 @@ package org.apache.hc.core5.reactor.ssl;
 
 import java.nio.ByteBuffer;
 
-import org.apache.hc.core5.annotation.Internal;
-
-/**
- * Managed internal SSL buffer.
- */
-@Internal
 interface SSLBuffer {
     /**
      * Allocates the resources required for this buffer, or returns the resources already allocated for this buffer.

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java
index 80cf1c1..38bafd1 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/TransportSecurityLayer.java
@@ -38,6 +38,17 @@ import org.apache.hc.core5.net.NamedEndpoint;
  */
 public interface TransportSecurityLayer {
 
+    /**
+     * Starts TLS session over an existing network connection with the given SSL context.
+     * {@link NamedEndpoint} details are applicable for client side connections and
+     * are used for host name verification, when supported by the SSL engine.
+     *
+     * @param sslContext SSL context to be used for this session.
+     * @param endpoint optional endpoint details for outgoing client side connections.
+     * @param sslBufferManagement SSL buffer management.
+     * @param initializer SSL session initialization callback.
+     * @param verifier SSL session verification callback.
+     */
     void startTls(
             SSLContext sslContext,
             NamedEndpoint endpoint,
@@ -45,6 +56,11 @@ public interface TransportSecurityLayer {
             SSLSessionInitializer initializer,
             SSLSessionVerifier verifier) throws UnsupportedOperationException;
 
+    /**
+     * Returns details of a fully established TLS session.
+     *
+     * @return TLS session details.
+     */
     TlsDetails getTlsDetails();
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3e0d1aa8/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/package-info.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/package-info.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/package-info.java
index d5181ab..c223c2a 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/package-info.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/package-info.java
@@ -26,6 +26,6 @@
  */
 
 /**
- * TLS/SSL support for asynchronous, event driven communication.
+ * TLS/SSL support for I/O reactors.
  */
 package org.apache.hc.core5.reactor.ssl;


[6/8] httpcomponents-core git commit: Moved classes (no functional changes)

Posted by ol...@apache.org.
Moved classes (no functional changes)


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/49c62969
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/49c62969
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/49c62969

Branch: refs/heads/api_javadocs
Commit: 49c62969d0604362d42521798eb4658d840df6ce
Parents: e0041dd
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Aug 5 12:50:42 2018 +0200
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Aug 5 12:50:42 2018 +0200

----------------------------------------------------------------------
 .../nio/AbstractHttp2StreamMultiplexer.java     |  2 +-
 .../impl/nio/ClientHttpProtocolNegotiator.java  |  2 +-
 .../nio/Http2OnlyClientProtocolNegotiator.java  |  2 +-
 .../impl/nio/ServerHttpProtocolNegotiator.java  |  2 +-
 .../core5/http/impl/io/BHttpConnectionBase.java |  2 +-
 .../core5/http/impl/io/HttpRequestExecutor.java |  2 +-
 .../impl/nio/AbstractHttp1StreamDuplexer.java   |  2 +-
 .../java/org/apache/hc/core5/io/Closer.java     | 55 ++++++++++++++++++
 .../core5/io/SocketTimeoutExceptionFactory.java | 60 ++++++++++++++++++++
 .../apache/hc/core5/reactor/IOSessionImpl.java  |  2 +-
 .../core5/reactor/InternalConnectChannel.java   |  2 +-
 .../hc/core5/reactor/SingleCoreIOReactor.java   |  2 +-
 .../reactor/SingleCoreListeningIOReactor.java   |  2 +-
 .../java/org/apache/hc/core5/util/Closer.java   | 53 -----------------
 .../util/SocketTimeoutExceptionFactory.java     | 58 -------------------
 15 files changed, 126 insertions(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
index 51a87d7..316d6e0 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/AbstractHttp2StreamMultiplexer.java
@@ -90,7 +90,7 @@ import org.apache.hc.core5.reactor.ssl.TlsDetails;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.ByteArrayBuffer;
 import org.apache.hc.core5.util.Identifiable;
-import org.apache.hc.core5.util.SocketTimeoutExceptionFactory;
+import org.apache.hc.core5.io.SocketTimeoutExceptionFactory;
 
 abstract class AbstractHttp2StreamMultiplexer implements Identifiable, HttpConnection {
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java
index 4213ccf..e787d29 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator.java
@@ -54,7 +54,7 @@ import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.reactor.ProtocolIOSession;
 import org.apache.hc.core5.reactor.ssl.TlsDetails;
 import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.SocketTimeoutExceptionFactory;
+import org.apache.hc.core5.io.SocketTimeoutExceptionFactory;
 
 /**
  * @since 5.0

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/Http2OnlyClientProtocolNegotiator.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/Http2OnlyClientProtocolNegotiator.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/Http2OnlyClientProtocolNegotiator.java
index 7d4e6ac..58d17fb 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/Http2OnlyClientProtocolNegotiator.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/Http2OnlyClientProtocolNegotiator.java
@@ -51,7 +51,7 @@ import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.reactor.ProtocolIOSession;
 import org.apache.hc.core5.reactor.ssl.TlsDetails;
 import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.SocketTimeoutExceptionFactory;
+import org.apache.hc.core5.io.SocketTimeoutExceptionFactory;
 import org.apache.hc.core5.util.TextUtils;
 
 /**

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
----------------------------------------------------------------------
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
index e097e00..b3b49d9 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ServerHttpProtocolNegotiator.java
@@ -51,7 +51,7 @@ import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.reactor.ProtocolIOSession;
 import org.apache.hc.core5.reactor.ssl.TlsDetails;
 import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.SocketTimeoutExceptionFactory;
+import org.apache.hc.core5.io.SocketTimeoutExceptionFactory;
 
 /**
  * @since 5.0

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
index c1979d4..f2d1603 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/BHttpConnectionBase.java
@@ -61,7 +61,7 @@ import org.apache.hc.core5.http.io.SessionOutputBuffer;
 import org.apache.hc.core5.io.CloseMode;
 import org.apache.hc.core5.net.InetAddressUtils;
 import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.Closer;
+import org.apache.hc.core5.io.Closer;
 
 class BHttpConnectionBase implements BHttpConnection {
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
index 93ddb47..a84fbe0 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/HttpRequestExecutor.java
@@ -53,7 +53,7 @@ import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.http.protocol.HttpCoreContext;
 import org.apache.hc.core5.http.protocol.HttpProcessor;
 import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.Closer;
+import org.apache.hc.core5.io.Closer;
 
 /**
  * {@code HttpRequestExecutor} is a client side HTTP protocol handler based

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
index 9ae7b5f..b8349b1 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java
@@ -76,7 +76,7 @@ import org.apache.hc.core5.reactor.ProtocolIOSession;
 import org.apache.hc.core5.reactor.ssl.TlsDetails;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.Identifiable;
-import org.apache.hc.core5.util.SocketTimeoutExceptionFactory;
+import org.apache.hc.core5.io.SocketTimeoutExceptionFactory;
 
 abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage, OutgoingMessage extends HttpMessage>
         implements Identifiable, HttpConnection {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5/src/main/java/org/apache/hc/core5/io/Closer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/io/Closer.java b/httpcore5/src/main/java/org/apache/hc/core5/io/Closer.java
new file mode 100644
index 0000000..a764afa
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/io/Closer.java
@@ -0,0 +1,55 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.io;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+/**
+ * Closes resources.
+ *
+ * @since 5.0
+ */
+public final class Closer {
+
+    /**
+     * Closes the given closeable quietly even in the event of an exception.
+     *
+     * @param closeable
+     *            what to close.
+     */
+    public static void closeQuietly(final Closeable closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (final IOException e) {
+                // Quietly ignore
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5/src/main/java/org/apache/hc/core5/io/SocketTimeoutExceptionFactory.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/io/SocketTimeoutExceptionFactory.java b/httpcore5/src/main/java/org/apache/hc/core5/io/SocketTimeoutExceptionFactory.java
new file mode 100644
index 0000000..eebc34a
--- /dev/null
+++ b/httpcore5/src/main/java/org/apache/hc/core5/io/SocketTimeoutExceptionFactory.java
@@ -0,0 +1,60 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.hc.core5.io;
+
+import java.net.SocketTimeoutException;
+
+/**
+ * Creates SocketTimeoutException instances.
+ *
+ * @since 5.0
+ */
+public final class SocketTimeoutExceptionFactory {
+
+    /**
+     * Creates a new SocketTimeoutException with a message for the given timeout.
+     *
+     * @param timeoutMillis
+     *            a timeout in milliseconds.
+     * @return a new SocketTimeoutException with a message for the given timeout.
+     */
+    static public SocketTimeoutException create(final int timeoutMillis) {
+        return new SocketTimeoutException(toMessage(timeoutMillis));
+    }
+
+    /**
+     * Creates a message for the given timeout.
+     *
+     * @param timeoutMillis
+     *            a timeout in milliseconds.
+     * @return a message for the given timeout.
+     */
+    public static String toMessage(final int timeoutMillis) {
+        return String.format("%,d millisecond", timeoutMillis);
+    }
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
index 98b3b7a..150aa90 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
@@ -40,7 +40,7 @@ import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.hc.core5.io.CloseMode;
 import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.Closer;
+import org.apache.hc.core5.io.Closer;
 
 class IOSessionImpl implements IOSession {
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalConnectChannel.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalConnectChannel.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalConnectChannel.java
index 4cde455..aad934d 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalConnectChannel.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalConnectChannel.java
@@ -32,7 +32,7 @@ import java.nio.channels.SelectionKey;
 import java.nio.channels.SocketChannel;
 
 import org.apache.hc.core5.io.CloseMode;
-import org.apache.hc.core5.util.SocketTimeoutExceptionFactory;
+import org.apache.hc.core5.io.SocketTimeoutExceptionFactory;
 import org.apache.hc.core5.util.TimeValue;
 
 final class InternalConnectChannel extends InternalChannel {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
index 0b16bed..67f38b4 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreIOReactor.java
@@ -48,7 +48,7 @@ import org.apache.hc.core5.function.Decorator;
 import org.apache.hc.core5.io.CloseMode;
 import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.Closer;
+import org.apache.hc.core5.io.Closer;
 import org.apache.hc.core5.util.TimeValue;
 
 class SingleCoreIOReactor extends AbstractSingleCoreIOReactor implements ConnectionInitiator {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java
index a30dd2e..748eaf5 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/SingleCoreListeningIOReactor.java
@@ -47,7 +47,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.hc.core5.concurrent.BasicFuture;
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.function.Callback;
-import org.apache.hc.core5.util.Closer;
+import org.apache.hc.core5.io.Closer;
 
 class SingleCoreListeningIOReactor extends AbstractSingleCoreIOReactor implements ConnectionAcceptor {
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5/src/main/java/org/apache/hc/core5/util/Closer.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/Closer.java b/httpcore5/src/main/java/org/apache/hc/core5/util/Closer.java
deleted file mode 100644
index 6886688..0000000
--- a/httpcore5/src/main/java/org/apache/hc/core5/util/Closer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.core5.util;
-
-import java.io.Closeable;
-import java.io.IOException;
-
-/**
- * Closes resources.
- */
-public class Closer {
-
-    /**
-     * Closes the given closeable quietly even in the event of an exception.
-     *
-     * @param closeable
-     *            what to close.
-     */
-    public static void closeQuietly(final Closeable closeable) {
-        if (closeable != null) {
-            try {
-                closeable.close();
-            } catch (final IOException e) {
-                // Quietly ignore
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/49c62969/httpcore5/src/main/java/org/apache/hc/core5/util/SocketTimeoutExceptionFactory.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/SocketTimeoutExceptionFactory.java b/httpcore5/src/main/java/org/apache/hc/core5/util/SocketTimeoutExceptionFactory.java
deleted file mode 100644
index 6af2bb7..0000000
--- a/httpcore5/src/main/java/org/apache/hc/core5/util/SocketTimeoutExceptionFactory.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.core5.util;
-
-import java.net.SocketTimeoutException;
-
-/**
- * Creates SocketTimeoutException instances.
- */
-public class SocketTimeoutExceptionFactory {
-
-    /**
-     * Creates a new SocketTimeoutException with a message for the given timeout.
-     *
-     * @param timeoutMillis
-     *            a timeout in milliseconds.
-     * @return a new SocketTimeoutException with a message for the given timeout.
-     */
-    static public SocketTimeoutException create(final int timeoutMillis) {
-        return new SocketTimeoutException(toMessage(timeoutMillis));
-    }
-
-    /**
-     * Creates a message for the given timeout.
-     *
-     * @param timeoutMillis
-     *            a timeout in milliseconds.
-     * @return a message for the given timeout.
-     */
-    public static String toMessage(final int timeoutMillis) {
-        return String.format("%,d millisecond", timeoutMillis);
-    }
-}