RFR: 8297149: REDO JDK-8296889: Race condition when cancelling a request
Jaikiran Pai
jpai at openjdk.org
Thu Nov 17 01:33:54 UTC 2022
On Wed, 16 Nov 2022 18:52:42 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
> Please find here a re-do fix for the race condition while cancelling request.
> The previous fix failed because it registered the subscriber too late (after having called userSubsciber.onSubscribe()), which opened a window for the call to unregister to occur before the call to register.
> This is fixed in this new iteration.
src/java.net.http/share/classes/jdk/internal/net/http/common/HttpBodySubscriberWrapper.java line 188:
> 186: // race condition with propagateError: we need to wait until
> 187: // subscription is finished before calling onError;
> 188: subscriptionLock.lock();
More of a question than a review comment - I see that the only place in this class where we were using `synchronized` is while dealing with the `subscribed`. The PR replaces the `synchronized` blocks with a `ReentrantLock`. Does that have an advantage in context of this code?
-------------
PR: https://git.openjdk.org/jdk/pull/11193
More information about the net-dev
mailing list