diff --git a/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java b/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java index 1fbf5def0a6d7229bea672361946a85581d7a041..6115401ff029c70d646fc606072bb2c7c1f8eca7 100644 --- a/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java +++ b/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java @@ -111,7 +111,7 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone * at the same time, then all but the first will block until * the first completes its authentication. */ - static private HashMap requests = new HashMap (); + static private HashMap requests = new HashMap<>(); /* check if a request for this destination is in progress * return false immediately if not. Otherwise block until @@ -125,7 +125,7 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone synchronized (requests) { Thread t, c; c = Thread.currentThread(); - if ((t=(Thread)requests.get(key))==null) { + if ((t = requests.get(key)) == null) { requests.put (key, c); return false; } @@ -147,8 +147,11 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone */ static private void requestCompleted (String key) { synchronized (requests) { - boolean waspresent = requests.remove (key) != null; - assert waspresent; + Thread thread = requests.get(key); + if (thread != null && thread == Thread.currentThread()) { + boolean waspresent = requests.remove(key) != null; + assert waspresent; + } requests.notifyAll(); } } diff --git a/test/ProblemList.txt b/test/ProblemList.txt index 43d53e18b12a07157723e28453eefd1948c06d39..ddcd68d3624a45343373a3a57bf6aa12516c638a 100644 --- a/test/ProblemList.txt +++ b/test/ProblemList.txt @@ -692,7 +692,6 @@ java/net/URLConnection/TimeoutTest.java generic-all java/net/URLConnection/ZeroContentLength.java generic-all # Solaris 11 i586 fails with samevm, not sure why -java/net/Authenticator/B4769350.java generic-all java/net/HttpURLConnection/HttpResponseCode.java generic-all java/net/ResponseCache/B6181108.java generic-all java/net/ResponseCache/ResponseCacheTest.java generic-all diff --git a/test/java/net/Authenticator/B4769350.java b/test/java/net/Authenticator/B4769350.java index e21cd869daf98f06de7977f5bdcf2c391b2ca519..1f6737635080e659f44901fb55814db2511f9669 100644 --- a/test/java/net/Authenticator/B4769350.java +++ b/test/java/net/Authenticator/B4769350.java @@ -26,9 +26,12 @@ * @bug 4769350 * @library ../../../sun/net/www/httptest/ * @build HttpCallback HttpServer ClosedChannelList HttpTransaction AbstractCallback - * @run main B4769350 server - * @run main B4769350 proxy + * @run main/othervm B4769350 server + * @run main/othervm B4769350 proxy * @summary proxy authentication username and password caching only works in serial case + * Run in othervm since the test sets system properties that are read by the + * networking stack and cached when the HTTP handler is invoked, and previous + * tests may already have invoked the HTTP handler. */ import java.io.*;