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

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

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");
     }