-
Notifications
You must be signed in to change notification settings - Fork 534
PublisherVerification.optional_spec105_emptyStreamMustTerminateBySignallingOnComplete fails if the publisher completes synchronously #422
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
(Oops, wrong 105 method). RxJava and Reactive4JavaFlow both pass so I don't think there is anything nothing wrong with the TCK in this regard. Did you override maxElementsFromPublisher to return zero? |
This passes (but skips 38 of the 42 tests due to max length == 0): import org.reactivestreams.*;
import org.reactivestreams.tck.*;
import org.testng.annotations.Test;
@Test
public class EmptyPublisherTckTest extends PublisherVerification<Integer> {
public EmptyPublisherTckTest() {
super(new TestEnvironment(50));
}
@Override
public Publisher<Integer> createPublisher(long elements) {
return subscriber -> {
subscriber.onSubscribe(new Subscription() {
@Override
public void request(long n) {
}
@Override
public void cancel() {
}
});
subscriber.onComplete();
};
}
@Override
public Publisher<Integer> createFailedPublisher() {
return null;
}
@Override
public long maxElementsFromPublisher() {
return 0;
}
} |
It's as @akarnokd writes. If your publisher is not able to emit many elements, you have to specify this by overriding the |
The error message could be better, perhaps add a hint if onComplete happens
before expected? (please override / verify max number of elements)
…--
Cheers,
√
On Dec 29, 2017 12:46, "ktoso" ***@***.***> wrote:
It's as @akarnokd <https://github.com/akarnokd> writes. If your publisher
is not able to emit many elements, you have to specify this by overriding
the maxElementsFromPublisher method, so then tests which require elements
to flow are skipped.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#422 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAqd58AIFpraGLrGxJnrSPEMYqiY_6bks5tFNEAgaJpZM4ROz7C>
.
|
But |
The tests expect you to provide |
I understand that. Here's the test: Here's the code: @Override @Test
public void optional_spec105_emptyStreamMustTerminateBySignallingOnComplete() throws Throwable {
optionalActivePublisherTest(0, true, new PublisherTestRun<T>() {
@Override
public void run(Publisher<T> pub) throws Throwable {
ManualSubscriber<T> sub = env.newManualSubscriber(pub);
sub.request(1);
sub.expectCompletion();
sub.expectNone();
}
});
} It's requesting a publisher of zero elements. This is a publisher of zero elements: Publisher publisher = subscriber -> {
subscriber.onSubscribe(new Subscription() {
public void request(long n) {}
public void cancel() {}
});
subscriber.onComplete();
}; It should pass that one test, right? Of course it won't pass the other tests, but it should pass the test that tests for an empty publisher, right? It's not passing. |
I've created a PR that fixes the issue. As you can see, in the PR, I've implemented a test that reproduces it - and in that test, as suggested, I did create a publisher that returned zero from |
Consider the following empty publisher:
I believe this is a valid publisher according to the spec, there's nothing that says that
onComplete
can't be synchronously invoked fromsubscribe
, it just has to be invoked afteronSusbscribe
(it is).However
PublisherVerification.optional_spec105_emptyStreamMustTerminateBySignallingOnComplete
, a test for empty publishers which should pass on the above publisher, fails withjava.lang.AssertionError: Subscriber::onComplete() called before Subscriber::onSubscribe
.The problem seems to be that
ManualSubscriberWithSubscriptionSupport
requiresexpectCompletion
to be invoked afteronSubscribe
and beforeonComplete
is invoked. ButexpectCompletion
isn't invoked until aftersubscribe
returns, hence synchronous invocation ofonComplete
afteronSusbcribe
in thesubscribe
method will always fail.The text was updated successfully, but these errors were encountered: