[jboss-cvs] JBossAS SVN: r59452 - branches/JBoss_4_0_2_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 14:21:45 EST 2007
Author: tom.elrod at jboss.com
Date: 2007-01-09 14:21:44 -0500 (Tue, 09 Jan 2007)
New Revision: 59452
Modified:
branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/interfaces/OptimizedObjectInputStream.java
Log:
JBAS-3912 - fix for pooled invoker scoped classloading bug
Modified: branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/interfaces/OptimizedObjectInputStream.java
===================================================================
--- branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/interfaces/OptimizedObjectInputStream.java 2007-01-09 19:13:25 UTC (rev 59451)
+++ branches/JBoss_4_0_2_CP/server/src/main/org/jboss/invocation/pooled/interfaces/OptimizedObjectInputStream.java 2007-01-09 19:21:44 UTC (rev 59452)
@@ -7,20 +7,22 @@
package org.jboss.invocation.pooled.interfaces;
+import org.jboss.logging.Logger;
+
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+
+import java.io.IOException;
import java.io.InputStream;
-import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.lang.reflect.Method;
-import java.lang.ref.WeakReference;
+import java.util.Collections;
+import java.util.Map;
+import java.util.WeakHashMap;
-import org.jboss.util.collection.WeakValueHashMap;
-
-import org.jboss.logging.Logger;
-import org.jboss.invocation.MarshalledValueInputStream;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
-
/**
* An ObjectInputStream subclass used by the MarshalledValue class to
* ensure the classes and proxies are loaded using the thread context
@@ -34,7 +36,7 @@
{
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;
@@ -61,7 +63,7 @@
{
if (flag == true)
{
- classCache = new ConcurrentReaderHashMap();
+ classCache = Collections.synchronizedMap(new WeakHashMap());
objectStreamClassCache = new ConcurrentReaderHashMap();
}
else
@@ -83,13 +85,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
{
@@ -103,7 +117,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