[jboss-cvs] JBossAS SVN: r59453 - branches/JBoss_4_0_5_GA_CP/server/src/main/org/jboss/invocation/pooled/interfaces.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 9 15:10:56 EST 2007


Author: tom.elrod at jboss.com
Date: 2007-01-09 15:10:55 -0500 (Tue, 09 Jan 2007)
New Revision: 59453

Modified:
   branches/JBoss_4_0_5_GA_CP/server/src/main/org/jboss/invocation/pooled/interfaces/OptimizedObjectInputStream.java
Log:
JBAS-3913 - fix for pooled invoker scoped classloading bug

Modified: branches/JBoss_4_0_5_GA_CP/server/src/main/org/jboss/invocation/pooled/interfaces/OptimizedObjectInputStream.java
===================================================================
--- branches/JBoss_4_0_5_GA_CP/server/src/main/org/jboss/invocation/pooled/interfaces/OptimizedObjectInputStream.java	2007-01-09 19:21:44 UTC (rev 59452)
+++ branches/JBoss_4_0_5_GA_CP/server/src/main/org/jboss/invocation/pooled/interfaces/OptimizedObjectInputStream.java	2007-01-09 20:10:55 UTC (rev 59453)
@@ -28,7 +28,11 @@
 import java.lang.ref.WeakReference;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import java.util.Collections;
+import java.util.Map;
+import java.util.WeakHashMap;
 
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
 
 /**
@@ -44,7 +48,7 @@
         extends ObjectInputStream
 {
    /** A class wide cache of proxy classes populated by resolveProxyClass */
-   private static ConcurrentReaderHashMap classCache;
+   private static Map classCache;
    private static ConcurrentReaderHashMap objectStreamClassCache;
    private static Method lookupStreamClass = null;
 
@@ -71,7 +75,7 @@
    {
       if (flag == true)
       {
-         classCache = new ConcurrentReaderHashMap();
+         classCache = Collections.synchronizedMap(new WeakHashMap());
          objectStreamClassCache = new ConcurrentReaderHashMap();
       }
       else
@@ -93,13 +97,25 @@
    private static Class forName(String className) throws ClassNotFoundException
    {
       Class clazz = null;
+
       if (classCache != null)
       {
-         WeakReference ref = (WeakReference) classCache.get(className);
-         if (ref != null) clazz = (Class) ref.get();
+
+    	 ConcurrentHashMap subCache = (ConcurrentHashMap )classCache.get(Thread.currentThread().getContextClassLoader());
+    	 if (subCache==null)
+    	 {
+    		 classCache.put(Thread.currentThread().getContextClassLoader(), new ConcurrentHashMap());
+    		 subCache = (ConcurrentHashMap )classCache.get(Thread.currentThread().getContextClassLoader());
+    	 }
+
+         WeakReference ref = (WeakReference) subCache.get(className);
+         if (ref != null)
+         {
+            clazz = (Class) ref.get();
+         }
          if (clazz == null)
          {
-            if (ref != null) classCache.remove(className);
+            if (ref != null) subCache.remove(className);
             ClassLoader loader = Thread.currentThread().getContextClassLoader();
             try
             {
@@ -113,7 +129,7 @@
                */
                clazz = Class.forName(className, false, loader);
             }
-            classCache.put(className, new WeakReference(clazz));
+            subCache.put(className, new WeakReference(clazz));
          }
       }
       else




More information about the jboss-cvs-commits mailing list