eclipse / microprofile-reactive-streams-operators

Microprofile project
Apache License 2.0
79 stars 33 forks source link

FlatMapStageVerification.InnerSubscriberVerification rule 2.9 #133

Closed danielkec closed 4 years ago

danielkec commented 4 years ago

Hi, I am not sure if understood it correctly but it seems that required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall is being tested on the FlatMap inner subscriber by expecting onComplete being sent to downstream when onComplete of the inner subscriber is invoked.

Seams to me weird a little, I would expect that every inner publisher in flatMap operator calls onComplete when it finishes, but that onComplete is not propagated downstream until upstream finishes/sends onComplete.

Also subscriber for FlatMapStageVerification.InnerSubscriberVerification is prepared like this:

            rs.of(rs.<Integer>fromPublisher(subscriber::complete))
                .flatMap(Function.identity())
                .to(new Subscriber<Integer>() {
                    @Override
                    public void onSubscribe(Subscription subscription) {
                        // We need to initially request an element to ensure that we get the publisher.
                        subscription.request(1);

Which seems to make required_spec209_mustBePreparedToReceiveAnOnCompleteSignalWithoutPrecedingRequestCall test even less applicable, there shouldn't be any preceding request.

Not sure how to address this and would appreciate any help.

akarnokd commented 4 years ago

rs.of will create a sigleton with rs.<Integer>fromPublisher(subscriber::complete) so both the upstream of flatMap and the only inner source will signal onComplete, thus the downstream subscriber can complete without any items immediately. I think the subscriber.request(1) is there because some implementations of flatMap may not start consuming rs.of until there is at least some demand from the downstream.

Emily-Jiang commented 4 years ago

@danielkec does the response from @akarnokd answer your question? Is this still an issue? If not, can you close this?

danielkec commented 4 years ago

I get it now, thx