From 1b14b1e4887271cf54ae89b8529f3dda630e8a39 Mon Sep 17 00:00:00 2001 From: markt Date: Fri, 5 Jun 2009 21:38:44 +0000 Subject: [PATCH] Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=47299 Simplify fireContainerEvent method and enable it to work with implementations that extend StandardContext. See http://svn.apache.org/viewvc?view=rev&revision=287710 for why it was written this way originally. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@782145 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/catalina/session/StandardSession.java | 37 +++------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/java/org/apache/catalina/session/StandardSession.java b/java/org/apache/catalina/session/StandardSession.java index 09cafd2e6..1833fce11 100644 --- a/java/org/apache/catalina/session/StandardSession.java +++ b/java/org/apache/catalina/session/StandardSession.java @@ -25,7 +25,6 @@ import java.io.NotSerializableException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; -import java.lang.reflect.Method; import java.security.AccessController; import java.security.Principal; import java.security.PrivilegedAction; @@ -57,6 +56,7 @@ import org.apache.catalina.SessionListener; import org.apache.catalina.util.Enumerator; import org.apache.catalina.util.StringManager; +import org.apache.catalina.core.StandardContext; import org.apache.catalina.security.SecurityUtil; /** @@ -142,24 +142,6 @@ public class StandardSession /** - * The java.lang.Method for the - * fireContainerEvent() method of the - * org.apache.catalina.core.StandardContext method, - * if our Context implementation is of this class. This value is - * computed dynamically the first time it is needed, or after - * a session reload (since it is declared transient). - */ - protected transient Method containerEventMethod = null; - - - /** - * The method signature for the fireContainerEvent method. - */ - protected static final Class containerEventTypes[] = - { String.class, Object.class }; - - - /** * The time this session was created, in milliseconds since midnight, * January 1, 1970 GMT. */ @@ -1594,21 +1576,10 @@ public class StandardSession String type, Object data) throws Exception { - if (!"org.apache.catalina.core.StandardContext".equals - (context.getClass().getName())) { - return; // Container events are not supported + if (context instanceof StandardContext) { + // NOTE: Race condition is harmless, so do not synchronize + ((StandardContext) context).fireContainerEvent(type, data); } - // NOTE: Race condition is harmless, so do not synchronize - if (containerEventMethod == null) { - containerEventMethod = - context.getClass().getMethod("fireContainerEvent", - containerEventTypes); - } - Object containerEventParams[] = new Object[2]; - containerEventParams[0] = type; - containerEventParams[1] = data; - containerEventMethod.invoke(context, containerEventParams); - } -- 2.11.0