[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:

---------------

http://openjdk.java.net/jeps/266

"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 @
http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/Flow.java?view=markup
 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
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

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

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



-- 
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