jdk/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java
changeset 38887 bb8ffdf4e7aa
parent 35311 613162418a3d
equal deleted inserted replaced
38886:bf687d4281eb 38887:bb8ffdf4e7aa
    92     private static boolean isUserRootWritable;
    92     private static boolean isUserRootWritable;
    93 
    93 
    94    /**
    94    /**
    95      * The user root.
    95      * The user root.
    96      */
    96      */
    97     static Preferences userRoot = null;
    97     private static volatile Preferences userRoot;
    98 
    98 
    99     static synchronized Preferences getUserRoot() {
    99     static Preferences getUserRoot() {
   100         if (userRoot == null) {
   100         Preferences root = userRoot;
   101             setupUserRoot();
   101         if (root == null) {
   102             userRoot = new FileSystemPreferences(true);
   102             synchronized (FileSystemPreferences.class) {
   103         }
   103                 root = userRoot;
   104         return userRoot;
   104                 if (root == null) {
       
   105                     setupUserRoot();
       
   106                     userRoot = root = new FileSystemPreferences(true);
       
   107                 }
       
   108             }
       
   109         }
       
   110         return root;
   105     }
   111     }
   106 
   112 
   107     private static void setupUserRoot() {
   113     private static void setupUserRoot() {
   108         AccessController.doPrivileged(new PrivilegedAction<Void>() {
   114         AccessController.doPrivileged(new PrivilegedAction<Void>() {
   109             public Void run() {
   115             public Void run() {
   153 
   159 
   154 
   160 
   155     /**
   161     /**
   156      * The system root.
   162      * The system root.
   157      */
   163      */
   158     static Preferences systemRoot;
   164     private static volatile Preferences systemRoot;
   159 
   165 
   160     static synchronized Preferences getSystemRoot() {
   166     static Preferences getSystemRoot() {
   161         if (systemRoot == null) {
   167         Preferences root = systemRoot;
   162             setupSystemRoot();
   168         if (root == null) {
   163             systemRoot = new FileSystemPreferences(false);
   169             synchronized (FileSystemPreferences.class) {
   164         }
   170                 root = systemRoot;
   165         return systemRoot;
   171                 if (root == null) {
       
   172                     setupSystemRoot();
       
   173                     systemRoot = root = new FileSystemPreferences(false);
       
   174                 }
       
   175             }
       
   176         }
       
   177         return root;
   166     }
   178     }
   167 
   179 
   168     private static void setupSystemRoot() {
   180     private static void setupSystemRoot() {
   169         AccessController.doPrivileged(new PrivilegedAction<Void>() {
   181         AccessController.doPrivileged(new PrivilegedAction<Void>() {
   170             public Void run() {
   182             public Void run() {