[jboss-cvs] JBossAS SVN: r59466 - branches/JBoss_4_0_5_GA_JBAS-3913/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 23:52:46 EST 2007
Author: tom.elrod at jboss.com
Date: 2007-01-09 23:52:45 -0500 (Tue, 09 Jan 2007)
New Revision: 59466
Modified:
branches/JBoss_4_0_5_GA_JBAS-3913/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_JBAS-3913/server/src/main/org/jboss/invocation/pooled/interfaces/OptimizedObjectInputStream.java
===================================================================
--- branches/JBoss_4_0_5_GA_JBAS-3913/server/src/main/org/jboss/invocation/pooled/interfaces/OptimizedObjectInputStream.java 2007-01-10 04:34:05 UTC (rev 59465)
+++ branches/JBoss_4_0_5_GA_JBAS-3913/server/src/main/org/jboss/invocation/pooled/interfaces/OptimizedObjectInputStream.java 2007-01-10 04:52:45 UTC (rev 59466)
@@ -28,9 +28,15 @@
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;
+import org.jboss.logging.Logger;
+
/**
* An ObjectInputStream subclass used by the MarshalledValue class to
* ensure the classes and proxies are loaded using the thread context
@@ -43,8 +49,9 @@
public class OptimizedObjectInputStream
extends ObjectInputStream
{
+ private static Logger log = Logger.getLogger(OptimizedObjectInputStream.class);
/** 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 +78,7 @@
{
if (flag == true)
{
- classCache = new ConcurrentReaderHashMap();
+ classCache = Collections.synchronizedMap(new WeakHashMap());
objectStreamClassCache = new ConcurrentReaderHashMap();
}
else
@@ -93,13 +100,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 +132,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