You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2020/11/05 14:16:48 UTC

[httpcomponents-client] 01/02: HTTPCLIENT-2126: `AsyncCachingExec` throws NPE when response body is null

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

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

commit c9489606d5ae6ff3af6eac9f407260b3e1f4dca0
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Thu Nov 5 15:09:31 2020 +0100

    HTTPCLIENT-2126: `AsyncCachingExec` throws NPE when response body is null
---
 .../java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
index c6db03c..2ccae57 100644
--- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
+++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java
@@ -157,7 +157,9 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
                     cacheResponse,
                     content != null ? new BasicEntityDetails(content.length, contentType) : null);
             if (dataConsumer != null) {
-                dataConsumer.consume(ByteBuffer.wrap(content));
+                if (content != null) {
+                    dataConsumer.consume(ByteBuffer.wrap(content));
+                }
                 dataConsumer.streamEnd(null);
             }
             asyncExecCallback.completed();