harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r986205 - /harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/IIORegistry.java
Date Tue, 17 Aug 2010 07:05:40 GMT
Author: hindessm
Date: Tue Aug 17 07:05:39 2010
New Revision: 986205

URL: http://svn.apache.org/viewvc?rev=986205&view=rev
Log:
Apply patch from "[#HARMONY-6612] Implement own instance for each
ThreadGroup for class IIORegistry".  First hunk needed to be applied
manually.

Modified:
    harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/IIORegistry.java

Modified: harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/IIORegistry.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/IIORegistry.java?rev=986205&r1=986204&r2=986205&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/IIORegistry.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/imageio/src/main/java/javax/imageio/spi/IIORegistry.java
Tue Aug 17 07:05:39 2010
@@ -22,7 +22,10 @@ package javax.imageio.spi;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.IdentityHashMap;
 import java.util.Iterator;
+import java.util.Map;
 
 import org.apache.harmony.x.imageio.plugins.gif.GIFImageReaderSpi;
 import org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageReaderSpi;
@@ -38,7 +41,8 @@ import org.apache.harmony.x.imageio.spi.
 
 public final class IIORegistry extends ServiceRegistry {
 
-    private static IIORegistry   instance;
+    private static Map<ThreadGroup, IIORegistry> instances = 
+    	Collections.synchronizedMap(new IdentityHashMap<ThreadGroup, IIORegistry>());
 
     private static final Class[] CATEGORIES = new Class[] {
                     javax.imageio.spi.ImageWriterSpi.class,
@@ -68,14 +72,17 @@ public final class IIORegistry extends S
     }
 
     public static IIORegistry getDefaultInstance() {
-        // TODO implement own instance for each ThreadGroup (see also
-        // ThreadLocal)
-        synchronized (IIORegistry.class) {
-            if (instance == null) {
-                instance = new IIORegistry();
-            }
-            return instance;
-        }
+        ThreadGroup tg = Thread.currentThread().getThreadGroup();
+        synchronized (instances) {
+        	IIORegistry instance = instances.get(tg);
+        	if (instance == null) {
+        		synchronized(IIORegistry.class) {
+        			instance = new IIORegistry();
+        		}
+            	instances.put(tg, instance);
+        	}
+        	return instance;
+        }    
     }
 
     @SuppressWarnings("unchecked")



Mime
View raw message