Method Http2ClientImpl.deleteConnection removes Http2Connection from ConcurrentHashMap 'connections' if it's present in the map. It performs this with 2 steps: first invoke ConcurrentHashMap.get and then check if result of 'get' is equals to parameter.
synchronized (this) {
Http2Connection c1 = connections.get(c.key());
if (c1 != null && c1.equals(c)) {
connections.remove(c.key());
if (debug.on())
debug.log("removed from the connection pool: %s", c);
}
}
We can do better: there is single method 'ConcurrentHashMap.remove(Key, Value)' which does the same thing, but faster.
synchronized (this) {
Http2Connection c1 = connections.get(c.key());
if (c1 != null && c1.equals(c)) {
connections.remove(c.key());
if (debug.on())
debug.log("removed from the connection pool: %s", c);
}
}
We can do better: there is single method 'ConcurrentHashMap.remove(Key, Value)' which does the same thing, but faster.