You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2009/10/11 05:57:21 UTC

svn commit: r824014 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java

Author: ndbeyer
Date: Sun Oct 11 03:57:21 2009
New Revision: 824014

URL: http://svn.apache.org/viewvc?rev=824014&view=rev
Log:
remove unnecessary instanceof check, add synchronized blocks to protect class field

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java?rev=824014&r1=824013&r2=824014&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URLConnection.java Sun Oct 11 03:57:21 2009
@@ -232,9 +232,6 @@
 
         if (contentHandlerFactory != null) {
             cHandler = contentHandlerFactory.createContentHandler(type);
-            if (!(cHandler instanceof ContentHandler)) {
-                throw new UnknownServiceException();
-            }
             contentHandlers.put(type, cHandler);
             return (ContentHandler) cHandler;
         }
@@ -399,10 +396,12 @@
         // Must use lazy initialization or there is a bootstrap problem
         // trying to load the MimeTable resource from a .jar before
         // JarURLConnection has finished initialization.
-        if (fileNameMap == null) {
-            fileNameMap = new MimeTable();
+        synchronized (URLConnection.class) {
+            if (fileNameMap == null) {
+                fileNameMap = new MimeTable();
+            }
+            return fileNameMap;
         }
-        return fileNameMap;
     }
 
     /**
@@ -905,7 +904,9 @@
         if (manager != null) {
             manager.checkSetFactory();
         }
-        fileNameMap = map;
+        synchronized (URLConnection.class) {
+            fileNameMap = map;
+        }
     }
 
     /**