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/06 08:32:44 UTC
[httpcomponents-core] branch master updated:
`AbstractAsyncResponseConsumer` to handle gracefully an inconsistent state
caused by the caller signalling a response with no entity but subsequently
calling methods to consume data
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-core.git
The following commit(s) were added to refs/heads/master by this push:
new 5d413a4 `AbstractAsyncResponseConsumer` to handle gracefully an inconsistent state caused by the caller signalling a response with no entity but subsequently calling methods to consume data
5d413a4 is described below
commit 5d413a44c3a067bd7af6088bfe7d9e3f362675a8
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Fri Nov 6 09:24:26 2020 +0100
`AbstractAsyncResponseConsumer` to handle gracefully an inconsistent state caused by the caller signalling a response with no entity but subsequently calling methods to consume data
---
.../http/nio/support/AbstractAsyncResponseConsumer.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
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 3b55735..168620c 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
@@ -127,19 +127,27 @@ public abstract class AbstractAsyncResponseConsumer<T, E> implements AsyncRespon
@Override
public final void updateCapacity(final CapacityChannel capacityChannel) throws IOException {
final AsyncEntityConsumer<E> dataConsumer = dataConsumerRef.get();
- dataConsumer.updateCapacity(capacityChannel);
+ if (dataConsumer != null) {
+ dataConsumer.updateCapacity(capacityChannel);
+ } else {
+ capacityChannel.update(Integer.MAX_VALUE);
+ }
}
@Override
public final void consume(final ByteBuffer src) throws IOException {
final AsyncEntityConsumer<E> dataConsumer = dataConsumerRef.get();
- dataConsumer.consume(src);
+ if (dataConsumer != null) {
+ dataConsumer.consume(src);
+ }
}
@Override
public final void streamEnd(final List<? extends Header> trailers) throws HttpException, IOException {
final AsyncEntityConsumer<E> dataConsumer = dataConsumerRef.get();
- dataConsumer.streamEnd(trailers);
+ if (dataConsumer != null) {
+ dataConsumer.streamEnd(trailers);
+ }
}
@Override