-
Notifications
You must be signed in to change notification settings - Fork 534
TCK PublisherVerification does not support publishers of empty streams #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@gnp Thanks for opening this Issue, we should definitely fix this. |
It is important to note that it needs to send both |
Good catch @gnp, thanks for noticing this! We definitely want to support all kinds of valid publishers (recently made it possible for never-onComplete-calling publishers to be tested as well etc). I'll draft a PR to address this soon :) |
While updating the TCK to support this (that's the easy part) I found that the spec is not precise about if calling // EagerEmptyStream - I assume the spec intends to not allow these
return new Publisher<Integer>() {
@Override
public void subscribe(Subscriber<? super Integer> s) {
s.onComplete();
}
}; The only rules which talk more or less around this area (yet do not prohibit it) are:
So the wording of 1.9 more or less seems to imply that we can only "early onError", and not "early onComplete", although it is not stated explicitly, and since completion is not really "failing" I'd say that the onComplete being eager is not specified - and I'm not sure according to the spec if the above Publisher is legal. Currently the TCK assumed that an onComplete coming in before an onSubscribe is NOT legal, thus I bumped into this case. I can update the TCK to be OK with this in the "empty stream" case of course, but it should be backed by some spec rule I think. Of course a fully legal and "complete" way to signal this completion is via "complete only once demand is signalled": return new Publisher<Integer>() {
@Override
public void subscribe(final Subscriber<? super Integer> s) {
s.onSubscribe(new Subscription() {
@Override
public void request(long n) {
s.onComplete();
}
@Override
public void cancel() {
// noop
}
});
}
}; Which does not have any ambiguity problems with the spec AFAICS. TL;DR: I think we should include some wording in the spec which that explicitly states an onComplete may only be signalled an onSubscribe has been signalled. The current wording does not seem to be precise enough about this I think. // cc @viktorklang |
I find that it is best illustrated in the readme just before the spec: In response to a call to Publisher.subscribe(Subscriber) the possible invocation sequences for methods on the Subscriber are given by the following protocol:
`onError | (onSubscribe onNext* (onError | onComplete)?)` I'll answer more in detail later :) |
Yeah, I did notice that sequence-of-calls diagram, but it's not really reinforced by the spec rules - thought that it would be perhaps safer to extend wording somewhere (1.9?) to do so as well |
PR submitted #199 |
tracking the |
+tck #198 allow 0-length publishers to be tested
This code in the
PublisherVerification
class:Causes an
EmptyPublisher
class representing an empty stream to fail conformance testing.An empty stream may be an edge case but it is a legitimate stream, and a Reactive Streams implementation should be able to have such a
Publisher
. One use case would be testing thatSubscriber
s operate correctly when subscribed to empty streams.Therefore, TCK should allow a subclass of
PublisherVerification
to return zero frommaxElemensFromPublisher()
, and if it does TCK should test thatrequest()
-ing any elements at all from thePublisher
results in only a call to theSubscriber
'sonComplete()
.The text was updated successfully, but these errors were encountered: