On Wed, 15 Jun 2022 18:17:39 GMT, Andrey Turbanov <aturba...@openjdk.org> wrote:

>> https://github.com/openjdk/jdk/blob/900d967da52afca9b239d8a58aa81b48b9fe0a78/src/java.net.http/share/classes/jdk/internal/net/http/Http2ClientImpl.java#L191-L196
>> 
>> Method `Http2ClientImpl.deleteConnection` removes `Http2Connection` from 
>> `ConcurrentHashMap` if it's present in the map. It does it with 2 steps: 
>> first invoke `ConcurrentHashMap.get` and then check if result of `get` is 
>> equals to parameter.
>> 
>> We can do better: there is single method `ConcurrentHashMap.remove(Key, 
>> Value)` which does the same thing, but faster.
>> 
>> Testing: `test/jdk/java/net/httpclient` on Win x64 release.
>
> src/java.net.http/share/classes/jdk/internal/net/http/Http2ClientImpl.java 
> line 190:
> 
>> 188:         if (debug.on())
>> 189:             debug.log("removing from the connection pool: %s", c);
>> 190:         synchronized (this) {
> 
> BTW, this `synchronized` seems redundant now too.

Yes, possibly. We'd be relying on internal CHM synchronization if we removed 
that - there may be some side effects with other synchronized blocks in 
Http2ClientImpl. Let's not go into this right now.

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

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

Reply via email to