--- 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;
}
/**