Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8210149

Example in JavaDoc for java.util.concurrent.Flow violates Reactive Streams spec

    XMLWordPrintable

Details

    Description

      A DESCRIPTION OF THE PROBLEM :
      The JavaDoc of java.util.concurrent.Flow has an example of a Publisher implementation called OneShotPublisher. If a subscription has already been registered when a second subscription request runs, then the provided Subscriber object will have his onError method called immediately without a preceding call to the onSubscribe method.

      Well, this is wrong according to the reactive-streams spec, paragraph 1.9;

      "Publisher.subscribe MUST call onSubscribe on the provided Subscriber prior to any other signals to that Subscriber [...] the only legal way to signal failure (or reject the Subscriber) is by calling onError (after calling onSubscribe)."

      I think the JavaDoc example could be indicative that the reactive-streams spec should change; i.e., it should be allowed to call the onError method before calling the onSubscribe? However that might be, the current example is still in violation of the reactive-streams spec.

      Paragraph link: https://github.com/reactive-streams/reactive-streams-jvm/tree/9464664fb98011e0d1cf976ce22951fe08963469#1.9


      Attachments

        Activity

          People

            dl Doug Lea
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: