Skip to content

Close loopholes by refining 1.9 and 2.5 #325

Closed
@anthonyvdotbe

Description

@anthonyvdotbe

In my opinion, there exists a pair of loopholes in rules 1.9 and 2.5. In order to close those, I propose to change the rules as follows:

§1.9:

Publisher.subscribe MUST call onSubscribe on the provided Subscriber prior to any other signals to that Subscriber. Moreover, if the Subscription was cancelled by the Subscriber during the execution of onSubscribe, it is REQUIRED that no further signals occur. Publisher.subscribe MUST return normally, except when the provided Subscriber is null in which case it MUST throw a java.lang.NullPointerException to the caller, for all other situations [1] the only legal way to signal failure (or reject the Subscriber) is by calling onError (after calling onSubscribe).

(Concerning this change, specifically how the Publisher would know that the Subscription was cancelled during the execution of onSubscribe, please refer to this comment)

§2.5:

If a Subscriber receives an onSubscribe signal while it already has an active Subscription, it MUST NOT call Subscription.request() and MUST call Subscription.cancel() on the given Subscription.

These changes guarantee that a Subscriber is able to properly fend off intruding Publishers while it already has an active Subscription.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions