You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2018/08/04 20:24:19 UTC

[01/19] httpcomponents-core git commit: Format nit.

Repository: httpcomponents-core
Updated Branches:
  refs/heads/master 27ee7a105 -> dc648a988


Format nit.

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

Branch: refs/heads/master
Commit: e458ec98e4bc7c9db1f13b5d15cb23f68649e37c
Parents: 872dcf2
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 07:48:21 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 07:48:21 2018 -0600

----------------------------------------------------------------------
 .../org/apache/hc/core5/testing/framework/TestingFramework.java     | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


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


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

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

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

Branch: refs/heads/master
Commit: ef6bc7ca645261a9ccb24bdedc8cfacfb6c16dbc
Parents: 8abb823
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 09:41:30 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 09:41:30 2018 -0600

----------------------------------------------------------------------
 .../apache/hc/core5/http2/hpack/FifoBuffer.java |  6 +-
 .../hc/core5/http2/hpack/FifoLinkedList.java    |  5 +-
 .../hc/core5/http2/hpack/HPackDecoder.java      | 30 +++++----
 .../hc/core5/http2/hpack/HPackEncoder.java      | 31 +++++----
 .../core5/http2/hpack/InboundDynamicTable.java  |  8 +--
 .../core5/http2/hpack/OutboundDynamicTable.java |  8 +--
 .../impl/nio/ClientHttp2StreamMultiplexer.java  |  3 +-
 .../impl/nio/ServerHttpProtocolNegotiator.java  |  3 +-
 .../nio/bootstrap/CancellableExecution.java     |  3 +-
 .../DefaultAsyncPushConsumerFactory.java        |  6 +-
 .../hc/core5/http2/WritableByteChannelMock.java |  8 +--
 .../http2/frame/TestDefaultFrameFactory.java    |  2 +-
 .../hc/core5/http2/frame/TestFrameFlag.java     |  2 +-
 .../hc/core5/http2/frame/TestH2Settings.java    |  2 +-
 .../impl/nio/entity/TestSharedInputBuffer.java  |  3 +-
 .../testing/classic/ClassicTestServer.java      |  6 +-
 .../testing/framework/ClientPOJOAdapter.java    |  2 +-
 .../testing/framework/ClientTestingAdapter.java |  4 +-
 .../testing/framework/TestingFramework.java     |  2 +-
 .../testing/framework/TestTestingFramework.java |  9 ++-
 .../http/examples/AsyncServerFilterExample.java | 45 +++++++------
 .../hc/core5/http/impl/HttpProcessors.java      |  2 +-
 .../http/impl/bootstrap/HttpRequester.java      |  3 +-
 .../hc/core5/http/impl/io/HttpService.java      | 23 ++++---
 .../hc/core5/http/impl/io/SocketHolder.java     | 24 +++----
 .../impl/nio/AbstractHttp1StreamDuplexer.java   | 19 +++---
 .../impl/nio/ClientHttp1StreamDuplexer.java     |  3 +-
 ...aultAsyncResponseExchangeHandlerFactory.java |  3 +-
 .../apache/hc/core5/ssl/ReflectionSupport.java  |  1 -
 .../hc/core5/http/WritableByteChannelMock.java  |  8 +--
 .../http/impl/io/TestBHttpConnectionBase.java   | 23 +++----
 .../http/impl/io/TestHttpRequestExecutor.java   | 13 ++--
 .../hc/core5/http/impl/io/TestHttpService.java  | 13 ++--
 .../http/impl/io/TestSessionInOutBuffers.java   |  9 +--
 .../impl/io/TimeoutByteArrayInputStream.java    |  8 +--
 .../http/impl/nio/TestSessionInOutBuffers.java  |  7 +--
 .../core5/http/message/TestBasicLineParser.java |  2 +-
 .../TestAbstractBinAsyncEntityConsumer.java     |  2 +-
 .../TestAbstractBinAsyncEntityProducer.java     |  2 +-
 .../TestAbstractCharAsyncEntityConsumer.java    |  2 +-
 .../TestAbstractCharAsyncEntityProducer.java    |  2 +-
 .../apache/hc/core5/pool/TestLaxConnPool.java   |  9 +--
 .../hc/core5/pool/TestStrictConnPool.java       | 11 ++--
 .../reactor/TestAbstractIOSessionPool.java      | 66 ++++++++++----------
 .../hc/core5/ssl/TestSSLContextBuilder.java     |  9 +--
 45 files changed, 206 insertions(+), 246 deletions(-)
----------------------------------------------------------------------


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

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

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

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

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

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

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

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

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ef6bc7ca/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 9468fee..7257782 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/CancellableExecution.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/CancellableExecution.java
@@ -66,9 +66,8 @@ final class CancellableExecution implements CancellableDependency {
                 dependency.cancel();
             }
             return true;
-        } else {
-            return false;
         }
+        return false;
     }
 
 }

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

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

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

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

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

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

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

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

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

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ef6bc7ca/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 8335efb..36761d3 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFramework.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/TestingFramework.java
@@ -373,7 +373,7 @@ public class TestingFramework {
         if (expectedHeaders == null) {
             return;
         }
-        for (final Map.Entry<String, String> expectedHeader : ((Map<String, String>) expectedHeaders).entrySet()) {
+        for (final Map.Entry<String, String> expectedHeader : expectedHeaders.entrySet()) {
             final String expectedHeaderName = expectedHeader.getKey();
             if (! actualHeaders.containsKey(expectedHeaderName)) {
                 throw new TestingFrameworkException("Expected header not found: name=" + expectedHeaderName);

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ef6bc7ca/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 f1c6e4e..c9b7980 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestTestingFramework.java
@@ -52,6 +52,7 @@ import org.hamcrest.Description;
 import org.hamcrest.Matcher;
 import org.junit.Assert;
 import org.junit.Test;
+import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
 
 public class TestTestingFramework {
@@ -123,13 +124,12 @@ public class TestTestingFramework {
         }
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void goodAdapterWithConstructor() throws Exception {
         final ClientTestingAdapter adapter = Mockito.mock(ClientTestingAdapter.class);
 
         // Have isRequestSupported() return false so no test will run.
-        Mockito.when(adapter.isRequestSupported(Mockito.<String, Object>anyMap()))
+        Mockito.when(adapter.isRequestSupported(ArgumentMatchers.<String, Object>anyMap()))
                      .thenReturn(false);
 
         final TestingFramework framework = newWebServerTestingFramework(adapter);
@@ -140,10 +140,9 @@ public class TestTestingFramework {
         verifyCallMethodNeverCalled(adapter);
     }
 
-    @SuppressWarnings("unchecked")
     private void verifyCallMethodNeverCalled(final ClientTestingAdapter adapter) throws Exception {
-        Mockito.verify(adapter, Mockito.never()).execute(Mockito.anyString(), Mockito.<String, Object>anyMap(),
-                       Mockito.any(TestingFrameworkRequestHandler.class), Mockito.<String, Object>anyMap());
+        Mockito.verify(adapter, Mockito.never()).execute(ArgumentMatchers.anyString(), ArgumentMatchers.<String, Object>anyMap(),
+                       ArgumentMatchers.any(TestingFrameworkRequestHandler.class), ArgumentMatchers.<String, Object>anyMap());
     }
 
     private TestingFramework newFrameworkAndSetAdapter(final ClientTestingAdapter adapter)

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

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

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

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

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

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

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

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ef6bc7ca/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 921c915..1097a08 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/DefaultAsyncResponseExchangeHandlerFactory.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/DefaultAsyncResponseExchangeHandlerFactory.java
@@ -75,9 +75,8 @@ public final class DefaultAsyncResponseExchangeHandlerFactory implements Handler
         final AsyncServerExchangeHandler handler = createHandler(request, context);
         if (handler != null) {
             return decorator != null ? decorator.decorate(handler) : handler;
-        } else {
-            return null;
         }
+        return null;
     }
 
 }

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

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

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

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

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

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

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/ef6bc7ca/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
index 2417b7d..97bdf49 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
@@ -61,9 +61,8 @@ class TimeoutByteArrayInputStream extends InputStream {
         final int v = this.buf[this.pos++] & 0xff;
         if (v != 0) {
             return v;
-        } else {
-            throw new InterruptedIOException("Timeout");
         }
+        throw new InterruptedIOException("Timeout");
     }
 
     @Override
@@ -92,10 +91,9 @@ class TimeoutByteArrayInputStream extends InputStream {
             final int v = this.buf[this.pos] & 0xff;
             if (v == 0) {
                 return i;
-            } else {
-                b[off + i] = (byte) v;
-                this.pos++;
             }
+            b[off + i] = (byte) v;
+            this.pos++;
         }
         return chunk;
     }

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

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

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

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

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

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

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

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

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

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


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

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

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

Branch: refs/heads/master
Commit: dc648a98871d6adaff40620ef1187415b9df9018
Parents: 24c351c
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 14:24:12 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 14:24:12 2018 -0600

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


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

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

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

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

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

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


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

Posted by gg...@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


[02/19] httpcomponents-core git commit: No need to nest else clauses.

Posted by gg...@apache.org.
No need to nest else clauses.

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

Branch: refs/heads/master
Commit: d921a80c88dbff241a6286b48b378d98d76dca26
Parents: e458ec9
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 07:57:13 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 07:57:13 2018 -0600

----------------------------------------------------------------------
 .../main/java/org/apache/hc/core5/http2/frame/RawFrame.java    | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


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


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

Posted by gg...@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


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

Posted by gg...@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/a82093ba
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/a82093ba
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/a82093ba

Branch: refs/heads/master
Commit: a82093baf300fe407e5ebee68e4abb40456747f9
Parents: be7fb8f
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 09:12:51 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 09:12:51 2018 -0600

----------------------------------------------------------------------
 .../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 +-
 .../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     | 16 +++---
 .../TestingFrameworkRequestHandler.java         |  4 +-
 .../TestClassicTestClientTestingAdapter.java    | 36 ++++++------
 .../framework/TestClientPOJOAdapter.java        |  2 +-
 .../testing/framework/TestFrameworkTest.java    |  8 +--
 .../testing/framework/TestTestingFramework.java | 58 ++++++++++----------
 .../hc/core5/concurrent/ComplexCancellable.java |  2 +-
 .../org/apache/hc/core5/http/ContentType.java   |  2 +-
 21 files changed, 82 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/a82093ba/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/a82093ba/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/a82093ba/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/a82093ba/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/a82093ba/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/a82093ba/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/a82093ba/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/a82093ba/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/a82093ba/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/a82093ba/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/a82093ba/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/a82093ba/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/a82093ba/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/a82093ba/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 ddc4086..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
@@ -121,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);
@@ -139,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;
@@ -157,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);
 
@@ -403,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/a82093ba/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/a82093ba/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/a82093ba/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..28ca7b2 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);

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


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

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


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

Branch: refs/heads/master
Commit: d619748c1769627edb3e2bfa1731a20d7c7797b4
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:48:28 2018 +0200

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


[08/19] httpcomponents-core git commit: Remove Unnecessary semicolon.

Posted by gg...@apache.org.
Remove Unnecessary semicolon.

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

Branch: refs/heads/master
Commit: 8abb823bbf369e333820757d43ffc20f2b1381ff
Parents: a82093b
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 09:22:25 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 09:22:25 2018 -0600

----------------------------------------------------------------------
 .../apache/hc/core5/testing/framework/TestClientPOJOAdapter.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/8abb823b/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 28ca7b2..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
@@ -69,7 +69,7 @@ public class TestClientPOJOAdapter {
             @Override
             public String getClientName() {
                 return null;
-            };
+            }
         };
 
         try {


[03/19] 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()'.

Posted by gg...@apache.org.
* 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/0124d114
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/0124d114
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/0124d114

Branch: refs/heads/master
Commit: 0124d1147424da09d7b0aaa54e21665ee4c13b7f
Parents: d921a80
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 08:25:52 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 08:25:52 2018 -0600

----------------------------------------------------------------------
 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 ++--
 .../testing/framework/TestingFramework.java     |  2 +-
 .../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 ++--
 22 files changed, 151 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/0124d114/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/0124d114/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/0124d114/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/0124d114/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/0124d114/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/0124d114/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/0124d114/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 74555ec..ddc4086 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,7 +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.
      */

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


[14/19] httpcomponents-core git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/httpcomponents-core.git

Posted by gg...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/httpcomponents-core.git

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

Branch: refs/heads/master
Commit: d21d2172d79ddb9b4e1d5a3a24f4c4299e028fed
Parents: ef6bc7c fc53fdd
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 09:41:40 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 09:41:40 2018 -0600

----------------------------------------------------------------------

----------------------------------------------------------------------



[05/19] httpcomponents-core git commit: Remove Unnecessary semicolon.

Posted by gg...@apache.org.
Remove Unnecessary semicolon.

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

Branch: refs/heads/master
Commit: a983bb8182d04ed837858f8788d82ce4dd2d3149
Parents: b26e6a3
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 09:00:20 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 09:00:20 2018 -0600

----------------------------------------------------------------------
 .../src/main/java/org/apache/hc/core5/http2/config/H2Param.java    | 2 +-
 .../src/main/java/org/apache/hc/core5/http2/config/H2Setting.java  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


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


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

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

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

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

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

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

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

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

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

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

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d619748c/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
index 2417b7d..97bdf49 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
@@ -61,9 +61,8 @@ class TimeoutByteArrayInputStream extends InputStream {
         final int v = this.buf[this.pos++] & 0xff;
         if (v != 0) {
             return v;
-        } else {
-            throw new InterruptedIOException("Timeout");
         }
+        throw new InterruptedIOException("Timeout");
     }
 
     @Override
@@ -92,10 +91,9 @@ class TimeoutByteArrayInputStream extends InputStream {
             final int v = this.buf[this.pos] & 0xff;
             if (v == 0) {
                 return i;
-            } else {
-                b[off + i] = (byte) v;
-                this.pos++;
             }
+            b[off + i] = (byte) v;
+            this.pos++;
         }
         return chunk;
     }

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

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

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

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

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

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

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

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

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

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


[09/19] 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()'.

Posted by gg...@apache.org.
* 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


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

Posted by gg...@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/b26e6a3e
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/b26e6a3e
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/b26e6a3e

Branch: refs/heads/master
Commit: b26e6a3e9df0adf25301fc1325200f7dbc822cbf
Parents: 0124d11
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 08:42:13 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 08:42:13 2018 -0600

----------------------------------------------------------------------
 .../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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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/b26e6a3e/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


[18/19] httpcomponents-core git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/httpcomponents-core.git

Posted by gg...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/httpcomponents-core.git

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

Branch: refs/heads/master
Commit: 24c351c4fa2014e3a6d0b686a83c0777e37f1609
Parents: c7b389f 27ee7a1
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 14:01:49 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 14:01:49 2018 -0600

----------------------------------------------------------------------

----------------------------------------------------------------------



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

Posted by gg...@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);
         }


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

Posted by gg...@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/be7fb8f6
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/be7fb8f6
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/be7fb8f6

Branch: refs/heads/master
Commit: be7fb8f672237884691952390a9bae7c07742700
Parents: a983bb8
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 09:00:58 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 09:00:58 2018 -0600

----------------------------------------------------------------------
 .../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 +-
 13 files changed, 60 insertions(+), 105 deletions(-)
----------------------------------------------------------------------


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


[17/19] httpcomponents-core git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/httpcomponents-core.git

Posted by gg...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/httpcomponents-core.git

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

Branch: refs/heads/master
Commit: c7b389fb8acea5c3b50501a67c97c40fef41a1ec
Parents: d21d217 d619748
Author: Gary Gregory <gg...@apache.org>
Authored: Sat Aug 4 10:44:11 2018 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Sat Aug 4 10:44:11 2018 -0600

----------------------------------------------------------------------

----------------------------------------------------------------------