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/04 15:39:03 UTC

[1/4] 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/master 8abb823bb -> fc53fdd66 (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/d01b7ec0
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/d01b7ec0
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/d01b7ec0

Branch: refs/heads/master
Commit: d01b7ec0787d032931deea9b137439d32ff662d8
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 17:27:35 2018 +0200

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |  6 ++
 .../impl/nio/AbstractHttp2IOEventHandler.java   | 12 ++--
 .../nio/AbstractHttp2StreamMultiplexer.java     | 20 +++++--
 .../impl/nio/ClientHttpProtocolNegotiator.java  | 10 ++--
 .../nio/Http2OnlyClientProtocolNegotiator.java  | 10 ++--
 .../impl/nio/ServerHttpProtocolNegotiator.java  | 10 ++--
 .../nio/TestDefaultListeningIOReactor.java      |  2 +-
 .../apache/hc/core5/http/HttpConnection.java    |  4 +-
 .../core5/http/impl/io/BHttpConnectionBase.java |  4 +-
 .../impl/nio/AbstractHttp1IOEventHandler.java   | 12 ++--
 .../impl/nio/AbstractHttp1StreamDuplexer.java   | 10 ++--
 .../impl/nio/ClientHttp1StreamDuplexer.java     |  4 +-
 .../http/impl/nio/ClientHttp1StreamHandler.java |  8 +--
 .../core5/http/impl/nio/Http1StreamChannel.java |  4 +-
 .../impl/nio/ServerHttp1StreamDuplexer.java     | 12 ++--
 .../apache/hc/core5/reactor/IOEventHandler.java |  3 +-
 .../hc/core5/reactor/InternalChannel.java       | 12 ++--
 .../core5/reactor/InternalConnectChannel.java   |  8 +--
 .../hc/core5/reactor/InternalDataChannel.java   |  6 +-
 .../util/SocketTimeoutExceptionFactory.java     | 58 ++++++++++++++++++++
 .../http/impl/io/TestBHttpConnectionBase.java   | 12 ++--
 21 files changed, 150 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d01b7ec0/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/d01b7ec0/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/d01b7ec0/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..6d73284 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,7 +1206,7 @@ abstract class AbstractHttp2StreamMultiplexer implements Identifiable, HttpConne
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
+    public void setSocketTimeoutMillis(final int timeout) {
         ioSession.setSocketTimeout(timeout);
     }
 
@@ -1218,7 +1226,7 @@ abstract class AbstractHttp2StreamMultiplexer implements Identifiable, HttpConne
     }
 
     @Override
-    public int getSocketTimeout() {
+    public int getSocketTimeoutMillis() {
         return ioSession.getSocketTimeout();
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d01b7ec0/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..62d3d1d 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,12 +218,12 @@ public class ClientHttpProtocolNegotiator implements HttpConnectionEventHandler
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
+    public void setSocketTimeoutMillis(final int timeout) {
         ioSession.setSocketTimeout(timeout);
     }
 
     @Override
-    public int getSocketTimeout() {
+    public int getSocketTimeoutMillis() {
         return ioSession.getSocketTimeout();
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d01b7ec0/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..286ec02 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,12 +190,12 @@ public class Http2OnlyClientProtocolNegotiator implements HttpConnectionEventHan
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
+    public void setSocketTimeoutMillis(final int timeout) {
         ioSession.setSocketTimeout(timeout);
     }
 
     @Override
-    public int getSocketTimeout() {
+    public int getSocketTimeoutMillis() {
         return ioSession.getSocketTimeout();
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d01b7ec0/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..18c70d9 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,12 +186,12 @@ public class ServerHttpProtocolNegotiator implements HttpConnectionEventHandler
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
+    public void setSocketTimeoutMillis(final int timeout) {
         ioSession.setSocketTimeout(timeout);
     }
 
     @Override
-    public int getSocketTimeout() {
+    public int getSocketTimeoutMillis() {
         return ioSession.getSocketTimeout();
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d01b7ec0/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/d01b7ec0/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/d01b7ec0/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/d01b7ec0/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/d01b7ec0/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..7b603b6 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));
         }
     }
 
@@ -563,7 +563,7 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
     }
 
     @Override
-    public void setSocketTimeout(final int timeout) {
+    public void setSocketTimeoutMillis(final int timeout) {
         ioSession.setSocketTimeout(timeout);
     }
 
@@ -577,7 +577,7 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
     }
 
     @Override
-    public int getSocketTimeout() {
+    public int getSocketTimeoutMillis() {
         return ioSession.getSocketTimeout();
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d01b7ec0/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..186f8b4 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,12 +124,12 @@ public class ClientHttp1StreamDuplexer extends AbstractHttp1StreamDuplexer<HttpR
             }
 
             @Override
-            public int getSocketTimeout() {
+            public int getSocketTimeoutMillis() {
                 return getSessionTimeout();
             }
 
             @Override
-            public void setSocketTimeout(final int timeout) {
+            public void setSocketTimeoutMillis(final int timeout) {
                 setSessionTimeout(timeout);
             }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d01b7ec0/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..41562d5 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.getWaitForContinueTimeout());
                 } 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/d01b7ec0/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/d01b7ec0/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..1491da1 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,12 +129,12 @@ public class ServerHttp1StreamDuplexer extends AbstractHttp1StreamDuplexer<HttpR
             }
 
             @Override
-            public int getSocketTimeout() {
+            public int getSocketTimeoutMillis() {
                 return getSessionTimeout();
             }
 
             @Override
-            public void setSocketTimeout(final int timeout) {
+            public void setSocketTimeoutMillis(final int timeout) {
                 setSessionTimeout(timeout);
             }
 
@@ -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/d01b7ec0/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/d01b7ec0/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/d01b7ec0/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/d01b7ec0/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..3f4878e 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() {
+    int getTimeoutMillis() {
         return ioSession.getSocketTimeout();
     }
 
     @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()) {

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d01b7ec0/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/d01b7ec0/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


[2/4] httpcomponents-core git commit: Refactor timeout APIs to include the scale in the method name; for example 'int getSocketTimeout()' -> int 'getSocketTimeoutMillis()'.

Posted by ol...@apache.org.
Refactor timeout APIs to include the scale in the method name; for
example 'int getSocketTimeout()' -> 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/3af89cc7
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/3af89cc7
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/3af89cc7

Branch: refs/heads/master
Commit: 3af89cc77028a240e6f685ff8c2ceca4c7cd9356
Parents: d01b7ec
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 08:42:13 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sat Aug 4 17:27:47 2018 +0200

----------------------------------------------------------------------
 .../impl/nio/AbstractHttp2StreamMultiplexer.java      |  6 +++---
 .../http2/impl/nio/ClientHttpProtocolNegotiator.java  |  4 ++--
 .../impl/nio/Http2OnlyClientProtocolNegotiator.java   |  4 ++--
 .../http2/impl/nio/ServerHttpProtocolNegotiator.java  |  4 ++--
 .../apache/hc/core5/http2/nio/pool/H2ConnPool.java    |  6 +++---
 .../apache/hc/core5/benchmark/BenchmarkWorker.java    |  6 +++---
 .../apache/hc/core5/benchmark/CommandLineUtils.java   |  2 +-
 .../java/org/apache/hc/core5/benchmark/Config.java    |  4 ++--
 .../apache/hc/core5/testing/nio/LoggingIOSession.java |  8 ++++----
 .../hc/core5/testing/nio/Http1IntegrationTest.java    |  2 +-
 .../org/apache/hc/core5/http/config/H1Config.java     | 14 +++++++-------
 .../core5/http/impl/bootstrap/HttpAsyncRequester.java |  2 +-
 .../http/impl/nio/AbstractHttp1StreamDuplexer.java    | 14 +++++++-------
 .../http/impl/nio/ClientHttp1StreamDuplexer.java      |  4 ++--
 .../core5/http/impl/nio/ClientHttp1StreamHandler.java |  2 +-
 .../http/impl/nio/ServerHttp1StreamDuplexer.java      |  4 ++--
 .../java/org/apache/hc/core5/reactor/IOSession.java   |  4 ++--
 .../org/apache/hc/core5/reactor/IOSessionImpl.java    |  4 ++--
 .../apache/hc/core5/reactor/InternalDataChannel.java  | 10 +++++-----
 .../apache/hc/core5/reactor/SingleCoreIOReactor.java  |  4 ++--
 .../org/apache/hc/core5/reactor/ssl/SSLIOSession.java | 12 ++++++------
 21 files changed, 60 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3af89cc7/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 6d73284..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
@@ -1207,7 +1207,7 @@ abstract class AbstractHttp2StreamMultiplexer implements Identifiable, HttpConne
 
     @Override
     public void setSocketTimeoutMillis(final int timeout) {
-        ioSession.setSocketTimeout(timeout);
+        ioSession.setSocketTimeoutMillis(timeout);
     }
 
     @Override
@@ -1220,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 getSocketTimeoutMillis() {
-        return ioSession.getSocketTimeout();
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3af89cc7/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 62d3d1d..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
@@ -219,12 +219,12 @@ public class ClientHttpProtocolNegotiator implements HttpConnectionEventHandler
 
     @Override
     public void setSocketTimeoutMillis(final int timeout) {
-        ioSession.setSocketTimeout(timeout);
+        ioSession.setSocketTimeoutMillis(timeout);
     }
 
     @Override
     public int getSocketTimeoutMillis() {
-        return ioSession.getSocketTimeout();
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3af89cc7/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 286ec02..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
@@ -191,12 +191,12 @@ public class Http2OnlyClientProtocolNegotiator implements HttpConnectionEventHan
 
     @Override
     public void setSocketTimeoutMillis(final int timeout) {
-        ioSession.setSocketTimeout(timeout);
+        ioSession.setSocketTimeoutMillis(timeout);
     }
 
     @Override
     public int getSocketTimeoutMillis() {
-        return ioSession.getSocketTimeout();
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3af89cc7/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 18c70d9..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
@@ -187,12 +187,12 @@ public class ServerHttpProtocolNegotiator implements HttpConnectionEventHandler
 
     @Override
     public void setSocketTimeoutMillis(final int timeout) {
-        ioSession.setSocketTimeout(timeout);
+        ioSession.setSocketTimeoutMillis(timeout);
     }
 
     @Override
     public int getSocketTimeoutMillis() {
-        return ioSession.getSocketTimeout();
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3af89cc7/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/3af89cc7/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/3af89cc7/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/3af89cc7/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/3af89cc7/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/3af89cc7/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/3af89cc7/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/3af89cc7/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/3af89cc7/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 7b603b6..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
@@ -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() {
@@ -564,21 +564,21 @@ abstract class AbstractHttp1StreamDuplexer<IncomingMessage extends HttpMessage,
 
     @Override
     public void setSocketTimeoutMillis(final int timeout) {
-        ioSession.setSocketTimeout(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 getSocketTimeoutMillis() {
-        return ioSession.getSocketTimeout();
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3af89cc7/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 186f8b4..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
@@ -125,12 +125,12 @@ public class ClientHttp1StreamDuplexer extends AbstractHttp1StreamDuplexer<HttpR
 
             @Override
             public int getSocketTimeoutMillis() {
-                return getSessionTimeout();
+                return getSessionTimeoutMillis();
             }
 
             @Override
             public void setSocketTimeoutMillis(final int timeout) {
-                setSessionTimeout(timeout);
+                setSessionTimeoutMillis(timeout);
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3af89cc7/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 41562d5..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
@@ -163,7 +163,7 @@ class ClientHttp1StreamHandler implements ResourceHolder {
                 if (expectContinue) {
                     requestState = MessageState.ACK;
                     timeout = outputChannel.getSocketTimeoutMillis();
-                    outputChannel.setSocketTimeoutMillis(h1Config.getWaitForContinueTimeout());
+                    outputChannel.setSocketTimeoutMillis(h1Config.getWaitForContinueTimeoutMillis());
                 } else {
                     requestState = MessageState.BODY;
                     exchangeHandler.produce(internalDataChannel);

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3af89cc7/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 1491da1..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
@@ -130,12 +130,12 @@ public class ServerHttp1StreamDuplexer extends AbstractHttp1StreamDuplexer<HttpR
 
             @Override
             public int getSocketTimeoutMillis() {
-                return getSessionTimeout();
+                return getSessionTimeoutMillis();
             }
 
             @Override
             public void setSocketTimeoutMillis(final int timeout) {
-                setSessionTimeout(timeout);
+                setSessionTimeoutMillis(timeout);
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/3af89cc7/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/3af89cc7/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/3af89cc7/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 3f4878e..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
@@ -173,7 +173,7 @@ final class InternalDataChannel extends InternalChannel implements ProtocolIOSes
 
     @Override
     int getTimeoutMillis() {
-        return ioSession.getSocketTimeout();
+        return ioSession.getSocketTimeoutMillis();
     }
 
     @Override
@@ -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/3af89cc7/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/3af89cc7/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


[3/4] httpcomponents-core git commit: No need to nest else clauses. Replace some if/else with a ternary return/

Posted by ol...@apache.org.
No need to nest else clauses. Replace some if/else with a ternary
return/


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

Branch: refs/heads/master
Commit: 24fb4ecea403d94b5d5f71b48580efb874a2e283
Parents: 3af89cc
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 17:29:11 2018 +0200

----------------------------------------------------------------------
 .../apache/hc/core5/http2/frame/RawFrame.java   |  6 +-
 .../nio/AbstractHttp2StreamMultiplexer.java     |  3 +-
 .../hc/core5/concurrent/ComplexCancellable.java |  3 +-
 .../hc/core5/http/config/NamedElementChain.java | 24 ++------
 .../hc/core5/http/message/MessageSupport.java   |  7 +--
 .../support/AbstractAsyncServerAuthFilter.java  | 64 ++++++++++----------
 ...ServerFilterChainExchangeHandlerFactory.java |  6 +-
 .../BasicAsyncServerExpectationDecorator.java   | 12 +---
 ...aultAsyncResponseExchangeHandlerFactory.java | 14 ++---
 .../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 +-
 14 files changed, 62 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/24fb4ece/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/24fb4ece/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/24fb4ece/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..7f2b46f 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
@@ -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/24fb4ece/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/24fb4ece/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/24fb4ece/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/24fb4ece/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/24fb4ece/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/24fb4ece/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..921c915 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");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/24fb4ece/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/24fb4ece/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/24fb4ece/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/24fb4ece/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/24fb4ece/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


[4/4] httpcomponents-core git commit: Remove redundant interfaces, generics, and semicolons.

Posted by ol...@apache.org.
Remove redundant interfaces, generics, and semicolons.


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

Branch: refs/heads/master
Commit: fc53fdd6695cdd6afe21d99769ff42bab60af917
Parents: 24fb4ec
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 09:00:20 2018 -0600
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sat Aug 4 17:31:56 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 +-
 .../hc/core5/http2/hpack/HPackException.java    |  2 +-
 .../hc/core5/http2/impl/Http2Processors.java    |  2 +-
 .../nio/bootstrap/CancellableExecution.java     |  2 +-
 .../framework/ClassicTestClientAdapter.java     |  4 +-
 .../core5/testing/framework/FrameworkTest.java  | 10 ++--
 .../testing/framework/TestingFramework.java     | 17 +++---
 .../TestingFrameworkRequestHandler.java         |  4 +-
 .../TestClassicTestClientTestingAdapter.java    | 36 ++++++------
 .../framework/TestClientPOJOAdapter.java        |  4 +-
 .../testing/framework/TestFrameworkTest.java    |  8 +--
 .../testing/framework/TestTestingFramework.java | 58 ++++++++++----------
 .../hc/core5/concurrent/ComplexCancellable.java |  2 +-
 .../org/apache/hc/core5/http/ContentType.java   |  2 +-
 23 files changed, 86 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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..9468fee 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;

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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..8335efb 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);
 
@@ -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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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/fc53fdd6/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..f1c6e4e 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
@@ -196,7 +196,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 +247,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 +267,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 +308,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 +341,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 +372,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 +406,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 +447,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 +496,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 +531,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 +559,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 +828,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 +859,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 +901,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 +960,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 +1023,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 +1046,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 +1092,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 +1109,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 +1150,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/fc53fdd6/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 7f2b46f..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;

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/fc53fdd6/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);
         }