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

Cleanup Map usage in AuthenticationInfo.requestAuthentication

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 19
    • None
    • core-libs
    • None
    • b26

      There is a HashMap<String,Thread> requests in class sun.net.www.protocol.http.AuthenticationInfo.

                  Thread t, c;
                  c = Thread.currentThread();
                  if ((t = requests.get(key)) == null) {
                      requests.put (key, c);
                      assert cached == null;
                      return cached;
                  }
                  if (t == c) {
                      assert cached == null;
                      return cached;
                  }
      Instead of separate HashMap.get/put calls we can improve code by HashMap.putIfAbsent.
      It results in cleaner and a bit faster code.

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

              Created:
              Updated:
              Resolved: