6891412: The sun.awt.shell.ShellFolder#getInvoker method should be synchronized
authorrupashka
Fri, 30 Oct 2009 14:18:23 +0300
changeset 4274 02ccf52bf1ba
parent 4273 19adfe928d6c
child 4275 4c3444f1b9d8
6891412: The sun.awt.shell.ShellFolder#getInvoker method should be synchronized Reviewed-by: peterz
jdk/src/share/classes/sun/awt/shell/ShellFolder.java
--- a/jdk/src/share/classes/sun/awt/shell/ShellFolder.java	Fri Oct 30 14:05:48 2009 +0300
+++ b/jdk/src/share/classes/sun/awt/shell/ShellFolder.java	Fri Oct 30 14:18:23 2009 +0300
@@ -201,6 +201,8 @@
 
     private static ShellFolderManager shellFolderManager;
 
+    private static Invoker invoker;
+
     static {
         String managerClassName = (String)Toolkit.getDefaultToolkit().
                                       getDesktopProperty("Shell.shellFolderManager");
@@ -225,6 +227,8 @@
             throw new Error ("Could not access Shell Folder Manager: "
             + managerClass.getName());
         }
+
+        invoker = shellFolderManager.createInvoker();
     }
 
     /**
@@ -486,21 +490,6 @@
         return null;
     }
 
-    private static Invoker invoker;
-
-    /**
-     * Provides the single access point to the {@link Invoker}. It is guaranteed that the value
-     * returned by this method will be always the same.
-     *
-     * @return the singleton instance of {@link Invoker}
-     */
-    public static Invoker getInvoker() {
-        if (invoker == null) {
-            invoker = shellFolderManager.createInvoker();
-        }
-        return invoker;
-    }
-
     /**
      * Invokes the {@code task} which doesn't throw checked exceptions
      * from its {@code call} method. If invokation is interrupted then Thread.currentThread().isInterrupted() will
@@ -522,7 +511,7 @@
     public static <T, E extends Throwable> T invoke(Callable<T> task, Class<E> exceptionClass)
             throws InterruptedException, E {
         try {
-            return getInvoker().invoke(task);
+            return invoker.invoke(task);
         } catch (Exception e) {
             if (e instanceof RuntimeException) {
                 // Rethrow unchecked exceptions