SUGGESTED FIX
--- a/src/share/classes/sun/awt/AppContext.java Sat Dec 15 08:25:38 2007 +0300
+++ b/src/share/classes/sun/awt/AppContext.java Sat Dec 15 08:26:12 2007 +0300
@@ -146,7 +146,9 @@ public final class AppContext {
* Returns a set containing all <code>AppContext</code>s.
*/
public static Set<AppContext> getAppContexts() {
- return new HashSet<AppContext>(threadGroup2appContext.values());
+ synchronized (threadGroup2appContext) {
+ return new HashSet<AppContext>(threadGroup2appContext.values());
+ }
}
/* The main "system" AppContext, used by everything not otherwise
|
|
|
EVALUATION
It looks like the problem is in AppContext.getAppContexts()
public static Set<AppContext> getAppContexts() {
return new HashSet<AppContext>(threadGroup2appContext.values());
}
we should clone threadGroup2appContext before getting values.
The problem was introduced by the fix for 6536220.
|
|
|
EVALUATION
Well, we can not just use clone() since threadGroup2appContext is a Map which doesn't have
clone() method. Also we can not use IdentityHashMap as type for threadGroup2appContext since
we need to have synchronized map, but Collections.synchronizedMap() returns just Map.
It looks like to fix the problem we should create some special class which will provide Map
interface (well not complete interface, just methods we need) and method clone().
|
|
|
EVALUATION
actually there is very simple fix. a map Collections.synchronizedMap() returns uses this for
synchronization (it is part of contract of this method) So we just need to use the same
syncronization in our code
public static Set<AppContext> getAppContexts() {
synchronized (threadGroup2appContext) {
return new HashSet<AppContext>(threadGroup2appContext.values());
}
}
|
|
|