Skip to content

Commit ed86987

Browse files
committed
Removes the RECOMMENDED section from 1.10
The reason is that it is not meaningful, as the same Subscriber could be subscribed to several *different* Publishers at the same time. The spec already requires that a Subscriber is only subscribed to one Publisher, and only once. And the spec also is clear that the only legal way to reject a Subscription in a Publisher is by issuing an `onError` signal to it.
1 parent 48ef44f commit ed86987

File tree

3 files changed

+4
-70
lines changed

3 files changed

+4
-70
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public interface Publisher<T> {
8787
| <a name="1.7">7</a> | Once a terminal state has been signaled (`onError`, `onComplete`) it is REQUIRED that no further signals occur |
8888
| <a name="1.8">8</a> | If a `Subscription` is cancelled its `Subscriber` MUST eventually stop being signaled |
8989
| <a name="1.9">9</a> | Invoking `Publisher.subscribe` MUST return normally. The only legal way to signal failure (or reject a `Subscriber`) is via the `onError` method |
90-
| <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)]. It is RECOMMENDED to reject the `Subscription` with a `java.lang.IllegalStateException` if the same `Subscriber` already has an active `Subscription` with this `Publisher`. The cause message MUST include a reference to this rule and/or quote the full rule |
90+
| <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)] |
9191
| <a name="1.11">11</a> | A `Publisher` MAY support multi-subscribe and choose whether each `Subscription` is unicast or multicast |
9292
| <a name="1.12">12</a> | A `Publisher` MAY reject calls to its `subscribe` method if it is unable or unwilling to serve them [[1](#footnote-1-1)]. If rejecting it MUST do this by calling `onError` on the `Subscriber` passed to `Publisher.subscribe` instead of calling `onSubscribe` |
9393
| <a name="1.13">13</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 |

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

+2-10
Original file line numberDiff line numberDiff line change
@@ -381,17 +381,9 @@ public void spec109_subscribeShouldNotThrowNonFatalThrowable() throws Throwable
381381
}
382382

383383
// Verifies rule: https://github.com/reactive-streams/reactive-streams#1.10
384-
@Additional @Test
384+
@NotVerified @Test
385385
public void spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice() throws Throwable {
386-
optionalActivePublisherTest(3, false, new PublisherTestRun<T>() {
387-
@Override
388-
public void run(final Publisher<T> pub) throws Throwable {
389-
ManualSubscriber<T> sub = env.newManualSubscriber(pub);
390-
391-
pub.subscribe(sub);
392-
sub.expectErrorWithMessage(IllegalStateException.class, "1.10"); // we do require implementations to mention the rule number at the very least
393-
}
394-
});
386+
notVerified(); // can we meaningfully test this?
395387
}
396388

397389
// Verifies rule: https://github.com/reactive-streams/reactive-streams#1.11

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

+1-59
Original file line numberDiff line numberDiff line change
@@ -231,65 +231,7 @@ public void spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice
231231
@Override public void run() throws Throwable {
232232
noopPublisherVerification().spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice();
233233
}
234-
}, "Skipped because tested publisher does NOT implement this OPTIONAL requirement.");
235-
}
236-
237-
@Additional @Test
238-
public void spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice_shouldFailBy_signallingWrongException() throws Throwable {
239-
requireTestFailure(new ThrowingRunnable() {
240-
@Override public void run() throws Throwable {
241-
customPublisherVerification(new Publisher<Integer>() {
242-
volatile Subscriber subscriber = null;
243-
244-
@Override public void subscribe(Subscriber<? super Integer> s) {
245-
if (subscriber == null) {
246-
this.subscriber = s;
247-
s.onSubscribe(new Subscription() {
248-
@Override public void request(long n) {
249-
// noop
250-
}
251-
252-
@Override public void cancel() {
253-
// noop
254-
}
255-
});
256-
} else {
257-
// onErrors properly, but intentionally omits rule number
258-
s.onError(new RuntimeException("This is the wrong exception type, but in the right place [1.10]"));
259-
}
260-
}
261-
}).spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice();
262-
}
263-
}, "Got java.lang.RuntimeException but expected java.lang.IllegalStateException");
264-
}
265-
266-
@Additional @Test
267-
public void spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice_shouldFailBy_missingSpecReferenceInRightException() throws Throwable {
268-
requireTestFailure(new ThrowingRunnable() {
269-
@Override public void run() throws Throwable {
270-
customPublisherVerification(new Publisher<Integer>() {
271-
volatile Subscriber subscriber = null;
272-
273-
@Override public void subscribe(Subscriber<? super Integer> s) {
274-
if (subscriber == null) {
275-
this.subscriber = s;
276-
s.onSubscribe(new Subscription() {
277-
@Override public void request(long n) {
278-
// noop
279-
}
280-
281-
@Override public void cancel() {
282-
// noop
283-
}
284-
});
285-
} else {
286-
// onErrors properly, but intentionally omits rule number
287-
s.onError(new IllegalStateException("Sorry, I can only support one subscriber, and I have one already. See rule [XXX]"));
288-
}
289-
}
290-
}).spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice();
291-
}
292-
}, "Got expected exception [class java.lang.IllegalStateException] but missing message part [1.10]");
234+
}, "Not verified by this TCK.");
293235
}
294236

295237
@Test

0 commit comments

Comments
 (0)