User: starksm
Date: 01/11/27 22:23:03
Modified: src/main/org/jboss/ejb/plugins/jrmp/interfaces Tag:
Branch_2_4 RemoteMethodInvocation.java
Log:
As noted in SF Bug#482875, the WeakHashMap usage is not actually allowing
classes to be garbage collected due to Methods retaining strong references
to their Class. Since the container invokers have a well defined life-cycle
its better to explicitly remove the cached methods hashes in the invoker
stop method.
Revision Changes Path
No revision
No revision
1.13.4.1 +33 -28
jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/RemoteMethodInvocation.java
Index: RemoteMethodInvocation.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/jrmp/interfaces/RemoteMethodInvocation.java,v
retrieving revision 1.13
retrieving revision 1.13.4.1
diff -u -r1.13 -r1.13.4.1
--- RemoteMethodInvocation.java 2001/05/02 03:04:14 1.13
+++ RemoteMethodInvocation.java 2001/11/28 06:23:03 1.13.4.1
@@ -15,7 +15,6 @@
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Map;
-import java.util.WeakHashMap;
import java.util.HashMap;
import java.security.Principal;
@@ -30,9 +29,10 @@
*
* @author Rickard �berg ([EMAIL PROTECTED])
* @author <a href="mailto:[EMAIL PROTECTED]">Richard
Monson-Haefel</a>.
- * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>.
+ * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>.
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel O'Connor</a>.
- * @version $Revision: 1.13 $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark/a>.
+ * @version $Revision: 1.13.4.1 $
*/
public final class RemoteMethodInvocation
implements java.io.Externalizable
@@ -41,30 +41,31 @@
/** Serial Version Identifier. */
private static final long serialVersionUID = 6021873560918744612L;
+ // Static --------------------------------------------------------
+ static Map hashMap = new HashMap();
// Attributes ----------------------------------------------------
+ /** The method invocation target id */
Object id;
-// String className;
+ /** The method hash caclulated by getInterfaceHashes */
long hash;
-
+ /** The method invocation arguments */
Object[] args;
private Object tpc; // Transaction propagation context.
+ /** The calling thread identity */
private Principal identity;
+ /** The calling thread identity credentials */
private Object credential;
-
+ /** The map of methods set by the JRMPContainerInvoker */
transient Map methodMap;
-
- // Static --------------------------------------------------------
- static Map hashMap = new WeakHashMap();
-
- /**
- * Calculate method hashes. This algo is taken from RMI.
- *
- * @param intf
- * @return
- */
+ /**
+ * Calculate method hashes. This algo is taken from RMI.
+ *
+ * @param intf
+ * @return
+ */
public static Map getInterfaceHashes(Class intf)
{
// Create method hashes
@@ -145,26 +146,31 @@
* we override the hashCode
*
* The hashes are cached in a static for efficiency
- * RO: WeakHashMap needed to support undeploy
*/
public static long calculateHash(Method method)
{
- Map methodHashes = (Map)hashMap.get(method.getDeclaringClass());
+ Class methodClass = method.getDeclaringClass();
+ Map methodHashes = (Map)hashMap.get(methodClass);
if (methodHashes == null)
{
- methodHashes = getInterfaceHashes(method.getDeclaringClass());
-
- // Copy and add
- WeakHashMap newHashMap = new WeakHashMap();
- newHashMap.putAll(hashMap);
- newHashMap.put(method.getDeclaringClass(), methodHashes);
- hashMap = newHashMap;
+ methodHashes = getInterfaceHashes(methodClass);
+ hashMap.put(methodClass, methodHashes);
}
return ((Long)methodHashes.get(method)).longValue();
}
-
+
+ /** Remove the method declaring class method hash map. This is
+ called by the JRMPContainerInvoker in stop to release the referenced
+ classes.
+ */
+ public static void clearHash(Method method)
+ {
+ Class methodClass = method.getDeclaringClass();
+ hashMap.remove(methodClass);
+ }
+
// Constructors --------------------------------------------------
public RemoteMethodInvocation()
{
@@ -181,9 +187,8 @@
this.id = id;
this.args = args;
this.hash = calculateHash(m);
-// this.className = m.getDeclaringClass().getName();
}
-
+
// Public --------------------------------------------------------
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development