From ffa0530bb2fb017e140e1be98754a6e1d25b905e Mon Sep 17 00:00:00 2001 From: slisaasquatch Date: Fri, 6 Mar 2020 11:31:42 -0800 Subject: [PATCH] Fix NPE for null HttpContext in minimal async clients --- .../apache/hc/client5/http/impl/async/MinimalH2AsyncClient.java | 2 +- .../hc/client5/http/impl/async/MinimalHttpAsyncClient.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalH2AsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalH2AsyncClient.java index bd4a35d64..dc23b6247 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalH2AsyncClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalH2AsyncClient.java @@ -136,7 +136,7 @@ public final class MinimalH2AsyncClient extends AbstractMinimalHttpAsyncClientBa final HttpContext context) { ensureRunning(); final ComplexCancellable cancellable = new ComplexCancellable(); - final HttpClientContext clientContext = HttpClientContext.adapt(context); + final HttpClientContext clientContext = context != null ? HttpClientContext.adapt(context) : HttpClientContext.create(); try { exchangeHandler.produceRequest(new RequestChannel() { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java index 65af82025..d4e95d2b3 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/MinimalHttpAsyncClient.java @@ -248,7 +248,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient final HttpContext context) { ensureRunning(); final ComplexCancellable cancellable = new ComplexCancellable(); - final HttpClientContext clientContext = HttpClientContext.adapt(context); + final HttpClientContext clientContext = context != null ? HttpClientContext.adapt(context) : HttpClientContext.create(); try { exchangeHandler.produceRequest(new RequestChannel() {