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/10/29 08:12:11 UTC

[httpcomponents-core] branch master updated (9f72a38 -> 5dcf070)

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

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


 discard 9f72a38  Make ReactiveDataConsumer.failed a no-op if it has already been marked as complete (#227)
     new 5dcf070  Make `ReactiveDataConsumer#failed` a no-op if it has already been marked as complete (#227)

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (9f72a38)
            \
             N -- N -- N   refs/heads/master (5dcf070)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[httpcomponents-core] 01/01: Make `ReactiveDataConsumer#failed` a no-op if it has already been marked as complete (#227)

Posted by ol...@apache.org.
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

commit 5dcf0707906d3b2454d74a9ce9b2f0c14e550b25
Author: cweld510 <54...@users.noreply.github.com>
AuthorDate: Thu Oct 29 01:00:35 2020 -0700

    Make `ReactiveDataConsumer#failed` a no-op if it has already been marked as complete (#227)
    
    Co-authored-by: ColinWeld <c_...@backblaze.com>
---
 .../hc/core5/reactive/ReactiveDataConsumer.java      |  6 ++++--
 .../hc/core5/reactive/TestReactiveDataConsumer.java  | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive/ReactiveDataConsumer.java b/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive/ReactiveDataConsumer.java
index 6db7d80..1818c69 100644
--- a/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive/ReactiveDataConsumer.java
+++ b/httpcore5-reactive/src/main/java/org/apache/hc/core5/reactive/ReactiveDataConsumer.java
@@ -67,8 +67,10 @@ final class ReactiveDataConsumer implements AsyncDataConsumer, Publisher<ByteBuf
     private volatile Subscriber<? super ByteBuffer> subscriber;
 
     public void failed(final Exception cause) {
-        exception = cause;
-        flushToSubscriber();
+        if (!completed) {
+            exception = cause;
+            flushToSubscriber();
+        }
     }
 
     @Override
diff --git a/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/TestReactiveDataConsumer.java b/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/TestReactiveDataConsumer.java
index 2473061..47fff1d 100644
--- a/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/TestReactiveDataConsumer.java
+++ b/httpcore5-reactive/src/test/java/org/apache/hc/core5/reactive/TestReactiveDataConsumer.java
@@ -206,4 +206,24 @@ public class TestReactiveDataConsumer {
             .blockingGet();
         Assert.assertSame(ex, result.getError());
     }
+
+    @Test
+    public void testFailAfterCompletion() {
+        // Calling consumer.failed() after consumer.streamEnd() must be a no-op.
+        // The exception must be discarded, and the subscriber must see that
+        // the stream was successfully completed.
+        final ReactiveDataConsumer consumer = new ReactiveDataConsumer();
+
+        consumer.streamEnd(null);
+
+        final RuntimeException ex = new RuntimeException();
+        consumer.failed(ex);
+
+        final Notification<ByteBuffer> result = Flowable.fromPublisher(consumer)
+                .materialize()
+                .singleOrError()
+                .blockingGet();
+        Assert.assertFalse(result.isOnError());
+        Assert.assertTrue(result.isOnComplete());
+    }
 }