Skip to content

Commit 095467f

Browse files
committed
Merge pull request #122 from ktoso/impr-fail-tck-when-onError-twice-ktoso
Fail test in case of double onError/onComplete signals
2 parents 24b181d + 6aac3f9 commit 095467f

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
@@ -490,6 +490,8 @@ public void run(WhiteboxTestStage stage) throws InterruptedException {
490490

491491
// cumulative pending > Long.MAX_VALUE
492492
stage.probe.expectErrorWithMessage(IllegalStateException.class, "3.17");
493+
494+
env.verifyNoAsyncErrors(env.defaultTimeoutMillis());
493495
}
494496
});
495497
}
@@ -627,12 +629,22 @@ public void registerOnNext(T element) {
627629

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

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

638650
public T expectNext() throws InterruptedException {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public void verifyNoAsyncErrors() {
158158
/** If {@code TestEnvironment#printlnDebug} is true, print debug message to std out. */
159159
public void debug(String msg) {
160160
if (printlnDebug)
161-
System.out.println(msg);
161+
System.out.println("[TCK-DEBUG] " + msg);
162162
}
163163

164164
// ---- classes ----

0 commit comments

Comments
 (0)