You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by mi...@apache.org on 2019/12/26 15:02:59 UTC

[httpcomponents-core] branch consistency-fixes updated (bada135 -> c4346a7)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch consistency-fixes
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git.


 discard bada135  Throw NullPointerException for null arguments in Args
 discard 198cb6c  Use Args for argument check
 discard 09781aa  Use language-stable exception messages
 discard f7f1d48  Use HttpStatus.SC_OK instead of literal 200
 discard b8615d0  Fix awkward exception message
 discard 21fb5c1  Replace LangUtils with Objects
     new c74a55e  Fix awkward exception message
     new fbf0845  Use HttpStatus.SC_OK instead of literal 200
     new 01a66ae  Use language-stable exception messages
     new dc6b3e5  Use Args for argument check
     new 4df0462  Throw NullPointerException for null arguments in Args
     new c4346a7  Replace LangUtils with Objects

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (bada135)
            \
             N -- N -- N   refs/heads/consistency-fixes (c4346a7)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[httpcomponents-core] 01/06: Fix awkward exception message

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch consistency-fixes
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit c74a55eb55ef40aa353d4979215837380cce9992
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Wed Dec 25 16:39:01 2019 +0100

    Fix awkward exception message
---
 .../src/main/java/org/apache/hc/core5/http/message/HeaderGroup.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/message/HeaderGroup.java b/httpcore5/src/main/java/org/apache/hc/core5/http/message/HeaderGroup.java
index 9cf09fb..a637a6d 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/message/HeaderGroup.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/message/HeaderGroup.java
@@ -263,7 +263,7 @@ public class HeaderGroup implements MessageHeaders, Serializable {
             }
         }
         if (count > 1) {
-            throw new ProtocolException("Multiple headers '%s'' found", name);
+            throw new ProtocolException("multiple '%s' headers found", name);
         }
         return singleHeader;
     }


[httpcomponents-core] 03/06: Use language-stable exception messages

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch consistency-fixes
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit 01a66ae5707c5f9b3e775343ecea1f12935f392d
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Wed Dec 25 16:44:05 2019 +0100

    Use language-stable exception messages
---
 .../apache/hc/core5/http/impl/io/ChunkedInputStream.java   |  2 +-
 .../hc/core5/http/impl/io/ContentLengthInputStream.java    |  4 ++--
 .../org/apache/hc/core5/http/impl/nio/ChunkDecoder.java    |  2 +-
 .../hc/core5/http/impl/nio/LengthDelimitedDecoder.java     |  6 +++---
 .../hc/core5/reactor/SingleCoreListeningIOReactor.java     |  2 +-
 httpcore5/src/main/java/org/apache/hc/core5/util/Args.java | 12 ++++++------
 .../src/main/java/org/apache/hc/core5/util/TimeValue.java  | 14 ++++++--------
 .../test/java/org/apache/hc/core5/util/TestTimeValue.java  | 10 +++++-----
 .../test/java/org/apache/hc/core5/util/TestTimeout.java    | 10 +++++-----
 .../apache/hc/core5/util/TestTimeoutValueException.java    |  2 +-
 10 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java
index 5bcc702..6effb56 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ChunkedInputStream.java
@@ -193,7 +193,7 @@ public class ChunkedInputStream extends InputStream {
             return bytesRead;
         }
         eof = true;
-        throw new TruncatedChunkException("Truncated chunk (expected size: %,d; actual size: %,d)",
+        throw new TruncatedChunkException("Truncated chunk (expected size: %d; actual size: %d)",
                         chunkSize, pos);
     }
 
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java
index b544971..d01495a 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/ContentLengthInputStream.java
@@ -135,7 +135,7 @@ public class ContentLengthInputStream extends InputStream {
         if (b == -1) {
             if (pos < contentLength) {
                 throw new ConnectionClosedException(
-                                "Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
+                                "Premature end of Content-Length delimited message body (expected: %d; received: %d)",
                                 contentLength, pos);
             }
         } else {
@@ -173,7 +173,7 @@ public class ContentLengthInputStream extends InputStream {
         final int count = this.buffer.read(b, off, chunk, this.inputStream);
         if (count == -1 && pos < contentLength) {
             throw new ConnectionClosedException(
-                            "Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
+                            "Premature end of Content-Length delimited message body (expected: %d; received: %d)",
                             contentLength, pos);
         }
         if (count > 0) {
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkDecoder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkDecoder.java
index 7411c0c..58c32a7 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkDecoder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ChunkDecoder.java
@@ -224,7 +224,7 @@ public class ChunkDecoder extends AbstractContentDecoder {
                         this.state = State.COMPLETED;
                         setCompleted();
                         throw new TruncatedChunkException(
-                                        "Truncated chunk (expected size: %,d; actual size: %,d)",
+                                        "Truncated chunk (expected size: %d; actual size: %d)",
                                         chunkSize, pos);
                     }
                 }
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/LengthDelimitedDecoder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/LengthDelimitedDecoder.java
index 46849b8..1a45075 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/LengthDelimitedDecoder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/LengthDelimitedDecoder.java
@@ -86,7 +86,7 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder implements Fi
             setCompleted();
             if (this.len < this.contentLength) {
                 throw new ConnectionClosedException(
-                                "Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
+                                "Premature end of Content-Length delimited message body (expected: %d; received: %d)",
                                 this.contentLength, this.len);
             }
         }
@@ -123,7 +123,7 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder implements Fi
         } else {
             if (this.channel.isOpen()) {
                 if (position > dst.size()) {
-                    throw new IOException(String.format("Position past end of file [%,d > %,d]",
+                    throw new IOException(String.format("Position past end of file [%d > %d]",
                                     position, dst.size()));
                 }
                 bytesRead = dst.transferFrom(this.channel, position, count < chunk ? count : chunk);
@@ -138,7 +138,7 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder implements Fi
             setCompleted();
             if (this.len < this.contentLength) {
                 throw new ConnectionClosedException(
-                                "Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
+                                "Premature end of Content-Length delimited message body (expected: %d; received: %d)",
                                 this.contentLength, this.len);
             }
         }
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 f70918c..18e7029 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
@@ -166,7 +166,7 @@ class SingleCoreListeningIOReactor extends AbstractSingleCoreIOReactor implement
                     socket.bind(address, this.reactorConfig.getBacklogSize());
                 } catch (final BindException ex) {
                     final BindException detailedEx = new BindException(
-                            String.format("Socket bind failure for socket %s, address=%s, BacklogSize=%,d: %s", socket,
+                            String.format("Socket bind failure for socket %s, address=%s, BacklogSize=%d: %s", socket,
                                     address, this.reactorConfig.getBacklogSize(), ex));
                     detailedEx.setStackTrace(ex.getStackTrace());
                     throw detailedEx;
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java b/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java
index b7867a0..4305ec7 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java
@@ -62,7 +62,7 @@ public class Args {
     public static int checkRange(final int value, final int lowInclusive, final int highInclusive,
                     final String message) {
         if (value < lowInclusive || value > highInclusive) {
-            throw illegalArgumentException("%s: %,d is out of range [%,d, %,d]", message, Integer.valueOf(value),
+            throw illegalArgumentException("%s: %d is out of range [%d, %d]", message, Integer.valueOf(value),
                             Integer.valueOf(lowInclusive), Integer.valueOf(highInclusive));
         }
         return value;
@@ -71,7 +71,7 @@ public class Args {
     public static long checkRange(final long value, final long lowInclusive, final long highInclusive,
                     final String message) {
         if (value < lowInclusive || value > highInclusive) {
-            throw illegalArgumentException("%s: %,d is out of range [%,d, %,d]", message, Long.valueOf(value),
+            throw illegalArgumentException("%s: %d is out of range [%d, %d]", message, Long.valueOf(value),
                             Long.valueOf(lowInclusive), Long.valueOf(highInclusive));
         }
         return value;
@@ -134,14 +134,14 @@ public class Args {
 
     public static int notNegative(final int n, final String name) {
         if (n < 0) {
-            throw illegalArgumentException("%s must not be negative: %,d", name, n);
+            throw illegalArgumentException("%s must not be negative: %d", name, n);
         }
         return n;
     }
 
     public static long notNegative(final long n, final String name) {
         if (n < 0) {
-            throw illegalArgumentException("%s must not be negative: %,d", name, n);
+            throw illegalArgumentException("%s must not be negative: %d", name, n);
         }
         return n;
     }
@@ -155,14 +155,14 @@ public class Args {
 
     public static int positive(final int n, final String name) {
         if (n <= 0) {
-            throw illegalArgumentException("%s must not be negative or zero: %,d", name, n);
+            throw illegalArgumentException("%s must not be negative or zero: %d", name, n);
         }
         return n;
     }
 
     public static long positive(final long n, final String name) {
         if (n <= 0) {
-            throw illegalArgumentException("%s must not be negative or zero: %,d", name, n);
+            throw illegalArgumentException("%s must not be negative or zero: %d", name, n);
         }
         return n;
     }
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java b/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
index 576d875..cb93f3a 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
@@ -27,7 +27,6 @@
 
 package org.apache.hc.core5.util;
 
-import java.text.NumberFormat;
 import java.text.ParseException;
 import java.util.Locale;
 import java.util.concurrent.TimeUnit;
@@ -178,14 +177,14 @@ public class TimeValue implements Comparable<TimeValue> {
     }
 
     /**
-     * Parses a TimeValue in the format {@code <Long><SPACE><TimeUnit>}, for example {@code "1,200 MILLISECONDS"}.
+     * Parses a TimeValue in the format {@code <Long><SPACE><TimeUnit>}, for example {@code "1200 MILLISECONDS"}.
      * <p>
      * Parses:
      * </p>
      * <ul>
-     * <li>{@code "1,200 MILLISECONDS"} Note the comma.</li>
-     * <li>{@code "1200 MILLISECONDS"} Without a comma.</li>
-     * <li>{@code " 1,200 MILLISECONDS "} Spaces are ignored.</li>
+     * <li>{@code "1200 MILLISECONDS"}.</li>
+     * <li>{@code " 1200 MILLISECONDS "}, spaces are ignored.</li>
+     * <li>{@code "1 MINUTE"}, singular units.</li>
      * <li></li>
      * </ul>
      *
@@ -195,7 +194,6 @@ public class TimeValue implements Comparable<TimeValue> {
      * @throws ParseException if the number cannot be parsed
      */
     public static TimeValue parse(final String value) throws ParseException {
-        final Locale locale = Locale.ROOT;
         final String split[] = value.trim().split("\\s+");
         if (split.length < 2) {
             throw new IllegalArgumentException(
@@ -204,7 +202,7 @@ public class TimeValue implements Comparable<TimeValue> {
         final String clean0 = split[0].trim();
         final String clean1 = split[1].trim().toUpperCase(Locale.ROOT);
         final String timeUnitStr = clean1.endsWith("S") ? clean1 : clean1 + "S";
-        return TimeValue.of(NumberFormat.getInstance(locale).parse(clean0).longValue(), TimeUnit.valueOf(timeUnitStr));
+        return TimeValue.of(Long.parseLong(clean0), TimeUnit.valueOf(timeUnitStr));
     }
 
     private final long duration;
@@ -376,7 +374,7 @@ public class TimeValue implements Comparable<TimeValue> {
 
     @Override
     public String toString() {
-        return String.format(Locale.ROOT, "%,d %s", duration, timeUnit);
+        return String.format("%d %s", duration, timeUnit);
     }
 
     public Timeout toTimeout() {
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
index 38c3b3f..a4a6619 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
@@ -247,18 +247,18 @@ public class TestTimeValue {
 
     @Test
     public void testToString() {
-        Assert.assertEquals("9,223,372,036,854,775,807 SECONDS", TimeValue.ofSeconds(Long.MAX_VALUE).toString());
+        Assert.assertEquals("9223372036854775807 SECONDS", TimeValue.ofSeconds(Long.MAX_VALUE).toString());
         Assert.assertEquals("0 MILLISECONDS", TimeValue.ZERO_MILLISECONDS.toString());
     }
 
     @Test
     public void testFromString() throws ParseException {
-        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9,223,372,036,854,775,807 SECONDS"));
+        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9223372036854775807 SECONDS"));
         Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9223372036854775807 SECONDS"));
         Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse(" 9223372036854775807 SECONDS "));
-        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9,223,372,036,854,775,807 Seconds"));
-        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9,223,372,036,854,775,807  Seconds"));
-        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9,223,372,036,854,775,807\tSeconds"));
+        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9223372036854775807 Seconds"));
+        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9223372036854775807  Seconds"));
+        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9223372036854775807\tSeconds"));
         Assert.assertEquals(TimeValue.ZERO_MILLISECONDS, TimeValue.parse("0 MILLISECONDS"));
         Assert.assertEquals(TimeValue.ofMilliseconds(1), TimeValue.parse("1 MILLISECOND"));
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeout.java b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeout.java
index a907c79..80f92c5 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeout.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeout.java
@@ -147,16 +147,16 @@ public class TestTimeout {
 
     @Test
     public void testToString() {
-        Assert.assertEquals("9,223,372,036,854,775,807 SECONDS", Timeout.ofSeconds(Long.MAX_VALUE).toString());
+        Assert.assertEquals("9223372036854775807 SECONDS", Timeout.ofSeconds(Long.MAX_VALUE).toString());
         Assert.assertEquals("0 MILLISECONDS", Timeout.ZERO_MILLISECONDS.toString());
     }
 
     @Test
     public void testFromString() throws ParseException {
-        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807 SECONDS"));
-        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807 Seconds"));
-        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807  Seconds"));
-        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807\tSeconds"));
+        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9223372036854775807 SECONDS"));
+        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9223372036854775807 Seconds"));
+        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9223372036854775807  Seconds"));
+        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9223372036854775807\tSeconds"));
         Assert.assertEquals(Timeout.ZERO_MILLISECONDS, Timeout.parse("0 MILLISECONDS"));
     }
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeoutValueException.java b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeoutValueException.java
index 265a649..0ba4e9b 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeoutValueException.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeoutValueException.java
@@ -34,7 +34,7 @@ public class TestTimeoutValueException {
 
     @Test
     public void testMessage() {
-        Assert.assertEquals("Timeout deadline: 1,000 MILLISECONDS, actual: 2,000 MILLISECONDS",
+        Assert.assertEquals("Timeout deadline: 1000 MILLISECONDS, actual: 2000 MILLISECONDS",
                 TimeoutValueException.fromMilliseconds(1000, 2000).getMessage());
     }
 }


[httpcomponents-core] 06/06: Replace LangUtils with Objects

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch consistency-fixes
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit c4346a716cd630e35326c5e82c6abf2fb9616a59
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Wed Dec 25 16:38:10 2019 +0100

    Replace LangUtils with Objects
---
 .../apache/hc/core5/http2/hpack/HPackEncoder.java  |  4 +-
 .../java/org/apache/hc/core5/http/HttpHost.java    | 11 +--
 .../hc/core5/http/message/BasicNameValuePair.java  |  9 +-
 .../apache/hc/core5/http/message/HeaderGroup.java  |  4 +-
 .../main/java/org/apache/hc/core5/net/Host.java    |  7 +-
 .../java/org/apache/hc/core5/net/URIAuthority.java | 12 +--
 .../java/org/apache/hc/core5/pool/LaxConnPool.java |  4 +-
 .../org/apache/hc/core5/pool/StrictConnPool.java   |  4 +-
 .../java/org/apache/hc/core5/util/LangUtils.java   | 98 ----------------------
 .../java/org/apache/hc/core5/util/TimeValue.java   |  8 +-
 .../org/apache/hc/core5/util/TestLangUtils.java    | 88 -------------------
 11 files changed, 23 insertions(+), 226 deletions(-)

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 dc3179d..28ae747 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
@@ -35,12 +35,12 @@ import java.nio.charset.CharsetEncoder;
 import java.nio.charset.CoderResult;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
+import java.util.Objects;
 
 import org.apache.hc.core5.annotation.Internal;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.ByteArrayBuffer;
-import org.apache.hc.core5.util.LangUtils;
 
 /**
  * HPACK encoder.
@@ -252,7 +252,7 @@ public final class HPackEncoder {
         }
         for (int i = 0; i < entries.size(); i++) {
             final HPackEntry entry = entries.get(i);
-            if (LangUtils.equals(value, entry.getHeader().getValue())) {
+            if (Objects.equals(value, entry.getHeader().getValue())) {
                 return entry.getIndex();
             }
         }
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java b/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
index a58f440..bcd5e1f 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/HttpHost.java
@@ -32,6 +32,7 @@ import java.net.InetAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Locale;
+import java.util.Objects;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
@@ -39,7 +40,6 @@ import org.apache.hc.core5.net.NamedEndpoint;
 import org.apache.hc.core5.net.Ports;
 import org.apache.hc.core5.net.URIAuthority;
 import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.LangUtils;
 import org.apache.hc.core5.util.TextUtils;
 
 /**
@@ -375,7 +375,7 @@ public final class HttpHost implements NamedEndpoint, Serializable {
             return this.lcHostname.equals(that.lcHostname)
                 && this.port == that.port
                 && this.schemeName.equals(that.schemeName)
-                && LangUtils.equals(this.address, that.address);
+                && Objects.equals(this.address, that.address);
         }
         return false;
     }
@@ -385,12 +385,7 @@ public final class HttpHost implements NamedEndpoint, Serializable {
      */
     @Override
     public int hashCode() {
-        int hash = LangUtils.HASH_SEED;
-        hash = LangUtils.hashCode(hash, this.lcHostname);
-        hash = LangUtils.hashCode(hash, this.port);
-        hash = LangUtils.hashCode(hash, this.schemeName);
-        hash = LangUtils.hashCode(hash, address);
-        return hash;
+        return Objects.hash(lcHostname, port, schemeName, address);
     }
 
 }
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicNameValuePair.java b/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicNameValuePair.java
index 28e6407..fd0eb35 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicNameValuePair.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/message/BasicNameValuePair.java
@@ -29,12 +29,12 @@ package org.apache.hc.core5.http.message;
 
 import java.io.Serializable;
 import java.util.Locale;
+import java.util.Objects;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.http.NameValuePair;
 import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.LangUtils;
 
 /**
  * Basic implementation of {@link NameValuePair}.
@@ -93,17 +93,14 @@ public class BasicNameValuePair implements NameValuePair, Serializable {
         }
         if (obj instanceof BasicNameValuePair) {
             final BasicNameValuePair that = (BasicNameValuePair) obj;
-            return this.name.equalsIgnoreCase(that.name) && LangUtils.equals(this.value, that.value);
+            return this.name.equalsIgnoreCase(that.name) && Objects.equals(this.value, that.value);
         }
         return false;
     }
 
     @Override
     public int hashCode() {
-        int hash = LangUtils.HASH_SEED;
-        hash = LangUtils.hashCode(hash, this.name.toLowerCase(Locale.ROOT));
-        hash = LangUtils.hashCode(hash, this.value);
-        return hash;
+        return Objects.hash(name.toLowerCase(Locale.ROOT), value);
     }
 
 }
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/message/HeaderGroup.java b/httpcore5/src/main/java/org/apache/hc/core5/http/message/HeaderGroup.java
index a637a6d..fe44776 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/message/HeaderGroup.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/message/HeaderGroup.java
@@ -33,12 +33,12 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
+import java.util.Objects;
 
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.MessageHeaders;
 import org.apache.hc.core5.http.ProtocolException;
 import org.apache.hc.core5.util.CharArrayBuffer;
-import org.apache.hc.core5.util.LangUtils;
 
 /**
  * A class for combining a set of headers. This class allows for multiple headers with the same name
@@ -104,7 +104,7 @@ public class HeaderGroup implements MessageHeaders, Serializable {
 
     private boolean headerEquals(final Header header1, final Header header2) {
         return header2 == header1 || header2.getName().equalsIgnoreCase(header1.getName())
-                && LangUtils.equals(header1.getValue(), header2.getValue());
+                && Objects.equals(header1.getValue(), header2.getValue());
     }
 
     /**
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 f03b790..7a0b64f 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
@@ -29,11 +29,11 @@ package org.apache.hc.core5.net;
 import java.io.Serializable;
 import java.net.URISyntaxException;
 import java.util.Locale;
+import java.util.Objects;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.LangUtils;
 import org.apache.hc.core5.util.TextUtils;
 
 /**
@@ -100,10 +100,7 @@ public final class Host implements NamedEndpoint, Serializable {
 
     @Override
     public int hashCode() {
-        int hash = LangUtils.HASH_SEED;
-        hash = LangUtils.hashCode(hash, this.lcName);
-        hash = LangUtils.hashCode(hash, this.port);
-        return hash;
+        return Objects.hash(lcName, port);
     }
 
     @Override
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java b/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
index 01feb0f..2d674f9 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
@@ -30,11 +30,11 @@ package org.apache.hc.core5.net;
 import java.io.Serializable;
 import java.net.URISyntaxException;
 import java.util.Locale;
+import java.util.Objects;
 
 import org.apache.hc.core5.annotation.Contract;
 import org.apache.hc.core5.annotation.ThreadingBehavior;
 import org.apache.hc.core5.util.Args;
-import org.apache.hc.core5.util.LangUtils;
 import org.apache.hc.core5.util.TextUtils;
 
 /**
@@ -159,8 +159,8 @@ public final class URIAuthority implements NamedEndpoint, Serializable {
         }
         if (obj instanceof URIAuthority) {
             final URIAuthority that = (URIAuthority) obj;
-            return LangUtils.equals(this.userInfo, that.userInfo) &&
-                    LangUtils.equals(this.hostname, that.hostname) &&
+            return Objects.equals(this.userInfo, that.userInfo) &&
+                    Objects.equals(this.hostname, that.hostname) &&
                     this.port == that.port;
         }
         return false;
@@ -168,11 +168,7 @@ public final class URIAuthority implements NamedEndpoint, Serializable {
 
     @Override
     public int hashCode() {
-        int hash = LangUtils.HASH_SEED;
-        hash = LangUtils.hashCode(hash, userInfo);
-        hash = LangUtils.hashCode(hash, hostname);
-        hash = LangUtils.hashCode(hash, port);
-        return hash;
+        return Objects.hash(userInfo, hostname, port);
     }
 
 }
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/pool/LaxConnPool.java b/httpcore5/src/main/java/org/apache/hc/core5/pool/LaxConnPool.java
index 82d2119..3aa6094 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/pool/LaxConnPool.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/pool/LaxConnPool.java
@@ -29,6 +29,7 @@ package org.apache.hc.core5.pool;
 import java.util.Deque;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedDeque;
@@ -52,7 +53,6 @@ import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.Asserts;
 import org.apache.hc.core5.util.Deadline;
 import org.apache.hc.core5.util.DeadlineTimeoutException;
-import org.apache.hc.core5.util.LangUtils;
 import org.apache.hc.core5.util.TimeValue;
 import org.apache.hc.core5.util.Timeout;
 
@@ -452,7 +452,7 @@ public class LaxConnPool<T, C extends ModalCloseable> implements ManagedConnPool
                     if (entry.getExpiryDeadline().isExpired()) {
                         entry.discardConnection(CloseMode.GRACEFUL);
                     }
-                    if (!LangUtils.equals(entry.getState(), state)) {
+                    if (!Objects.equals(entry.getState(), state)) {
                         entry.discardConnection(CloseMode.GRACEFUL);
                     }
                     return entry;
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java b/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
index dfd5b36..0765e56 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
@@ -32,6 +32,7 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.ListIterator;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.Future;
@@ -50,7 +51,6 @@ import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.Asserts;
 import org.apache.hc.core5.util.Deadline;
 import org.apache.hc.core5.util.DeadlineTimeoutException;
-import org.apache.hc.core5.util.LangUtils;
 import org.apache.hc.core5.util.TimeValue;
 import org.apache.hc.core5.util.Timeout;
 
@@ -517,7 +517,7 @@ public class StrictConnPool<T, C extends ModalCloseable> implements ManagedConnP
             final PerRoutePool<T, C> pool = getPool(route);
             int pendingCount = 0;
             for (final LeaseRequest<T, C> request: leasingRequests) {
-                if (LangUtils.equals(route, request.getRoute())) {
+                if (Objects.equals(route, request.getRoute())) {
                     pendingCount++;
                 }
             }
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/LangUtils.java b/httpcore5/src/main/java/org/apache/hc/core5/util/LangUtils.java
deleted file mode 100644
index f38d32d..0000000
--- a/httpcore5/src/main/java/org/apache/hc/core5/util/LangUtils.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.core5.util;
-
-/**
- * A set of utility methods to help produce consistent
- * {@link Object#equals equals} and {@link Object#hashCode hashCode} methods.
- *
- *
- * @since 4.0
- */
-public final class LangUtils {
-
-    public static final int HASH_SEED = 17;
-    public static final int HASH_OFFSET = 37;
-
-    /** Disabled default constructor. */
-    private LangUtils() {
-    }
-
-    public static int hashCode(final int seed, final int hashcode) {
-        return seed * HASH_OFFSET + hashcode;
-    }
-
-    public static int hashCode(final int seed, final boolean b) {
-        return hashCode(seed, b ? 1 : 0);
-    }
-
-    public static int hashCode(final int seed, final Object obj) {
-        return hashCode(seed, obj != null ? obj.hashCode() : 0);
-    }
-
-    /**
-     * Check if two objects are equal.
-     *
-     * @param obj1 first object to compare, may be {@code null}
-     * @param obj2 second object to compare, may be {@code null}
-     * @return {@code true} if the objects are equal or both null
-     */
-    public static boolean equals(final Object obj1, final Object obj2) {
-        return obj1 == null ? obj2 == null : obj1.equals(obj2);
-    }
-
-    /**
-     * Check if two object arrays are equal.
-     * <ul>
-     * <li>If both parameters are null, return {@code true}</li>
-     * <li>If one parameter is null, return {@code false}</li>
-     * <li>If the array lengths are different, return {@code false}</li>
-     * <li>Compare array elements using .equals(); return {@code false} if any comparisons fail.</li>
-     * <li>Return {@code true}</li>
-     * </ul>
-     *
-     * @param a1 first array to compare, may be {@code null}
-     * @param a2 second array to compare, may be {@code null}
-     * @return {@code true} if the arrays are equal or both null
-     */
-    public static boolean equals(final Object[] a1, final Object[] a2) {
-        if (a1 == null) {
-            return a2 == null;
-        }
-        if (a2 != null && a1.length == a2.length) {
-            for (int i = 0; i < a1.length; i++) {
-                if (!equals(a1[i], a2[i])) {
-                    return false;
-                }
-            }
-            return true;
-        }
-        return false;
-    }
-
-}
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java b/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
index cb93f3a..240d2a0 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
@@ -29,6 +29,7 @@ package org.apache.hc.core5.util;
 
 import java.text.ParseException;
 import java.util.Locale;
+import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.hc.core5.annotation.Contract;
@@ -227,7 +228,7 @@ public class TimeValue implements Comparable<TimeValue> {
         }
         if (obj instanceof TimeValue) {
             final TimeValue that = (TimeValue) obj;
-            return this.duration == that.duration && LangUtils.equals(this.timeUnit, that.timeUnit);
+            return this.duration == that.duration && Objects.equals(this.timeUnit, that.timeUnit);
         }
         return false;
     }
@@ -271,10 +272,7 @@ public class TimeValue implements Comparable<TimeValue> {
 
     @Override
     public int hashCode() {
-        int hash = LangUtils.HASH_SEED;
-        hash = LangUtils.hashCode(hash, duration);
-        hash = LangUtils.hashCode(hash, timeUnit);
-        return hash;
+        return Objects.hash(duration, timeUnit);
     }
 
     public TimeValue min(final TimeValue other) {
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/util/TestLangUtils.java b/httpcore5/src/test/java/org/apache/hc/core5/util/TestLangUtils.java
deleted file mode 100644
index b9aa571..0000000
--- a/httpcore5/src/test/java/org/apache/hc/core5/util/TestLangUtils.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.hc.core5.util;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Unit tests for {@link LangUtils}.
- *
- */
-public class TestLangUtils {
-
-    @Test
-    public void testBasicHash() {
-        final Integer i = Integer.valueOf(1234);
-        final int h1 = LangUtils.hashCode(LangUtils.HASH_SEED, i.hashCode());
-        final int h2 = LangUtils.hashCode(LangUtils.HASH_SEED, i);
-        Assert.assertTrue(h1 == h2);
-    }
-
-    @Test
-    public void testNullObjectHash() {
-        final int h1 = LangUtils.hashCode(LangUtils.HASH_SEED, null);
-        final int h2 = LangUtils.hashCode(LangUtils.HASH_SEED, 0);
-        Assert.assertTrue(h1 == h2);
-    }
-
-    @Test
-    public void testBooleanHash() {
-        final int h1 = LangUtils.hashCode(LangUtils.HASH_SEED, true);
-        final int h2 = LangUtils.hashCode(LangUtils.HASH_SEED, false);
-        final int h3 = LangUtils.hashCode(LangUtils.HASH_SEED, true);
-        final int h4 = LangUtils.hashCode(LangUtils.HASH_SEED, false);
-        Assert.assertTrue(h1 != h2);
-        Assert.assertTrue(h1 == h3);
-        Assert.assertTrue(h2 == h4);
-    }
-
-    @Test
-    public void testBasicEquality() {
-        Assert.assertTrue(LangUtils.equals(null, null));
-        Assert.assertFalse(LangUtils.equals(null, "abc"));
-        Assert.assertFalse(LangUtils.equals("abc", null));
-        Assert.assertTrue(LangUtils.equals("abc", "abc"));
-    }
-
-    @Test
-    public void testArrayEquals() {
-        Assert.assertFalse(LangUtils.equals(null, new Object[] {}));
-        Assert.assertFalse(LangUtils.equals(new Object[] {}, null));
-        Assert.assertTrue(LangUtils.equals(new Object[] {}, new Object[] {}));
-        Assert.assertFalse(LangUtils.equals(
-                new Object[] {Integer.valueOf(1), Integer.valueOf(2)},
-                new Object[] {Integer.valueOf(1)}));
-        Assert.assertFalse(LangUtils.equals(
-                new Object[] {Integer.valueOf(1), Integer.valueOf(2)},
-                new Object[] {Integer.valueOf(1), Integer.valueOf(3)}));
-        Assert.assertTrue(LangUtils.equals(
-                new Object[] {Integer.valueOf(1), Integer.valueOf(2)},
-                new Object[] {Integer.valueOf(1), Integer.valueOf(2)}));
-    }
-}


[httpcomponents-core] 04/06: Use Args for argument check

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch consistency-fixes
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit dc6b3e5aa5520c7d70ba3a1db0f0f2262b87d4ec
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Wed Dec 25 16:46:22 2019 +0100

    Use Args for argument check
---
 .../java/org/apache/hc/core5/http/message/ParserCursor.java    | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/message/ParserCursor.java b/httpcore5/src/main/java/org/apache/hc/core5/http/message/ParserCursor.java
index 70082dc..fcbd2e4 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/message/ParserCursor.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/message/ParserCursor.java
@@ -27,6 +27,8 @@
 
 package org.apache.hc.core5.http.message;
 
+import org.apache.hc.core5.util.Args;
+
 /**
  * This class represents a context of a parsing operation:
  * <ul>
@@ -44,12 +46,8 @@ public class ParserCursor {
 
     public ParserCursor(final int lowerBound, final int upperBound) {
         super();
-        if (lowerBound < 0) {
-            throw new IndexOutOfBoundsException("Lower bound cannot be negative");
-        }
-        if (lowerBound > upperBound) {
-            throw new IndexOutOfBoundsException("Lower bound cannot be greater then upper bound");
-        }
+        Args.notNegative(lowerBound, "lowerBound");
+        Args.check(lowerBound <= upperBound, "lowerBound cannot be greater than upperBound");
         this.lowerBound = lowerBound;
         this.upperBound = upperBound;
         this.pos = lowerBound;


[httpcomponents-core] 05/06: Throw NullPointerException for null arguments in Args

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch consistency-fixes
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit 4df046258ebbb2da6a5a66c24e656f6229516710
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Wed Dec 25 17:43:37 2019 +0100

    Throw NullPointerException for null arguments in Args
    
    The common approach for the past years have been to throw NPE if a null
    argument has been passed. This mimics the behavior of
    Objects#requireNonNull().
---
 .../main/java/org/apache/hc/core5/util/Args.java   | 14 +++----
 .../org/apache/hc/core5/http/TestContentType.java  |  4 +-
 .../org/apache/hc/core5/http/TestHttpHost.java     |  8 ++--
 .../impl/TestDefaultConnectionReuseStrategy.java   |  4 +-
 .../http/impl/io/TestHttpRequestExecutor.java      | 36 ++++++++--------
 .../hc/core5/http/impl/io/TestHttpService.java     |  4 +-
 .../hc/core5/http/impl/nio/TestChunkDecoder.java   | 14 +++----
 .../hc/core5/http/impl/nio/TestChunkEncoder.java   | 12 +++---
 .../core5/http/impl/nio/TestIdentityDecoder.java   | 16 ++++----
 .../core5/http/impl/nio/TestIdentityEncoder.java   | 12 +++---
 .../http/impl/nio/TestLengthDelimitedDecoder.java  | 16 ++++----
 .../http/impl/nio/TestLengthDelimitedEncoder.java  | 12 +++---
 .../http/io/entity/TestBufferedHttpEntity.java     | 12 +++---
 .../core5/http/io/entity/TestByteArrayEntity.java  | 10 ++---
 .../core5/http/io/entity/TestByteBufferEntity.java |  4 +-
 .../hc/core5/http/io/entity/TestEntityUtils.java   |  6 +--
 .../hc/core5/http/io/entity/TestFileEntity.java    | 10 ++---
 .../http/io/entity/TestHttpEntityWrapper.java      |  8 ++--
 .../http/io/entity/TestInputStreamEntity.java      |  6 +--
 .../http/io/entity/TestSerializableEntity.java     |  4 +-
 .../hc/core5/http/io/entity/TestStringEntity.java  | 10 ++---
 .../hc/core5/http/message/TestBasicHeader.java     |  4 +-
 .../http/message/TestBasicHeaderIterator.java      |  2 +-
 .../message/TestBasicHeaderValueFormatter.java     | 32 +++++++--------
 .../core5/http/message/TestBasicLineFormatter.java | 24 +++++------
 .../hc/core5/http/message/TestBasicMessages.java   |  4 +-
 .../core5/http/message/TestBasicTokenIterator.java |  2 +-
 .../apache/hc/core5/http/message/TestHeader.java   |  4 +-
 .../hc/core5/http/message/TestHeaderElement.java   |  8 ++--
 .../hc/core5/http/message/TestNameValuePair.java   |  4 +-
 .../http/protocol/TestHttpExecutionContext.java    | 12 +++---
 .../http/protocol/TestStandardInterceptors.java    | 48 +++++++++++-----------
 .../core5/http/protocol/TestUriPatternMatcher.java |  6 +--
 .../protocol/TestUriPatternOrderedMatcher.java     |  6 +--
 .../core5/http/protocol/TestUriRegexMatcher.java   |  6 +--
 .../java/org/apache/hc/core5/net/TestHost.java     |  4 +-
 .../org/apache/hc/core5/pool/TestLaxConnPool.java  | 12 +++---
 .../org/apache/hc/core5/pool/TestPoolEntry.java    |  6 +--
 .../apache/hc/core5/pool/TestStrictConnPool.java   | 14 +++----
 .../java/org/apache/hc/core5/util/TestArgs.java    |  8 ++--
 40 files changed, 214 insertions(+), 214 deletions(-)

diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java b/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java
index 4305ec7..0ee17b6 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/util/Args.java
@@ -79,7 +79,7 @@ public class Args {
 
     public static <T extends CharSequence> T containsNoBlanks(final T argument, final String name) {
         if (argument == null) {
-            throw illegalArgumentExceptionNotNull(name);
+            throw NullPointerException(name);
         }
         if (argument.length() == 0) {
             throw illegalArgumentExceptionNotEmpty(name);
@@ -98,13 +98,13 @@ public class Args {
         return new IllegalArgumentException(name + " must not be empty");
     }
 
-    private static IllegalArgumentException illegalArgumentExceptionNotNull(final String name) {
-        return new IllegalArgumentException(name + " must not be null");
+    private static NullPointerException NullPointerException(final String name) {
+        return new NullPointerException(name + " must not be null");
     }
 
     public static <T extends CharSequence> T notBlank(final T argument, final String name) {
         if (argument == null) {
-            throw illegalArgumentExceptionNotNull(name);
+            throw NullPointerException(name);
         }
         if (TextUtils.isBlank(argument)) {
             throw new IllegalArgumentException(name + " must not be blank");
@@ -114,7 +114,7 @@ public class Args {
 
     public static <T extends CharSequence> T notEmpty(final T argument, final String name) {
         if (argument == null) {
-            throw illegalArgumentExceptionNotNull(name);
+            throw NullPointerException(name);
         }
         if (TextUtils.isEmpty(argument)) {
             throw illegalArgumentExceptionNotEmpty(name);
@@ -124,7 +124,7 @@ public class Args {
 
     public static <E, T extends Collection<E>> T notEmpty(final T argument, final String name) {
         if (argument == null) {
-            throw illegalArgumentExceptionNotNull(name);
+            throw NullPointerException(name);
         }
         if (argument.isEmpty()) {
             throw illegalArgumentExceptionNotEmpty(name);
@@ -148,7 +148,7 @@ public class Args {
 
     public static <T> T notNull(final T argument, final String name) {
         if (argument == null) {
-            throw illegalArgumentExceptionNotNull(name);
+            throw NullPointerException(name);
         }
         return argument;
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/TestContentType.java b/httpcore5/src/test/java/org/apache/hc/core5/http/TestContentType.java
index afc6f7d..e1348d9 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/TestContentType.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/TestContentType.java
@@ -83,8 +83,8 @@ public class TestContentType {
     public void testCreateInvalidInput() throws Exception {
         try {
             ContentType.create(null, (String) null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
index 1fa99a4..54019d1 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpHost.java
@@ -68,8 +68,8 @@ public class TestHttpHost {
         Assert.assertEquals("https", host5.getSchemeName());
         try {
             new HttpHost(null, (String) null, -1);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException expected) {
         }
         try {
             new HttpHost(null, "   ", -1);
@@ -78,8 +78,8 @@ public class TestHttpHost {
         }
         try {
             new HttpHost(null, (InetAddress) null, -1);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException expected) {
         }
     }
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultConnectionReuseStrategy.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultConnectionReuseStrategy.java
index 0f5c3f6..9252f7b 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultConnectionReuseStrategy.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/TestDefaultConnectionReuseStrategy.java
@@ -55,8 +55,8 @@ public class TestDefaultConnectionReuseStrategy {
         context = new BasicHttpContext(null);
     }
 
-    @Test(expected=IllegalArgumentException.class)
-    public void testIllegalResponseArg() throws Exception {
+    @Test(expected=NullPointerException.class)
+    public void testInvalidResponseArg() throws Exception {
         reuseStrategy.keepAlive(null, null, this.context);
     }
 
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 2f4b098..4c15bef 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
@@ -61,58 +61,58 @@ public class TestHttpRequestExecutor {
         try {
             final HttpRequestExecutor executor = new HttpRequestExecutor();
             executor.execute(null, conn, context);
-            Assert.fail("IllegalArgumentException expected");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException expected");
+        } catch (final NullPointerException expected) {
         }
         try {
             final HttpRequestExecutor executor = new HttpRequestExecutor();
             executor.execute(request, null, context);
-            Assert.fail("IllegalArgumentException expected");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException expected");
+        } catch (final NullPointerException expected) {
         }
         try {
             final HttpRequestExecutor executor = new HttpRequestExecutor();
             executor.execute(request, conn, null);
-            Assert.fail("IllegalArgumentException expected");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException expected");
+        } catch (final NullPointerException expected) {
         }
 
         try {
             final HttpRequestExecutor executor = new HttpRequestExecutor();
             executor.preProcess(null, httprocessor, context);
-            Assert.fail("IllegalArgumentException expected");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException expected");
+        } catch (final NullPointerException expected) {
         }
         try {
             final HttpRequestExecutor executor = new HttpRequestExecutor();
             executor.preProcess(request, null, context);
-            Assert.fail("IllegalArgumentException expected");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException expected");
+        } catch (final NullPointerException expected) {
         }
         try {
             final HttpRequestExecutor executor = new HttpRequestExecutor();
             executor.preProcess(request, httprocessor, null);
-            Assert.fail("IllegalArgumentException expected");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException expected");
+        } catch (final NullPointerException expected) {
         }
 
         try {
             final HttpRequestExecutor executor = new HttpRequestExecutor();
             executor.postProcess(null, httprocessor, context);
-            Assert.fail("IllegalArgumentException expected");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException expected");
+        } catch (final NullPointerException expected) {
         }
         try {
             final HttpRequestExecutor executor = new HttpRequestExecutor();
             executor.postProcess(response, null, context);
-            Assert.fail("IllegalArgumentException expected");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException expected");
+        } catch (final NullPointerException expected) {
         }
         try {
             final HttpRequestExecutor executor = new HttpRequestExecutor();
             executor.postProcess(response, httprocessor, null);
-            Assert.fail("IllegalArgumentException expected");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException expected");
+        } catch (final NullPointerException expected) {
         }
     }
 
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 b3e50df..889efe7 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
@@ -101,8 +101,8 @@ public class TestHttpService {
                     handlerResolver,
                     connReuseStrategy,
                     responseFactory);
-            Assert.fail("IllegalArgumentException expected");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException expected");
+        } catch (final NullPointerException expected) {
         }
     }
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkDecoder.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkDecoder.java
index 61a2bb2..43a935a 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkDecoder.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkDecoder.java
@@ -552,25 +552,25 @@ public class TestChunkDecoder {
         final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, 0, StandardCharsets.US_ASCII);
         try {
             new ChunkDecoder(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
             new ChunkDecoder(channel, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
             new ChunkDecoder(channel, inbuf, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testInvalidInput() throws Exception {
         final String s = "10;key=\"value\"\r\n1234567890123456\r\n" +
                 "5\r\n12345\r\n5\r\n12345\r\n0\r\nFooter1 abcde\r\n\r\n";
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkEncoder.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkEncoder.java
index 921356d..4427276 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkEncoder.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestChunkEncoder.java
@@ -213,20 +213,20 @@ public class TestChunkEncoder {
 
         try {
             new ChunkEncoder(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
             new ChunkEncoder(channel, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
             new ChunkEncoder(channel, outbuf, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityDecoder.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityDecoder.java
index dd8af8e..0df1f1d 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityDecoder.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityDecoder.java
@@ -353,20 +353,20 @@ public class TestIdentityDecoder {
         final SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, 0, StandardCharsets.US_ASCII);
         try {
             new IdentityDecoder(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
             new IdentityDecoder(channel, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
             new IdentityDecoder(channel, inbuf, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
     }
@@ -383,8 +383,8 @@ public class TestIdentityDecoder {
 
         try {
             decoder.read(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityEncoder.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityEncoder.java
index fcba011..1c8c80b 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityEncoder.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestIdentityEncoder.java
@@ -130,20 +130,20 @@ public class TestIdentityEncoder {
 
         try {
             new IdentityEncoder(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
             new IdentityEncoder(channel, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
             new IdentityEncoder(channel, outbuf, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedDecoder.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedDecoder.java
index 3a0b96e..4ab31d4 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedDecoder.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedDecoder.java
@@ -499,20 +499,20 @@ public class TestLengthDelimitedDecoder {
         final BasicHttpTransportMetrics metrics = new BasicHttpTransportMetrics();
         try {
             new LengthDelimitedDecoder(null, null, null, 10);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
             new LengthDelimitedDecoder(channel, null, null, 10);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
             new LengthDelimitedDecoder(channel, inbuf, null, 10);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
@@ -536,8 +536,8 @@ public class TestLengthDelimitedDecoder {
 
         try {
             decoder.read(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedEncoder.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedEncoder.java
index 248eaac..be9ff4b 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedEncoder.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestLengthDelimitedEncoder.java
@@ -147,20 +147,20 @@ public class TestLengthDelimitedEncoder {
 
         try {
             new LengthDelimitedEncoder(null, null, null, 10);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
             new LengthDelimitedEncoder(channel, null, null, 10);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
             new LengthDelimitedEncoder(channel, outbuf, null, 10);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // ignore
         }
         try {
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestBufferedHttpEntity.java b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestBufferedHttpEntity.java
index 858b1c3..88c1eaa 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestBufferedHttpEntity.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestBufferedHttpEntity.java
@@ -74,8 +74,8 @@ public class TestBufferedHttpEntity {
     public void testIllegalConstructor() throws Exception {
         try {
             new BufferedHttpEntity(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -106,8 +106,8 @@ public class TestBufferedHttpEntity {
 
         try {
             bufentity.writeTo(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -138,8 +138,8 @@ public class TestBufferedHttpEntity {
 
         try {
             bufentity.writeTo(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestByteArrayEntity.java b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestByteArrayEntity.java
index 16971d9..55fc39c 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestByteArrayEntity.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestByteArrayEntity.java
@@ -61,7 +61,7 @@ public class TestByteArrayEntity {
         Assert.assertFalse(entity.isStreaming());
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testIllegalConstructorNullByteArray() throws Exception {
         new ByteArrayEntity(null, null);
     }
@@ -109,8 +109,8 @@ public class TestByteArrayEntity {
 
         try {
             entity.writeTo(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -142,8 +142,8 @@ public class TestByteArrayEntity {
 
         try {
             entity.writeTo(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestByteBufferEntity.java b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestByteBufferEntity.java
index 355a9f9..2c64d60 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestByteBufferEntity.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestByteBufferEntity.java
@@ -79,8 +79,8 @@ public class TestByteBufferEntity {
 
         try {
             httpentity.writeTo(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestEntityUtils.java b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestEntityUtils.java
index e8a3611..a9bd58d 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestEntityUtils.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestEntityUtils.java
@@ -49,7 +49,7 @@ import org.junit.Test;
  */
 public class TestEntityUtils {
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = NullPointerException.class)
     public void testNullEntityToByteArray() throws Exception {
         EntityUtils.toByteArray(null);
     }
@@ -90,8 +90,8 @@ public class TestEntityUtils {
     public void testNullEntityToString() throws Exception {
         try {
             EntityUtils.toString(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestFileEntity.java b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestFileEntity.java
index d28fb8c..1f20135 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestFileEntity.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestFileEntity.java
@@ -60,11 +60,11 @@ public class TestFileEntity {
     }
 
     @Test
-    public void testIllegalConstructor() throws Exception {
+    public void testNullConstructor() throws Exception {
         try {
             new FileEntity(null, ContentType.TEXT_PLAIN);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -97,8 +97,8 @@ public class TestFileEntity {
 
         try {
             httpentity.writeTo(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestHttpEntityWrapper.java b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestHttpEntityWrapper.java
index 3acdebf..ffafba3 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestHttpEntityWrapper.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestHttpEntityWrapper.java
@@ -58,8 +58,8 @@ public class TestHttpEntityWrapper {
     public void testIllegalConstructor() throws Exception {
         try {
             new HttpEntityWrapper(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -91,8 +91,8 @@ public class TestHttpEntityWrapper {
 
         try {
             wrapped.writeTo(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestInputStreamEntity.java b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestInputStreamEntity.java
index 3e5b441..04f937b 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestInputStreamEntity.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestInputStreamEntity.java
@@ -54,8 +54,8 @@ public class TestInputStreamEntity {
         Assert.assertTrue(entity.isStreaming());
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testIllegalConstructor() throws Exception {
+    @Test(expected = NullPointerException.class)
+    public void testNullConstructor() throws Exception {
         new InputStreamEntity(null, 0, null);
     }
 
@@ -119,7 +119,7 @@ public class TestInputStreamEntity {
         Assert.assertEquals(message, s);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = NullPointerException.class)
     public void testWriteToNull() throws Exception {
         final InputStreamEntity entity = new InputStreamEntity(EmptyInputStream.INSTANCE, 0, null);
         entity.writeTo(null);
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestSerializableEntity.java b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestSerializableEntity.java
index df81f5c..ac72cb5 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestSerializableEntity.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestSerializableEntity.java
@@ -82,8 +82,8 @@ public class TestSerializableEntity {
 
         try {
             httpentity.writeTo(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestStringEntity.java b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestStringEntity.java
index 93376e8..c7694ef 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestStringEntity.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/io/entity/TestStringEntity.java
@@ -53,11 +53,11 @@ public class TestStringEntity {
     }
 
     @Test
-    public void testIllegalConstructor() throws Exception {
+    public void testNullConstructor() throws Exception {
         try {
             new StringEntity(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -126,8 +126,8 @@ public class TestStringEntity {
 
         try {
             httpentity.writeTo(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHeader.java b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHeader.java
index 032ae9e..87fba77 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHeader.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHeader.java
@@ -46,8 +46,8 @@ public class TestBasicHeader {
     public void testInvalidName() {
         try {
             new BasicHeader(null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             //expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHeaderIterator.java b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHeaderIterator.java
index f30d2e0..0c57000 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHeaderIterator.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHeaderIterator.java
@@ -221,7 +221,7 @@ public class TestBasicHeaderIterator {
         try {
             hit = new BasicHeaderIterator(null, "whatever");
             Assert.fail("null headers not detected");
-        } catch (final IllegalArgumentException iax) {
+        } catch (final NullPointerException iax) {
             // expected
         }
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHeaderValueFormatter.java b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHeaderValueFormatter.java
index 284b61b..a3f7ed4 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHeaderValueFormatter.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicHeaderValueFormatter.java
@@ -171,51 +171,51 @@ public class TestBasicHeaderValueFormatter {
 
         try {
             this.formatter.formatNameValuePair(null, param, false);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             this.formatter.formatNameValuePair(buf, null, false);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             this.formatter.formatParameters(null, params, false);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             this.formatter.formatParameters(buf, null, false);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
 
         try {
             this.formatter.formatHeaderElement(null, element, false);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             this.formatter.formatHeaderElement(buf, null, false);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             this.formatter.formatElements(null, elements, false);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             this.formatter.formatElements(buf, null, false);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicLineFormatter.java b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicLineFormatter.java
index 105dd6c..9ce8f9c 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicLineFormatter.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicLineFormatter.java
@@ -69,14 +69,14 @@ public class TestBasicLineFormatter {
         final RequestLine requestline = new RequestLine(Method.GET.name(), "/stuff", HttpVersion.HTTP_1_1);
         try {
             this.formatter.formatRequestLine(null, requestline);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             this.formatter.formatRequestLine(buf, null);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -102,14 +102,14 @@ public class TestBasicLineFormatter {
         final StatusLine statusline = new StatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
         try {
             this.formatter.formatStatusLine(null, statusline);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             this.formatter.formatStatusLine(buf, null);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -133,14 +133,14 @@ public class TestBasicLineFormatter {
         final Header header = new BasicHeader("name", "value");
         try {
             this.formatter.formatHeader(null, header);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             this.formatter.formatHeader(buf, null);
-            Assert.fail("IllegalArgumentException should habe been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should habe been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicMessages.java b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicMessages.java
index 96c0cc1..760bf8c 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicMessages.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicMessages.java
@@ -88,8 +88,8 @@ public class TestBasicMessages {
 
         try {
             new BasicHttpRequest(Method.GET, (URI) null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicTokenIterator.java b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicTokenIterator.java
index a3c24b8..78ae150 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicTokenIterator.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestBasicTokenIterator.java
@@ -184,7 +184,7 @@ public class TestBasicTokenIterator {
         try {
             new BasicTokenIterator(null);
             Assert.fail("null argument not detected");
-        } catch (final IllegalArgumentException iax) {
+        } catch (final NullPointerException iax) {
             // expected
         }
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestHeader.java b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestHeader.java
index fb1146a..db2ae7f 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestHeader.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestHeader.java
@@ -59,8 +59,8 @@ public class TestHeader {
     public void testInvalidName() {
         try {
             new BasicHeader(null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             //expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestHeaderElement.java b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestHeaderElement.java
index 8de7a95..2193870 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestHeaderElement.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestHeaderElement.java
@@ -65,8 +65,8 @@ public class TestHeaderElement {
     public void testInvalidName() {
         try {
             new BasicHeaderElement(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             //expected
         }
     }
@@ -83,8 +83,8 @@ public class TestHeaderElement {
         Assert.assertNull(element.getParameterByName("param3"));
         try {
             element.getParameterByName(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             //expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestNameValuePair.java b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestNameValuePair.java
index a3729f4..1dcccca 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestNameValuePair.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/message/TestNameValuePair.java
@@ -48,8 +48,8 @@ public class TestNameValuePair {
     public void testInvalidName() {
         try {
             new BasicNameValuePair(null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             //expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestHttpExecutionContext.java b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestHttpExecutionContext.java
index d207277..58be10d 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestHttpExecutionContext.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestHttpExecutionContext.java
@@ -77,20 +77,20 @@ public class TestHttpExecutionContext {
         final HttpContext currentContext = new BasicHttpContext(null);
         try {
             currentContext.setAttribute(null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             currentContext.getAttribute(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             currentContext.removeAttribute(null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestStandardInterceptors.java b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestStandardInterceptors.java
index fa4332e..8ed0f1e 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestStandardInterceptors.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestStandardInterceptors.java
@@ -103,8 +103,8 @@ public class TestStandardInterceptors {
         final RequestConnControl interceptor = new RequestConnControl();
         try {
             interceptor.process(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -252,8 +252,8 @@ public class TestStandardInterceptors {
         final RequestContent interceptor = new RequestContent();
         try {
             interceptor.process(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -360,8 +360,8 @@ public class TestStandardInterceptors {
         final RequestExpectContinue interceptor = new RequestExpectContinue();
         try {
             interceptor.process(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -429,14 +429,14 @@ public class TestStandardInterceptors {
         final RequestTargetHost interceptor = new RequestTargetHost();
         try {
             interceptor.process(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             interceptor.process(new BasicClassicHttpRequest(Method.GET, "/"), null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -503,8 +503,8 @@ public class TestStandardInterceptors {
         final RequestUserAgent interceptor = new RequestUserAgent();
         try {
             interceptor.process(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -699,15 +699,15 @@ public class TestStandardInterceptors {
         final ResponseConnControl interceptor = new ResponseConnControl();
         try {
             interceptor.process(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
         try {
             final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
             interceptor.process(response, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -835,8 +835,8 @@ public class TestStandardInterceptors {
         final ResponseContent interceptor = new ResponseContent();
         try {
             interceptor.process(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -929,8 +929,8 @@ public class TestStandardInterceptors {
         final ResponseDate interceptor = new ResponseDate();
         try {
             interceptor.process(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -966,8 +966,8 @@ public class TestStandardInterceptors {
         final RequestDate interceptor = new RequestDate();
         try {
             interceptor.process(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
@@ -1010,8 +1010,8 @@ public class TestStandardInterceptors {
         final ResponseServer interceptor = new ResponseServer();
         try {
             interceptor.process(null, null, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException ex) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException ex) {
             // expected
         }
     }
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternMatcher.java b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternMatcher.java
index 1b14e5f..ac77aee 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternMatcher.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternMatcher.java
@@ -76,7 +76,7 @@ public class TestUriPatternMatcher {
         Assert.assertNull(h);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testRegisterNull() throws Exception {
         final LookupRegistry<Object> matcher = new UriPatternMatcher<>();
         matcher.register(null, null);
@@ -154,13 +154,13 @@ public class TestUriPatternMatcher {
         Assert.assertTrue(h1 == h);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testRegisterInvalidInput() throws Exception {
         final LookupRegistry<Object> matcher = new UriPatternMatcher<>();
         matcher.register(null, null);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testLookupInvalidInput() throws Exception {
         final LookupRegistry<Object> matcher = new UriPatternMatcher<>();
         matcher.lookup(null);
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternOrderedMatcher.java b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternOrderedMatcher.java
index a647209..f9b575a 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternOrderedMatcher.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriPatternOrderedMatcher.java
@@ -76,7 +76,7 @@ public class TestUriPatternOrderedMatcher {
         Assert.assertNull(h);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testRegisterNull() throws Exception {
         final LookupRegistry<Object> matcher = new UriPatternOrderedMatcher<>();
         matcher.register(null, null);
@@ -154,13 +154,13 @@ public class TestUriPatternOrderedMatcher {
         Assert.assertTrue(h1 == h);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testRegisterInvalidInput() throws Exception {
         final LookupRegistry<Object> matcher = new UriPatternOrderedMatcher<>();
         matcher.register(null, null);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testLookupInvalidInput() throws Exception {
         final LookupRegistry<Object> matcher = new UriPatternOrderedMatcher<>();
         matcher.lookup(null);
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriRegexMatcher.java b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriRegexMatcher.java
index bbcdd75..56ca167 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriRegexMatcher.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriRegexMatcher.java
@@ -60,7 +60,7 @@ public class TestUriRegexMatcher {
         Assert.assertNull(h);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = NullPointerException.class)
     public void testRegisterNull() throws Exception {
         final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
         matcher.register(null, null);
@@ -196,13 +196,13 @@ public class TestUriRegexMatcher {
         Assert.assertTrue(h1 == h);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = NullPointerException.class)
     public void testRegisterInvalidInput() throws Exception {
         final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
         matcher.register(null, null);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = NullPointerException.class)
     public void testLookupInvalidInput() throws Exception {
         final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
         matcher.lookup(null);
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/net/TestHost.java b/httpcore5/src/test/java/org/apache/hc/core5/net/TestHost.java
index 4fdbe7a..23c5880 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/net/TestHost.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/net/TestHost.java
@@ -52,8 +52,8 @@ public class TestHost {
         Assert.assertEquals(0, host2.getPort());
         try {
             new Host(null, 0);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException expected) {
         }
         try {
             new Host("blah", -1);
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 766cb62..8547ff2 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
@@ -102,12 +102,12 @@ public class TestLaxConnPool {
     }
 
     @Test
-    public void testLeaseIllegal() throws Exception {
+    public void testLeaseInvalid() throws Exception {
         final LaxConnPool<String, HttpConnection> pool = new LaxConnPool<>(2);
         try {
             pool.lease(null, null, Timeout.ZERO_MILLISECONDS, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException expected) {
         }
     }
 
@@ -372,7 +372,7 @@ public class TestLaxConnPool {
         Assert.assertEquals(0, totals.getLeased());
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testGetStatsInvalid() throws Exception {
         final LaxConnPool<String, HttpConnection> pool = new LaxConnPool<>(2);
         pool.getStats(null);
@@ -383,8 +383,8 @@ public class TestLaxConnPool {
         final LaxConnPool<String, HttpConnection> pool = new LaxConnPool<>(2);
         try {
             pool.setMaxPerRoute(null, 1);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException expected) {
         }
         try {
             pool.setDefaultMaxPerRoute(-1);
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/pool/TestPoolEntry.java b/httpcore5/src/test/java/org/apache/hc/core5/pool/TestPoolEntry.java
index b53624e..97aafe6 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/pool/TestPoolEntry.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/pool/TestPoolEntry.java
@@ -78,8 +78,8 @@ public class TestPoolEntry {
         Assert.assertEquals(Deadline.MIN_VALUE, entry1.getExpiryDeadline());
     }
 
-    @Test(expected = IllegalArgumentException.class)
-    public void testInvalidConstruction() throws Exception {
+    @Test(expected = NullPointerException.class)
+    public void testNullConstructor() throws Exception {
         new PoolEntry<String, HttpConnection>(null);
     }
 
@@ -114,7 +114,7 @@ public class TestPoolEntry {
         Assert.assertEquals(validityDeadline, entry2.getExpiryDeadline());
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testInvalidExpiry() throws Exception {
         final PoolEntry<String, HttpConnection> entry = new PoolEntry<>(
                 "route1", TimeValue.of(0L, TimeUnit.MILLISECONDS), currentTimeSupplier);
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 7aa5c50..a0484d2 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
@@ -112,17 +112,17 @@ public class TestStrictConnPool {
     }
 
     @Test
-    public void testLeaseIllegal() throws Exception {
+    public void testLeaseInvalid() throws Exception {
         final StrictConnPool<String, HttpConnection> pool = new StrictConnPool<>(2, 10);
         try {
             pool.lease(null, null, Timeout.ZERO_MILLISECONDS, null);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException expected) {
         }
         try {
             pool.lease("somehost", null, null, null);
             Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException expected) {
+        } catch (final NullPointerException expected) {
         }
     }
 
@@ -604,7 +604,7 @@ public class TestStrictConnPool {
         Assert.assertEquals(0, totals.getLeased());
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testGetStatsInvalid() throws Exception {
         final StrictConnPool<String, HttpConnection> pool = new StrictConnPool<>(2, 2);
         pool.getStats(null);
@@ -620,8 +620,8 @@ public class TestStrictConnPool {
         }
         try {
             pool.setMaxPerRoute(null, 1);
-            Assert.fail("IllegalArgumentException should have been thrown");
-        } catch (final IllegalArgumentException expected) {
+            Assert.fail("NullPointerException should have been thrown");
+        } catch (final NullPointerException expected) {
         }
         try {
             pool.setDefaultMaxPerRoute(-1);
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/util/TestArgs.java b/httpcore5/src/test/java/org/apache/hc/core5/util/TestArgs.java
index b957e1e..f82a8c9 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/util/TestArgs.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/util/TestArgs.java
@@ -55,7 +55,7 @@ public class TestArgs {
         Assert.assertSame(stuff, Args.notNull(stuff, "Stuff"));
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testArgNotNullFail() {
         Args.notNull(null, "Stuff");
     }
@@ -66,7 +66,7 @@ public class TestArgs {
         Assert.assertSame(stuff, Args.notEmpty(stuff, "Stuff"));
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testArgNotEmptyFail1() {
         Args.notEmpty((String) null, "Stuff");
     }
@@ -76,7 +76,7 @@ public class TestArgs {
         Args.notEmpty("", "Stuff");
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testArgNotBlankFail1() {
         Args.notBlank((String) null, "Stuff");
     }
@@ -97,7 +97,7 @@ public class TestArgs {
         Assert.assertSame(list, Args.notEmpty(list, "List"));
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected=NullPointerException.class)
     public void testArgCollectionNotEmptyFail1() {
         Args.notEmpty((List<?>) null, "List");
     }


[httpcomponents-core] 02/06: Use HttpStatus.SC_OK instead of literal 200

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch consistency-fixes
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit fbf0845f4cddbfc8e5c1b2400f8991a43097a038
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Wed Dec 25 16:40:24 2019 +0100

    Use HttpStatus.SC_OK instead of literal 200
---
 .../org/apache/hc/core5/http/impl/nio/ClientHttp1StreamDuplexer.java   | 3 ++-
 .../org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

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 0adb248..36cb7e4 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
@@ -44,6 +44,7 @@ import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
 import org.apache.hc.core5.http.LengthRequiredException;
 import org.apache.hc.core5.http.config.CharCodingConfig;
 import org.apache.hc.core5.http.config.Http1Config;
@@ -229,7 +230,7 @@ public class ClientHttp1StreamDuplexer extends AbstractHttp1StreamDuplexer<HttpR
 
     @Override
     void updateInputMetrics(final HttpResponse response, final BasicHttpConnectionMetrics connMetrics) {
-        if (response.getCode() >= 200) {
+        if (response.getCode() >= HttpStatus.SC_OK) {
             connMetrics.incrementRequestCount();
         }
     }
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 68e3cf7..e1047ff 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
@@ -44,6 +44,7 @@ import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
 import org.apache.hc.core5.http.config.CharCodingConfig;
 import org.apache.hc.core5.http.config.Http1Config;
 import org.apache.hc.core5.http.impl.BasicHttpConnectionMetrics;
@@ -241,7 +242,7 @@ public class ServerHttp1StreamDuplexer extends AbstractHttp1StreamDuplexer<HttpR
 
     @Override
     void updateOutputMetrics(final HttpResponse response, final BasicHttpConnectionMetrics connMetrics) {
-        if (response.getCode() >= 200) {
+        if (response.getCode() >= HttpStatus.SC_OK) {
             connMetrics.incrementRequestCount();
         }
     }