Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8288330

Avoid redundant ConcurrentHashMap.get call in Http2ClientImpl.deleteConnection

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 20
    • None
    • core-libs
    • None
    • b03

      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.

            aturbanov Andrey Turbanov
            aturbanov Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: