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:29:57 UTC
[httpcomponents-core] branch 5.0.x 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 5.0.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
The following commit(s) were added to refs/heads/5.0.x by this push:
new 3a6ea60 `AbstractAsyncResponseConsumer` to handle gracefully an inconsistent state caused by the caller signalling a response with no entity but subsequently calling methods to consume data
3a6ea60 is described below
commit 3a6ea6039da8193f00a077f85ea3da4a4622488f
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 9012ee2..07afcdb 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
@@ -140,19 +140,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