Skip to content

Commit 4c5361d

Browse files
committed
+tck 2.9 blackbox verification should fully drive publisher
It should not use the helper publisher as it may signal asynchronously as well as onComplete in undefined ways - we need to control the publisher in this case because of the very specific test scenario
1 parent c3dd8a1 commit 4c5361d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

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

+18-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import java.util.concurrent.ExecutorService;
1717
import java.util.concurrent.Executors;
18+
import java.util.concurrent.atomic.AtomicBoolean;
1819

1920
import static org.reactivestreams.tck.Annotations.NotVerified;
2021
import static org.reactivestreams.tck.Annotations.Required;
@@ -224,7 +225,23 @@ public void spec209_blackbox_mustBePreparedToReceiveAnOnCompleteSignalWithPreced
224225
blackboxSubscriberWithoutSetupTest(new BlackboxTestStageTestRun() {
225226
@Override
226227
public void run(BlackboxTestStage stage) throws Throwable {
227-
final Publisher<T> pub = createHelperPublisher(0);
228+
final Publisher<T> pub = new Publisher<T>() {
229+
@Override public void subscribe(final Subscriber<? super T> s) {
230+
s.onSubscribe(new Subscription() {
231+
private AtomicBoolean completed = new AtomicBoolean();
232+
233+
@Override public void request(long n) {
234+
if (completed.compareAndSet(false, true)) {
235+
s.onComplete(); // Publisher now realises that it is in fact already completed
236+
}
237+
}
238+
239+
@Override public void cancel() {
240+
// noop, ignore
241+
}
242+
});
243+
}
244+
};
228245

229246
final Subscriber<T> sub = createSubscriber();
230247
final BlackboxSubscriberProxy<T> probe = stage.createBlackboxSubscriberProxy(env, sub);

0 commit comments

Comments
 (0)