On Fri, 6 May 2022 09:14:53 GMT, Daniel Fuchs <[email protected]> wrote:
>> src/java.net.http/share/classes/jdk/internal/net/http/HttpClientImpl.java
>> line 1039:
>>
>>> 1037: e.abort(selectorClosedException());
>>> 1038: } else {
>>> 1039: selector.wakeup();
>>
>> Hello Daniel, before this PR, except for the `wakeupSelector()` method on
>> `SelectorManager`, all other methods which were operating on the `selector`
>> field were `synchronized` on the `SelectorManager` instance. After this PR,
>> that continues to be true except for this specific line where the operation
>> on the `selector` field is outside of a `synchronized` block. Would that be
>> OK?
>
> And this is what (or at least a part of what) was causing the issue. We need
> to add the event to the `registrations` list within a synchronized block
> because that's a plain ArrayList whose access is controlled by synchronizing
> on `this`. However the event should not be invoked within the synchronized
> and block, and if you look at the calling method (eventUpdated) you will see
> that this is what we are doing there too (raising the event without
> synchronizing).
Thank you for that explanation. I understand this change better now.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8562