Merge
authorksrini
Tue, 12 Oct 2010 12:20:44 -0700
changeset 6889 6afd3474895b
parent 6888 83b7b1e3301c (current diff)
parent 6887 b74bcf130b67 (diff)
child 6890 43cb79a6b123
Merge
--- a/jdk/src/share/classes/sun/net/www/MimeTable.java	Thu Oct 07 14:35:14 2010 -0700
+++ b/jdk/src/share/classes/sun/net/www/MimeTable.java	Tue Oct 12 12:20:44 2010 -0700
@@ -73,29 +73,32 @@
 
     private static final String filePreamble = "sun.net.www MIME content-types table";
     private static final String fileMagic = "#" + filePreamble;
-    private static MimeTable defaultInstance = null;
 
     MimeTable() {
         load();
     }
 
+    private static class DefaultInstanceHolder {
+        static final MimeTable defaultInstance = getDefaultInstance();
+
+        static MimeTable getDefaultInstance() {
+            return java.security.AccessController.doPrivileged(
+                new java.security.PrivilegedAction<MimeTable>() {
+                public MimeTable run() {
+                    MimeTable instance = new MimeTable();
+                    URLConnection.setFileNameMap(instance);
+                    return instance;
+                }
+            });
+        }
+    }
+
     /**
      * Get the single instance of this class.  First use will load the
      * table from a data file.
      */
     public static MimeTable getDefaultTable() {
-        if (defaultInstance == null) {
-            java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction<Void>() {
-                    public Void run() {
-                    defaultInstance = new MimeTable();
-                    URLConnection.setFileNameMap(defaultInstance);
-                    return null;
-                }
-            });
-        }
-
-        return defaultInstance;
+        return DefaultInstanceHolder.defaultInstance;
     }
 
     /**