提交 360a1536 编写于 作者: R rupashka

6891412: The sun.awt.shell.ShellFolder#getInvoker method should be synchronized

Reviewed-by: peterz
上级 e459baed
...@@ -201,6 +201,8 @@ public abstract class ShellFolder extends File { ...@@ -201,6 +201,8 @@ public abstract class ShellFolder extends File {
private static ShellFolderManager shellFolderManager; private static ShellFolderManager shellFolderManager;
private static Invoker invoker;
static { static {
String managerClassName = (String)Toolkit.getDefaultToolkit(). String managerClassName = (String)Toolkit.getDefaultToolkit().
getDesktopProperty("Shell.shellFolderManager"); getDesktopProperty("Shell.shellFolderManager");
...@@ -225,6 +227,8 @@ public abstract class ShellFolder extends File { ...@@ -225,6 +227,8 @@ public abstract class ShellFolder extends File {
throw new Error ("Could not access Shell Folder Manager: " throw new Error ("Could not access Shell Folder Manager: "
+ managerClass.getName()); + managerClass.getName());
} }
invoker = shellFolderManager.createInvoker();
} }
/** /**
...@@ -486,21 +490,6 @@ public abstract class ShellFolder extends File { ...@@ -486,21 +490,6 @@ public abstract class ShellFolder extends File {
return null; 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 * Invokes the {@code task} which doesn't throw checked exceptions
* from its {@code call} method. If invokation is interrupted then Thread.currentThread().isInterrupted() will * from its {@code call} method. If invokation is interrupted then Thread.currentThread().isInterrupted() will
...@@ -522,7 +511,7 @@ public abstract class ShellFolder extends File { ...@@ -522,7 +511,7 @@ public abstract class ShellFolder extends File {
public static <T, E extends Throwable> T invoke(Callable<T> task, Class<E> exceptionClass) public static <T, E extends Throwable> T invoke(Callable<T> task, Class<E> exceptionClass)
throws InterruptedException, E { throws InterruptedException, E {
try { try {
return getInvoker().invoke(task); return invoker.invoke(task);
} catch (Exception e) { } catch (Exception e) {
if (e instanceof RuntimeException) { if (e instanceof RuntimeException) {
// Rethrow unchecked exceptions // Rethrow unchecked exceptions
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册