Correct me if I'm wrong, but this may leak 'this' from the constructor and submit may end up being called before the constructor sealed the final fields.
Line 830: consume()
Line 839: ConsumerSubscriber
If one cancels the CompletableFuture after the subscribe() returns but before an async submit() call, the ConsumerSubscriber does not cancel its subscription up until said submit call reaches the ConsumerSubscriber.onNext (if no submit() call happens, the SubmissionPublisher will leak whatever is captured through the Consumer instance). What I'd do is to call
The stream-based methods were removed because we were not satisfied with current implementation approaches. We might be able to do something better at some point in the future. Before the JEP is targeted i will update the dependency section.
On 09/24/2015 04:13 AM, Dávid Karnok wrote:
> Hello. Since the class(es) and the JEPS have been updated recently, I'dlike to
> review them again:
> http://openjdk.java.net/jeps/266 >
> "Also, one method in class |Flow |might benefit from additional supportin
> |java.util.streams|, but it is usable as-is."
> I don't see any j.u.s.Stream-related methodsin v1.28 @
As Paul mentioned, these got triaged out at least in the near term.
Without further j.u.s.Stream integration, the implementation
options are either to wait for publisher to complete, or to
treat as an IO-like item-by-item blocking stream,
neither of which are what people normally want or expect.
We felt that it was better not to introduce this or
related method into jdk yet until something better can be done.
> Lines 89-90:
> * periodicTask = scheduler.scheduleAtFixedRate(
> * () -> submit(supplier.get()), 0, period, unit);
> Correct me if I'm wrong, but this may leak 'this' from the constructor and
> submit may end up being called before the constructor sealed the final fields.
I would ordinarily agree that an example that starts a service or
thread in a constructor is too delicate for a javadoc example.
But this usage is convenient and OK because of the intrinsic
properties of ScheduledThreadPoolExecutor (all writes before
first thread creation happen-before reads by that thread, etc).
> Line 830: consume() ...
> What I'd do is to call
> status.whenComplete((v, e) -> subscription.cancel());