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:13:19 UTC

[httpcomponents-client] branch 5.0.x updated: 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 5.0.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/5.0.x by this push:
     new 543d738  HTTPCLIENT-2126: `AsyncCachingExec` throws NPE when response body is null
543d738 is described below

commit 543d73863c3616eb3c6d4fe1ab038cfe893d7af8
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();