RFR: 8296889: Race condition when cancelling a request

Daniel Fuchs dfuchs at openjdk.org
Tue Nov 15 14:28:02 UTC 2022


On Tue, 15 Nov 2022 08:54:39 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

> Hello Daniel, from what I understand, before the change in this PR, we used to add the subscriber to an internal collection in the HttpClient even before the subscription was done. That would then mean the callbacks that are related to a subscription wouldn't be invoked, in certain cases (for example the request cancellation). Since we do the unregistration in these callbacks, the registered subscriber would not be removed from the HttpClient's collection. Did I understand this right? If so, your change looks good to me.

Yes - if the cancellation happens after the subscriber is registered in the collection, but before the subscriber is subscribed, then the subscriber may never subscribe, and therefore might never be canceled. If it doesn't get cancelled (or completed) then it won't be removed from the collection. Therefore, adding it to the collection at the time it is subscribed should ensure that it gets removed from the collection, because the expectation is that once subscribed it MUST either be completed successfully, completed exceptionally, or cancelled, and any of these three actions will take it out of the collection (which was the object of my previous fix in this area).

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

PR: https://git.openjdk.org/jdk/pull/11110


More information about the net-dev mailing list