RFR: 8252374: Add a new factory method to concatenate a sequence of BodyPublisher instances into a single publisher. [v6]
Pavel Rappo
prappo at openjdk.java.net
Mon Oct 5 10:19:37 UTC 2020
On Mon, 5 Oct 2020 09:40:14 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> src/java.net.http/share/classes/jdk/internal/net/http/RequestPublishers.java line 569:
>>
>>> 567: this.bodies = new ConcurrentLinkedQueue<>(bodies);
>>> 568: this.subscriber = subscriber;
>>> 569: scheduler = SequentialScheduler.synchronizedScheduler(this::run);
>>
>> It's a little unpleasant that this call to the scheduler is inside the constructor. I wonder if it could be located in
>> the subscribe method above, just after the subscription is created? (since both classes are in the same nest )
>
> Scheduler is a final variable in `AggregateSubscription`. Fixed to:
>
> ` this.scheduler = ....;`
>
> (though the `this.` is not strictly needed in this third instantiation)
Daniel, I believe Chris' concern is the escape of `this` before the (`AggregateSubscription`) object is fully
constructed.
-------------
PR: https://git.openjdk.java.net/jdk/pull/57
More information about the net-dev
mailing list