You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2021/10/11 15:40:42 UTC

[httpcomponents-core] branch master updated: Don't initialize AtomicReference to its default value.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new c813e39  Don't initialize AtomicReference to its default value.
c813e39 is described below

commit c813e39427973817ec3fbc1d877ca96cb772c394
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Oct 11 11:40:39 2021 -0400

    Don't initialize AtomicReference to its default value.
---
 .../org/apache/hc/core5/http2/impl/nio/ProtocolNegotiatorBase.java    | 2 +-
 .../hc/core5/http2/impl/nio/bootstrap/CancellableExecution.java       | 2 +-
 .../main/java/org/apache/hc/core5/reactive/ReactiveDataProducer.java  | 4 ++--
 .../org/apache/hc/core5/reactive/ReactiveServerExchangeHandler.java   | 2 +-
 .../src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java  | 4 ++--
 .../java/org/apache/hc/core5/testing/classic/ClassicTestClient.java   | 2 +-
 .../java/org/apache/hc/core5/testing/classic/ClassicTestServer.java   | 2 +-
 .../main/java/org/apache/hc/core5/testing/nio/IOReactorExecutor.java  | 2 +-
 .../apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java    | 2 +-
 .../test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java  | 2 +-
 .../java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java    | 2 +-
 .../java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java    | 2 +-
 .../java/org/apache/hc/core5/testing/reactive/ReactiveClientTest.java | 4 ++--
 .../src/main/java/org/apache/hc/core5/concurrent/ComplexFuture.java   | 2 +-
 .../src/main/java/org/apache/hc/core5/http/impl/io/SocketHolder.java  | 4 ++--
 .../org/apache/hc/core5/http/nio/entity/BasicAsyncEntityProducer.java | 4 ++--
 .../java/org/apache/hc/core5/http/nio/entity/FileEntityProducer.java  | 4 ++--
 .../apache/hc/core5/http/nio/entity/StringAsyncEntityProducer.java    | 2 +-
 .../hc/core5/http/nio/support/AbstractAsyncRequesterConsumer.java     | 2 +-
 .../hc/core5/http/nio/support/AbstractAsyncResponseConsumer.java      | 2 +-
 .../hc/core5/http/nio/support/AbstractServerExchangeHandler.java      | 4 ++--
 .../core5/http/nio/support/BasicAsyncServerExpectationDecorator.java  | 2 +-
 .../org/apache/hc/core5/http/nio/support/BasicRequestConsumer.java    | 2 +-
 .../org/apache/hc/core5/http/nio/support/BasicResponseConsumer.java   | 2 +-
 .../core5/http/nio/support/classic/AbstractClassicEntityConsumer.java | 4 ++--
 .../core5/http/nio/support/classic/AbstractClassicEntityProducer.java | 2 +-
 .../nio/support/classic/AbstractClassicServerExchangeHandler.java     | 2 +-
 httpcore5/src/main/java/org/apache/hc/core5/pool/PoolEntry.java       | 2 +-
 .../src/main/java/org/apache/hc/core5/reactor/IOSessionRequest.java   | 2 +-
 .../main/java/org/apache/hc/core5/reactor/InternalDataChannel.java    | 2 +-
 30 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ProtocolNegotiatorBase.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ProtocolNegotiatorBase.java
index d3803b6..89e787c 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ProtocolNegotiatorBase.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/ProtocolNegotiatorBase.java
@@ -60,7 +60,7 @@ abstract class ProtocolNegotiatorBase implements HttpConnectionEventHandler {
             final ProtocolIOSession ioSession,
             final FutureCallback<ProtocolIOSession> resultCallback) {
         this.ioSession = Args.notNull(ioSession, "I/O session");
-        this.protocolHandlerRef = new AtomicReference<>(null);
+        this.protocolHandlerRef = new AtomicReference<>();
         this.resultCallback = resultCallback;
         this.completed = new AtomicBoolean();
     }
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/CancellableExecution.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/CancellableExecution.java
index 7257782..84e89dc 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/CancellableExecution.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/CancellableExecution.java
@@ -39,7 +39,7 @@ final class CancellableExecution implements CancellableDependency {
 
     CancellableExecution() {
         this.cancelled = new AtomicBoolean(false);
-        this.dependencyRef = new AtomicReference<>(null);
+        this.dependencyRef = new AtomicReference<>();
     }
 
     @Override
diff --git a/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive/ReactiveDataProducer.java b/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive/ReactiveDataProducer.java
index cfdb364..61813ca 100644
--- a/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive/ReactiveDataProducer.java
+++ b/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive/ReactiveDataProducer.java
@@ -53,10 +53,10 @@ final class ReactiveDataProducer implements AsyncDataProducer, Subscriber<ByteBu
     private static final int BUFFER_WINDOW_SIZE = 5;
 
     private final AtomicReference<DataStreamChannel> requestChannel = new AtomicReference<>();
-    private final AtomicReference<Throwable> exception = new AtomicReference<>(null);
+    private final AtomicReference<Throwable> exception = new AtomicReference<>();
     private final AtomicBoolean complete = new AtomicBoolean(false);
     private final Publisher<ByteBuffer> publisher;
-    private final AtomicReference<Subscription> subscription = new AtomicReference<>(null);
+    private final AtomicReference<Subscription> subscription = new AtomicReference<>();
     private final ArrayDeque<ByteBuffer> buffers = new ArrayDeque<>(); // This field requires synchronization
 
     public ReactiveDataProducer(final Publisher<ByteBuffer> publisher) {
diff --git a/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive/ReactiveServerExchangeHandler.java b/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive/ReactiveServerExchangeHandler.java
index d2eef61..4e5ec4c 100644
--- a/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive/ReactiveServerExchangeHandler.java
+++ b/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive/ReactiveServerExchangeHandler.java
@@ -51,7 +51,7 @@ import org.reactivestreams.Publisher;
 public final class ReactiveServerExchangeHandler implements AsyncServerExchangeHandler {
 
     private final ReactiveRequestProcessor requestProcessor;
-    private final AtomicReference<ReactiveDataProducer> responseProducer = new AtomicReference<>(null);
+    private final AtomicReference<ReactiveDataProducer> responseProducer = new AtomicReference<>();
     private final ReactiveDataConsumer requestConsumer;
     private volatile DataStreamChannel channel;
 
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
index 5227db2..8fb3fea 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
@@ -89,7 +89,7 @@ class BenchmarkWorker implements ResourceHolder {
         this.completionLatch = completionLatch;
         this.stats = stats;
         this.config = config;
-        this.endpointRef = new AtomicReference<>(null);
+        this.endpointRef = new AtomicReference<>();
     }
 
     private AsyncRequestProducer createRequestProducer() {
@@ -183,7 +183,7 @@ class BenchmarkWorker implements ResourceHolder {
             volatile int status;
             volatile Charset charset;
             final AtomicLong contentLength = new AtomicLong();
-            final AtomicReference<FutureCallback<Void>> resultCallbackRef = new AtomicReference<>(null);
+            final AtomicReference<FutureCallback<Void>> resultCallbackRef = new AtomicReference<>();
 
             @Override
             public void consumeResponse(
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java
index 9fc3e92..efb1730 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestClient.java
@@ -64,7 +64,7 @@ public class ClassicTestClient {
         super();
         this.sslContext = sslContext;
         this.socketConfig = socketConfig != null ? socketConfig : SocketConfig.DEFAULT;
-        this.requesterRef = new AtomicReference<>(null);
+        this.requesterRef = new AtomicReference<>();
     }
 
     public ClassicTestClient(final SocketConfig socketConfig) {
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
index 4abe8b2..2e94c77 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/classic/ClassicTestServer.java
@@ -64,7 +64,7 @@ public class ClassicTestServer {
         this.sslContext = sslContext;
         this.socketConfig = socketConfig != null ? socketConfig : SocketConfig.DEFAULT;
         this.registry = new RequestHandlerRegistry<>();
-        this.serverRef = new AtomicReference<>(null);
+        this.serverRef = new AtomicReference<>();
     }
 
     public ClassicTestServer(final SocketConfig socketConfig) {
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/IOReactorExecutor.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/IOReactorExecutor.java
index 22d1db3..13b7576 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/IOReactorExecutor.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/IOReactorExecutor.java
@@ -56,7 +56,7 @@ abstract class IOReactorExecutor<T extends IOReactorService> implements AutoClos
         super();
         this.ioReactorConfig = ioReactorConfig != null ? ioReactorConfig : IOReactorConfig.DEFAULT;
         this.workerThreadFactory = workerThreadFactory;
-        this.ioReactorRef = new AtomicReference<>(null);
+        this.ioReactorRef = new AtomicReference<>();
         this.status = new AtomicReference<>(Status.READY);
     }
 
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java
index c7d01fd..aa7a5df 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicTLSIntegrationTest.java
@@ -112,7 +112,7 @@ public class ClassicTLSIntegrationTest {
                 .create();
         server.start();
 
-        final AtomicReference<SSLSession> sslSessionRef = new AtomicReference<>(null);
+        final AtomicReference<SSLSession> sslSessionRef = new AtomicReference<>();
 
         requester = RequesterBootstrap.bootstrap()
                 .setSslContext(SSLTestContexts.createClientSSLContext())
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java
index 18f6d21..5985436 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2IntegrationTest.java
@@ -747,7 +747,7 @@ public class H2IntegrationTest extends InternalH2ServerTestBase {
             public AsyncServerExchangeHandler get() {
                 return new AsyncServerExchangeHandler() {
 
-                    private final AtomicReference<AsyncResponseProducer> responseProducer = new AtomicReference<>(null);
+                    private final AtomicReference<AsyncResponseProducer> responseProducer = new AtomicReference<>();
 
                     @Override
                     public void updateCapacity(final CapacityChannel capacityChannel) throws IOException {
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java
index 85f7662..0f40ab9 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/H2TLSIntegrationTest.java
@@ -125,7 +125,7 @@ public class H2TLSIntegrationTest {
                 .create();
         server.start();
 
-        final AtomicReference<SSLSession> sslSessionRef = new AtomicReference<>(null);
+        final AtomicReference<SSLSession> sslSessionRef = new AtomicReference<>();
 
         requester = H2RequesterBootstrap.bootstrap()
                 .setIOReactorConfig(IOReactorConfig.custom()
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
index a243646..9640a06 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/Http1IntegrationTest.java
@@ -956,7 +956,7 @@ public class Http1IntegrationTest extends InternalHttp1ServerTestBase {
     public void testPrematureResponse() throws Exception {
         server.register("*", () -> new AsyncServerExchangeHandler() {
 
-            private final AtomicReference<AsyncResponseProducer> responseProducer = new AtomicReference<>(null);
+            private final AtomicReference<AsyncResponseProducer> responseProducer = new AtomicReference<>();
 
             @Override
             public void handleRequest(
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/reactive/ReactiveClientTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/reactive/ReactiveClientTest.java
index 9787606..ec1bdbe 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/reactive/ReactiveClientTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/reactive/ReactiveClientTest.java
@@ -208,7 +208,7 @@ public class ReactiveClientTest {
     public void testLongRunningRequest() throws Exception {
         final InetSocketAddress address = startClientAndServer();
         final long expectedLength = 6_554_200L;
-        final AtomicReference<String> expectedHash = new AtomicReference<>(null);
+        final AtomicReference<String> expectedHash = new AtomicReference<>();
         final Flowable<ByteBuffer> stream = ReactiveTestUtils.produceStream(expectedLength, expectedHash);
         final ReactiveEntityProducer producer = new ReactiveEntityProducer(stream, -1, null, null);
         final BasicRequestProducer request = getRequestProducer(address, producer);
@@ -233,7 +233,7 @@ public class ReactiveClientTest {
         for (int i = 0; i < 10; i++) {
             final long expectedLength = 1_024_000;
             final int maximumBlockSize = 1024;
-            final AtomicReference<String> expectedHash = new AtomicReference<>(null);
+            final AtomicReference<String> expectedHash = new AtomicReference<>();
             final Publisher<ByteBuffer> stream = ReactiveTestUtils.produceStream(expectedLength, maximumBlockSize, expectedHash);
             final ReactiveEntityProducer producer = new ReactiveEntityProducer(stream, -1, null, null);
             final BasicRequestProducer request = getRequestProducer(address, producer);
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexFuture.java b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexFuture.java
index e902e0e..a841112 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexFuture.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/concurrent/ComplexFuture.java
@@ -45,7 +45,7 @@ public final class ComplexFuture<T> extends BasicFuture<T> implements Cancellabl
 
     public ComplexFuture(final FutureCallback<T> callback) {
         super(callback);
-        this.dependencyRef = new AtomicReference<>(null);
+        this.dependencyRef = new AtomicReference<>();
     }
 
     @Override
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SocketHolder.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SocketHolder.java
index 4a8496f..b189dc5 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SocketHolder.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SocketHolder.java
@@ -49,8 +49,8 @@ public class SocketHolder {
 
     public SocketHolder(final Socket socket) {
         this.socket = Args.notNull(socket, "Socket");
-        this.inputStreamRef = new AtomicReference<>(null);
-        this.outputStreamRef = new AtomicReference<>(null);
+        this.inputStreamRef = new AtomicReference<>();
+        this.outputStreamRef = new AtomicReference<>();
     }
 
     public final Socket getSocket() {
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/BasicAsyncEntityProducer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/BasicAsyncEntityProducer.java
index 03bbfac..f3183b2 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/BasicAsyncEntityProducer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/BasicAsyncEntityProducer.java
@@ -59,7 +59,7 @@ public class BasicAsyncEntityProducer implements AsyncEntityProducer {
         this.length = this.bytebuf.remaining();
         this.contentType = contentType;
         this.chunked = chunked;
-        this.exception = new AtomicReference<>(null);
+        this.exception = new AtomicReference<>();
     }
 
     public BasicAsyncEntityProducer(final byte[] content, final ContentType contentType) {
@@ -80,7 +80,7 @@ public class BasicAsyncEntityProducer implements AsyncEntityProducer {
         this.bytebuf = charset.encode(CharBuffer.wrap(content));
         this.length = this.bytebuf.remaining();
         this.chunked = chunked;
-        this.exception = new AtomicReference<>(null);
+        this.exception = new AtomicReference<>();
     }
 
     public BasicAsyncEntityProducer(final CharSequence content, final ContentType contentType) {
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/FileEntityProducer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/FileEntityProducer.java
index 0df0276..2ac1c00 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/FileEntityProducer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/FileEntityProducer.java
@@ -63,8 +63,8 @@ public final class FileEntityProducer implements AsyncEntityProducer {
         this.byteBuffer = ByteBuffer.allocate(bufferSize);
         this.contentType = contentType;
         this.chunked = chunked;
-        this.accessFileRef = new AtomicReference<>(null);
-        this.exception = new AtomicReference<>(null);
+        this.accessFileRef = new AtomicReference<>();
+        this.exception = new AtomicReference<>();
     }
 
     public FileEntityProducer(final File file, final ContentType contentType, final boolean chunked) {
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/StringAsyncEntityProducer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/StringAsyncEntityProducer.java
index cd946cc..7d5f284 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/StringAsyncEntityProducer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/entity/StringAsyncEntityProducer.java
@@ -54,7 +54,7 @@ public class StringAsyncEntityProducer extends AbstractCharAsyncEntityProducer {
         super(bufferSize, fragmentSizeHint, contentType);
         Args.notNull(content, "Content");
         this.content = CharBuffer.wrap(content);
-        this.exception = new AtomicReference<>(null);
+        this.exception = new AtomicReference<>();
     }
 
     public StringAsyncEntityProducer(final CharSequence content, final int bufferSize, final ContentType contentType) {
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncRequesterConsumer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncRequesterConsumer.java
index c5caa92..faa050f 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncRequesterConsumer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncRequesterConsumer.java
@@ -62,7 +62,7 @@ public abstract class AbstractAsyncRequesterConsumer<T, E> implements AsyncReque
 
     public AbstractAsyncRequesterConsumer(final Supplier<AsyncEntityConsumer<E>> dataConsumerSupplier) {
         this.dataConsumerSupplier = Args.notNull(dataConsumerSupplier, "Data consumer supplier");
-        this.dataConsumerRef = new AtomicReference<>(null);
+        this.dataConsumerRef = new AtomicReference<>();
     }
 
     public AbstractAsyncRequesterConsumer(final AsyncEntityConsumer<E> dataConsumer) {
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncResponseConsumer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncResponseConsumer.java
index c4a0644..61f2542 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncResponseConsumer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractAsyncResponseConsumer.java
@@ -62,7 +62,7 @@ public abstract class AbstractAsyncResponseConsumer<T, E> implements AsyncRespon
 
     public AbstractAsyncResponseConsumer(final Supplier<AsyncEntityConsumer<E>> dataConsumerSupplier) {
         this.dataConsumerSupplier = Args.notNull(dataConsumerSupplier, "Data consumer supplier");
-        this.dataConsumerRef = new AtomicReference<>(null);
+        this.dataConsumerRef = new AtomicReference<>();
     }
 
     public AbstractAsyncResponseConsumer(final AsyncEntityConsumer<E> dataConsumer) {
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractServerExchangeHandler.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractServerExchangeHandler.java
index 0e2c3c4..9607ae9 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractServerExchangeHandler.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractServerExchangeHandler.java
@@ -60,8 +60,8 @@ public abstract class AbstractServerExchangeHandler<T> implements AsyncServerExc
     private final AtomicReference<AsyncResponseProducer> responseProducerRef;
 
     public AbstractServerExchangeHandler() {
-        this.requestConsumerRef = new AtomicReference<>(null);
-        this.responseProducerRef = new AtomicReference<>(null);
+        this.requestConsumerRef = new AtomicReference<>();
+        this.responseProducerRef = new AtomicReference<>();
     }
 
     /**
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncServerExpectationDecorator.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncServerExpectationDecorator.java
index 441e2ae..326e618 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncServerExpectationDecorator.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicAsyncServerExpectationDecorator.java
@@ -65,7 +65,7 @@ public class BasicAsyncServerExpectationDecorator implements AsyncServerExchange
                                                 final Callback<Exception> exceptionCallback) {
         this.handler = Args.notNull(handler, "Handler");
         this.exceptionCallback = exceptionCallback;
-        this.responseProducerRef = new AtomicReference<>(null);
+        this.responseProducerRef = new AtomicReference<>();
     }
 
     public BasicAsyncServerExpectationDecorator(final AsyncServerExchangeHandler handler) {
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicRequestConsumer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicRequestConsumer.java
index 8802b60..3567c18 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicRequestConsumer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicRequestConsumer.java
@@ -58,7 +58,7 @@ public class BasicRequestConsumer<T> implements AsyncRequestConsumer<Message<Htt
 
     public BasicRequestConsumer(final Supplier<AsyncEntityConsumer<T>> dataConsumerSupplier) {
         this.dataConsumerSupplier = Args.notNull(dataConsumerSupplier, "Data consumer supplier");
-        this.dataConsumerRef = new AtomicReference<>(null);
+        this.dataConsumerRef = new AtomicReference<>();
     }
 
     public BasicRequestConsumer(final AsyncEntityConsumer<T> dataConsumer) {
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicResponseConsumer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicResponseConsumer.java
index 70fc73e..be95f81 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicResponseConsumer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/BasicResponseConsumer.java
@@ -59,7 +59,7 @@ public class BasicResponseConsumer<T> implements AsyncResponseConsumer<Message<H
 
     public BasicResponseConsumer(final Supplier<AsyncEntityConsumer<T>> dataConsumerSupplier) {
         this.dataConsumerSupplier = Args.notNull(dataConsumerSupplier, "Data consumer supplier");
-        this.dataConsumerRef = new AtomicReference<>(null);
+        this.dataConsumerRef = new AtomicReference<>();
     }
 
     public BasicResponseConsumer(final AsyncEntityConsumer<T> dataConsumer) {
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicEntityConsumer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicEntityConsumer.java
index 4cee5ac..fbc9fd4 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicEntityConsumer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicEntityConsumer.java
@@ -67,8 +67,8 @@ public abstract class AbstractClassicEntityConsumer<T> implements AsyncEntityCon
         this.executor = Args.notNull(executor, "Executor");
         this.buffer = new SharedInputBuffer(initialBufferSize);
         this.state = new AtomicReference<>(State.IDLE);
-        this.resultRef = new AtomicReference<>(null);
-        this.exceptionRef = new AtomicReference<>(null);
+        this.resultRef = new AtomicReference<>();
+        this.exceptionRef = new AtomicReference<>();
     }
 
     /**
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicEntityProducer.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicEntityProducer.java
index 28ae2b3..4b33b0b 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicEntityProducer.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicEntityProducer.java
@@ -59,7 +59,7 @@ public abstract class AbstractClassicEntityProducer implements AsyncEntityProduc
         this.contentType = contentType;
         this.executor = Args.notNull(executor, "Executor");
         this.state = new AtomicReference<>(State.IDLE);
-        this.exception = new AtomicReference<>(null);
+        this.exception = new AtomicReference<>();
     }
 
     /**
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicServerExchangeHandler.java b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicServerExchangeHandler.java
index 1b18de0..3ab6b94 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicServerExchangeHandler.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicServerExchangeHandler.java
@@ -78,7 +78,7 @@ public abstract class AbstractClassicServerExchangeHandler implements AsyncServe
     public AbstractClassicServerExchangeHandler(final int initialBufferSize, final Executor executor) {
         this.initialBufferSize = Args.positive(initialBufferSize, "Initial buffer size");
         this.executor = Args.notNull(executor, "Executor");
-        this.exception = new AtomicReference<>(null);
+        this.exception = new AtomicReference<>();
         this.state = new AtomicReference<>(State.IDLE);
     }
 
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/pool/PoolEntry.java b/httpcore5/src/main/java/org/apache/hc/core5/pool/PoolEntry.java
index ad27c69..6ca8ab5 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/pool/PoolEntry.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/pool/PoolEntry.java
@@ -66,7 +66,7 @@ public final class PoolEntry<T, C extends ModalCloseable> {
         super();
         this.route = Args.notNull(route, "Route");
         this.timeToLive = TimeValue.defaultsToNegativeOneMillisecond(timeToLive);
-        this.connRef = new AtomicReference<>(null);
+        this.connRef = new AtomicReference<>();
         this.disposalCallback = disposalCallback;
         this.currentTimeSupplier = currentTimeSupplier;
     }
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionRequest.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionRequest.java
index 1eafc0e..c808e0a 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionRequest.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionRequest.java
@@ -66,7 +66,7 @@ final class IOSessionRequest implements Future<IOSession> {
         this.timeout = timeout;
         this.attachment = attachment;
         this.future = new BasicFuture<>(callback);
-        this.closeableRef = new AtomicReference<>(null);
+        this.closeableRef = new AtomicReference<>();
     }
 
     public void completed(final ProtocolIOSession ioSession) {
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
index fcb3afa..82cc940 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/InternalDataChannel.java
@@ -82,7 +82,7 @@ final class InternalDataChannel extends InternalChannel implements ProtocolIOSes
         this.closedSessions = closedSessions;
         this.ioSessionDecorator = ioSessionDecorator;
         this.sessionListener = sessionListener;
-        this.tlsSessionRef = new AtomicReference<>(null);
+        this.tlsSessionRef = new AtomicReference<>();
         this.currentSessionRef = new AtomicReference<>(
                 ioSessionDecorator != null ? ioSessionDecorator.decorate(ioSession) : ioSession);
         this.protocolUpgradeHandlerMap = new ConcurrentHashMap<>();