Skip to content

Commit

Permalink
Fix flaky ByteStreamMessageOutputStreamTest.writeAfterStreamClosed() (
Browse files Browse the repository at this point in the history
#5427)

Motivation:

`ByteStreamMessageOutputStreamTest.writeAfterStreamClosed()` tests if
`ByteStreamMessageOutputStream` raises an IOException after the
enclosing `ByteStreamMessage` is aborted.

If a `StreamMessage` has been subscribed by another `Subscriber`, the
abortion process may happen in a different thread asynchronously.

Modifications:

- Wait until the abortion of `ByteStreamMessage` completes.

Results:

Closes #4553
  • Loading branch information
ikhoon authored Jan 30, 2024
1 parent 420480a commit 9bf07b7
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.Closeable;
import java.io.IOException;
import java.time.Duration;
import java.util.concurrent.CompletionException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;

Expand Down Expand Up @@ -175,6 +176,12 @@ void writeAfterStreamClosed() throws InterruptedException {
StepVerifier.create(byteStreamMessage, 2)
.expectNext(httpData(0), httpData(1))
.then(byteStreamMessage::abort)
.then(() -> {
// Wait for the abortion to be completed.
assertThatThrownBy(() -> byteStreamMessage.whenComplete().join())
.isInstanceOf(CompletionException.class)
.hasCauseInstanceOf(AbortedStreamException.class);
})
.then(wait::countDown)
.verifyError(AbortedStreamException.class);
end.await();
Expand Down

0 comments on commit 9bf07b7

Please sign in to comment.