Skip to content

Commit 607da83

Browse files
committed
remove rule 1:12 (produce same elements to all Subscribers)
This rule is in conflict with 1:11 which allows a Publisher to treat multiple Subscribers as either as unicast or multicast recipients. The verification of proper multicast behavior (which 1:12 specified) has been retained, the test methods renamed accordingly.
1 parent b33420a commit 607da83

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public interface Publisher<T> {
9393
| <a name="1.9">9</a> | `Publisher.subscribe` MUST call `onSubscribe` on the provided `Subscriber` prior to any other signals to that `Subscriber` and MUST return normally, except when the provided `Subscriber` is `null` in which case it MUST throw a `java.lang.NullPointerException` to the caller, for all other situations the only legal way to signal failure (or reject the `Subscriber`) is by calling `onError` (after calling `onSubscribe`). |
9494
| <a name="1.10">10</a> | `Publisher.subscribe` MAY be called as many times as wanted but MUST be with a different `Subscriber` each time [see [2.12](#2.12)]. |
9595
| <a name="1.11">11</a> | A `Publisher` MAY support multiple `Subscriber`s and decides whether each `Subscription` is unicast or multicast. |
96-
| <a name="1.12">12</a> | A `Publisher` MUST produce the same elements, starting with the oldest element still available, in the same sequence for all its subscribers and MAY produce the stream elements at (temporarily) differing rates to different subscribers. |
9796

9897
[<a name="footnote-1-1">1</a>] : A stateful Publisher can be overwhelmed, bounded by a finite number of underlying resources, exhausted, shut-down or in a failed state.
9998

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -297,18 +297,18 @@ public void optional_spec111_maySupportMultiSubscribe() throws Throwable {
297297
}
298298

299299
@Override @Test
300-
public void required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws Throwable {
301-
publisherVerification.required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne();
300+
public void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws Throwable {
301+
publisherVerification.optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne();
302302
}
303303

304304
@Override @Test
305-
public void required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws Throwable {
306-
publisherVerification.required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront();
305+
public void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws Throwable {
306+
publisherVerification.optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront();
307307
}
308308

309309
@Override @Test
310-
public void required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws Throwable {
311-
publisherVerification.required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected();
310+
public void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws Throwable {
311+
publisherVerification.optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected();
312312
}
313313

314314
@Override @Test
@@ -755,4 +755,4 @@ public void expectError(Throwable cause, long timeoutMillis) throws InterruptedE
755755
}
756756
}
757757
}
758-
}
758+
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ public void run(Publisher<T> pub) throws Throwable {
551551

552552
// Verifies rule: https://github.com/reactive-streams/reactive-streams#1.12
553553
@Override @Test
554-
public void required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws Throwable {
554+
public void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws Throwable {
555555
optionalActivePublisherTest(5, true, new PublisherTestRun<T>() { // This test is skipped if the publisher is unbounded (never sends onComplete)
556556
@Override
557557
public void run(Publisher<T> pub) throws InterruptedException {
@@ -602,7 +602,7 @@ public void run(Publisher<T> pub) throws InterruptedException {
602602

603603
// Verifies rule: https://github.com/reactive-streams/reactive-streams#1.12
604604
@Override @Test
605-
public void required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws Throwable {
605+
public void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws Throwable {
606606
optionalActivePublisherTest(3, false, new PublisherTestRun<T>() { // This test is skipped if the publisher cannot produce enough elements
607607
@Override
608608
public void run(Publisher<T> pub) throws Throwable {
@@ -635,7 +635,7 @@ public void run(Publisher<T> pub) throws Throwable {
635635

636636
// Verifies rule: https://github.com/reactive-streams/reactive-streams#1.12
637637
@Override @Test
638-
public void required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws Throwable {
638+
public void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws Throwable {
639639
optionalActivePublisherTest(3, true, new PublisherTestRun<T>() { // This test is skipped if the publisher is unbounded (never sends onComplete)
640640
@Override
641641
public void run(Publisher<T> pub) throws Throwable {

tck/src/main/java/org/reactivestreams/tck/support/PublisherVerificationRules.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ public interface PublisherVerificationRules {
2626
void required_spec109_mayRejectCallsToSubscribeIfPublisherIsUnableOrUnwillingToServeThemRejectionMustTriggerOnErrorAfterOnSubscribe() throws Throwable;
2727
void untested_spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice() throws Throwable;
2828
void optional_spec111_maySupportMultiSubscribe() throws Throwable;
29-
void required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws Throwable;
30-
void required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws Throwable;
31-
void required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws Throwable;
29+
void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingOneByOne() throws Throwable;
30+
void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront() throws Throwable;
31+
void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfrontAndCompleteAsExpected() throws Throwable;
3232
void required_spec302_mustAllowSynchronousRequestCallsFromOnNextAndOnSubscribe() throws Throwable;
3333
void required_spec303_mustNotAllowUnboundedRecursion() throws Throwable;
3434
void untested_spec304_requestShouldNotPerformHeavyComputations() throws Exception;
@@ -42,4 +42,4 @@ public interface PublisherVerificationRules {
4242
void required_spec317_mustSupportAPendingElementCountUpToLongMaxValue() throws Throwable;
4343
void required_spec317_mustSupportACumulativePendingElementCountUpToLongMaxValue() throws Throwable;
4444
void required_spec317_mustNotSignalOnErrorWhenPendingAboveLongMaxValue() throws Throwable;
45-
}
45+
}

tck/src/test/java/org/reactivestreams/tck/PublisherVerificationTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ public void optional_spec111_maySupportMultiSubscribe_shouldFailBy_actuallyPass(
352352
}
353353

354354
@Test
355-
public void required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront_shouldFailBy_expectingOnError() throws Throwable {
355+
public void optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront_shouldFailBy_expectingOnError() throws Throwable {
356356
requireTestFailure(new ThrowingRunnable() {
357357
@Override public void run() throws Throwable {
358358
customPublisherVerification(new Publisher<Integer>() {
@@ -370,7 +370,7 @@ public void required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfI
370370
}
371371
});
372372
}
373-
}).required_spec112_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront();
373+
}).optional_spec111_multicast_mustProduceTheSameElementsInTheSameSequenceToAllOfItsSubscribersWhenRequestingManyUpfront();
374374
}
375375
}, "Expected elements to be signaled in the same sequence to 1st and 2nd subscribers: Lists differ at element ");
376376
}

0 commit comments

Comments
 (0)