From ed86987558eaebfaee1967fc703db74601b7d9be Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Sun, 21 Dec 2014 19:36:58 +0100 Subject: [PATCH] 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. --- README.md | 2 +- .../tck/PublisherVerification.java | 12 +--- .../tck/PublisherVerificationTest.java | 60 +------------------ 3 files changed, 4 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index f209044b..069969fb 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ public interface Publisher { | 7 | Once a terminal state has been signaled (`onError`, `onComplete`) it is REQUIRED that no further signals occur | | 8 | If a `Subscription` is cancelled its `Subscriber` MUST eventually stop being signaled | | 9 | Invoking `Publisher.subscribe` MUST return normally. The only legal way to signal failure (or reject a `Subscriber`) is via the `onError` method | -| 10 | `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 | +| 10 | `Publisher.subscribe` MAY be called as many times as wanted but MUST be with a different `Subscriber` each time [see [2.12](#2.12)] | | 11 | A `Publisher` MAY support multi-subscribe and choose whether each `Subscription` is unicast or multicast | | 12 | 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` | | 13 | 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 | diff --git a/tck/src/main/java/org/reactivestreams/tck/PublisherVerification.java b/tck/src/main/java/org/reactivestreams/tck/PublisherVerification.java index 9bafdfae..f879edab 100644 --- a/tck/src/main/java/org/reactivestreams/tck/PublisherVerification.java +++ b/tck/src/main/java/org/reactivestreams/tck/PublisherVerification.java @@ -381,17 +381,9 @@ public void spec109_subscribeShouldNotThrowNonFatalThrowable() throws Throwable } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.10 - @Additional @Test + @NotVerified @Test public void spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice() throws Throwable { - optionalActivePublisherTest(3, false, new PublisherTestRun() { - @Override - public void run(final Publisher pub) throws Throwable { - ManualSubscriber sub = env.newManualSubscriber(pub); - - pub.subscribe(sub); - sub.expectErrorWithMessage(IllegalStateException.class, "1.10"); // we do require implementations to mention the rule number at the very least - } - }); + notVerified(); // can we meaningfully test this? } // Verifies rule: https://github.com/reactive-streams/reactive-streams#1.11 diff --git a/tck/src/test/java/org/reactivestreams/tck/PublisherVerificationTest.java b/tck/src/test/java/org/reactivestreams/tck/PublisherVerificationTest.java index 8961bebb..ba61e69c 100644 --- a/tck/src/test/java/org/reactivestreams/tck/PublisherVerificationTest.java +++ b/tck/src/test/java/org/reactivestreams/tck/PublisherVerificationTest.java @@ -231,65 +231,7 @@ public void spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice @Override public void run() throws Throwable { noopPublisherVerification().spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice(); } - }, "Skipped because tested publisher does NOT implement this OPTIONAL requirement."); - } - - @Additional @Test - public void spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice_shouldFailBy_signallingWrongException() throws Throwable { - requireTestFailure(new ThrowingRunnable() { - @Override public void run() throws Throwable { - customPublisherVerification(new Publisher() { - volatile Subscriber subscriber = null; - - @Override public void subscribe(Subscriber s) { - if (subscriber == null) { - this.subscriber = s; - s.onSubscribe(new Subscription() { - @Override public void request(long n) { - // noop - } - - @Override public void cancel() { - // noop - } - }); - } else { - // onErrors properly, but intentionally omits rule number - s.onError(new RuntimeException("This is the wrong exception type, but in the right place [1.10]")); - } - } - }).spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice(); - } - }, "Got java.lang.RuntimeException but expected java.lang.IllegalStateException"); - } - - @Additional @Test - public void spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice_shouldFailBy_missingSpecReferenceInRightException() throws Throwable { - requireTestFailure(new ThrowingRunnable() { - @Override public void run() throws Throwable { - customPublisherVerification(new Publisher() { - volatile Subscriber subscriber = null; - - @Override public void subscribe(Subscriber s) { - if (subscriber == null) { - this.subscriber = s; - s.onSubscribe(new Subscription() { - @Override public void request(long n) { - // noop - } - - @Override public void cancel() { - // noop - } - }); - } else { - // onErrors properly, but intentionally omits rule number - s.onError(new IllegalStateException("Sorry, I can only support one subscriber, and I have one already. See rule [XXX]")); - } - } - }).spec110_rejectASubscriptionRequestIfTheSameSubscriberSubscribesTwice(); - } - }, "Got expected exception [class java.lang.IllegalStateException] but missing message part [1.10]"); + }, "Not verified by this TCK."); } @Test