[concurrency-interest] Flow/SubmissionPublisher review

Dávid Karnok akarnokd at gmail.com
Thu Sep 24 04:13:49 EDT 2015

Hello. Since the class(es) and the JEPS have been updated recently, I'd
like to review them again:



"Also, one method in class Flow might benefit from additional support in
java.util.streams, but it is usable as-is."

I don't see any j.u.s.Stream-related methods in v1.28 @
 or in SubmissionPublisher.


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


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

status.whenComplete((v, e) -> subscription.cancel());

in onSubscribe() which should issue a cancel the moment status is completed

Best regards,
David Karnok
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20150924/1fe383b1/attachment.html>

More information about the Concurrency-interest mailing list