src/java.base/share/classes/java/net/URL.java
changeset 52638 f39854fffca0
parent 52499 768b1c612100
child 52694 93afbb11063b
--- a/src/java.base/share/classes/java/net/URL.java	Wed Nov 21 09:40:19 2018 -0500
+++ b/src/java.base/share/classes/java/net/URL.java	Wed Nov 21 15:09:27 2018 +0000
@@ -1393,39 +1393,39 @@
             }
         }
 
-        synchronized (streamHandlerLock) {
-            if (handler == null) {
-                // Try the built-in protocol handler
-                handler = defaultFactory.createURLStreamHandler(protocol);
-            } else {
-                URLStreamHandler handler2 = null;
-
-                // Check again with hashtable just in case another
-                // thread created a handler since we last checked
-                handler2 = handlers.get(protocol);
+        if (handler == null) {
+            // Try the built-in protocol handler
+            handler = defaultFactory.createURLStreamHandler(protocol);
+        }
 
-                if (handler2 != null) {
-                    return handler2;
-                }
+        synchronized (streamHandlerLock) {
+            URLStreamHandler handler2 = null;
 
-                // Check with factory if another thread set a
-                // factory since our last check
-                if (!checkedWithFactory && (fac = factory) != null) {
-                    handler2 = fac.createURLStreamHandler(protocol);
-                }
+            // Check again with hashtable just in case another
+            // thread created a handler since we last checked
+            handler2 = handlers.get(protocol);
 
-                if (handler2 != null) {
-                    // The handler from the factory must be given more
-                    // importance. Discard the default handler that
-                    // this thread created.
-                    handler = handler2;
-                }
+            if (handler2 != null) {
+                return handler2;
             }
 
-            // Insert this handler into the hashtable
-            if (handler != null) {
-                handlers.put(protocol, handler);
+            // Check with factory if another thread set a
+            // factory since our last check
+            if (!checkedWithFactory && (fac = factory) != null) {
+                handler2 = fac.createURLStreamHandler(protocol);
             }
+
+            if (handler2 != null) {
+                // The handler from the factory must be given more
+                // importance. Discard the default handler that
+                // this thread created.
+                handler = handler2;
+            }
+        }
+
+        // Insert this handler into the hashtable
+        if (handler != null) {
+            handlers.put(protocol, handler);
         }
 
         return handler;