Skip to content

Ensure TCK passes with empty publisher that synchronously completes #423

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

Conversation

jroper
Copy link
Contributor

@jroper jroper commented Jan 2, 2018

Fixes #422

@@ -599,6 +602,7 @@ public void onSubscribe(Subscription s) {
env.debug(String.format("%s::onSubscribe(%s)", this, s));
if (!subscription.isCompleted()) {
subscription.complete(s);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a completeImmediately() method on the promise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw. the plain complete() behavior is odd. I'd think once called, isCompleted() should report true but the implementation queues the object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree - but I'm not familiar enough with the TCK to change it. Though I can understand why the event is queued, so that the order of events can be verified and duplicates can be detected etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll investigate this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing, I think we can improve the impl there. I'll work on it today after done with work stuff.
I'll PR into this PR then :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reimplemented the Promise which makes this workwithout the additional atomic.
Please see here: jroper#1

@viktorklang
Copy link
Contributor

Thanks @jroper!

@Override
     public void onNext(T element) {
       env.debug(String.format("%s::onNext(%s)", this, element));
       if (subscription.isCompleted()) { // Shouldn't this be onSubscribeCalled.get() too? (for subscribe + onSubscribe + sync request(n) + onNext?
         super.onNext(element);
       } else {
         env.flop(String.format("Subscriber::onNext(%s) called before Subscriber::onSubscribe", element));
       }
     }

@jroper
Copy link
Contributor Author

jroper commented Jan 4, 2018

I thought about changing onNext, however, the manual subscriber will never invoke Subscription.request before invoking expectCompletion, so I think that logic is still valid, even if the error message is a little odd. My worry with changing it is that there might be some tests that depend on the current behaviour.

} catch (SkipException skip) {
throw new RuntimeException("Expected TCK to PASS this test, instead it was SKIPPED", skip.getCause());
} catch (Throwable throwable) {
throw new RuntimeException(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repackage Errors as Exceptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just being consistent with requireTestFailure and requireTestSkip.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not really matter much as those will end up failing the test in the suite and one may always look into the logs. It's not like it's a production app where we have to watch out to not accidentally continue after an OOM or something... Fine as is I think

@ktoso
Copy link
Contributor

ktoso commented Jan 8, 2018

I submitted an impl improvement of the Promise which makes the test pass the new requirement:
jroper#1

I submitted the change as PR into this PR, so if you accept it over there @jroper we could merge all those commits rebased here together I guess.

@viktorklang
Copy link
Contributor

@jroper @ktoso Hey all, I just wanted to know what the current status is here.

@ktoso
Copy link
Contributor

ktoso commented Jan 31, 2018

I would like @jroper to merge the fix I proposed to this PR, it's been waiting ;-)
jroper#1

Improve Promise impl to make the test valid without adding onSubscribeCalled
@ktoso
Copy link
Contributor

ktoso commented Jan 31, 2018

PR was merged, thanks @jroper ! Seems good to go from my side then

@viktorklang
Copy link
Contributor

thanks @jroper!

@viktorklang viktorklang merged commit 0a47f63 into reactive-streams:master Jan 31, 2018
@viktorklang viktorklang modified the milestones: 1.0.2, 1.0.3 Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants