Skip to content

Commit deb5a31

Browse files
committed
Fail test in case of double onError/onComplete signals
1 parent 96a4a0a commit deb5a31

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

tck/src/main/java/org/reactivestreams/tck/SubscriberWhiteboxVerification.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@ public void run(WhiteboxTestStage stage) throws InterruptedException {
493493

494494
// cumulative pending > Long.MAX_VALUE
495495
stage.probe.expectErrorWithMessage(IllegalStateException.class, "3.17");
496+
497+
env.verifyNoAsyncErrors(env.defaultTimeoutMillis());
496498
}
497499
});
498500
}
@@ -626,12 +628,22 @@ public void registerOnNext(T element) {
626628

627629
@Override
628630
public void registerOnComplete() {
629-
elements.complete();
631+
try {
632+
elements.complete();
633+
} catch (IllegalStateException ex) {
634+
// "Queue full"
635+
env.flop("subscriber::onComplete was called a second time, which is illegal according to Rule 1.7");
636+
}
630637
}
631638

632639
@Override
633640
public void registerOnError(Throwable cause) {
634-
error.complete(cause);
641+
try {
642+
error.complete(cause);
643+
} catch (IllegalStateException ex) {
644+
// "Queue full", onError was already called
645+
env.flop("subscriber::onError was called a second time, which is illegal according to Rule 1.7");
646+
}
635647
}
636648

637649
public T expectNext() throws InterruptedException {

tck/src/main/java/org/reactivestreams/tck/TestEnvironment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public void verifyNoAsyncErrors() {
150150
/** If {@code TestEnvironment#printlnDebug} is true, print debug message to std out. */
151151
public void debug(String msg) {
152152
if (printlnDebug)
153-
System.out.println(msg);
153+
System.out.println("[TCK-DEBUG] " + msg);
154154
}
155155

156156
// ---- classes ----

0 commit comments

Comments
 (0)