You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2010/01/12 23:36:15 UTC
svn commit: r898555 -
/tomcat/trunk/java/org/apache/catalina/session/StandardSession.java
Author: markt
Date: Tue Jan 12 22:36:15 2010
New Revision: 898555
URL: http://svn.apache.org/viewvc?rev=898555&view=rev
Log:
Improved fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=47774
Modified:
tomcat/trunk/java/org/apache/catalina/session/StandardSession.java
Modified: tomcat/trunk/java/org/apache/catalina/session/StandardSession.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/StandardSession.java?rev=898555&r1=898554&r2=898555&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/StandardSession.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/StandardSession.java Tue Jan 12 22:36:15 2010
@@ -702,37 +702,55 @@
// Notify interested application event listeners
// FIXME - Assumes we call listeners in reverse order
Context context = (Context) manager.getContainer();
- Object listeners[] = context.getApplicationLifecycleListeners();
- if (notify && (listeners != null)) {
- HttpSessionEvent event =
- new HttpSessionEvent(getSession());
- for (int i = 0; i < listeners.length; i++) {
- int j = (listeners.length - 1) - i;
- if (!(listeners[j] instanceof HttpSessionListener))
- continue;
- HttpSessionListener listener =
- (HttpSessionListener) listeners[j];
- try {
- fireContainerEvent(context,
- "beforeSessionDestroyed",
- listener);
- listener.sessionDestroyed(event);
- fireContainerEvent(context,
- "afterSessionDestroyed",
- listener);
- } catch (Throwable t) {
+
+ // The call to expire() may not have been triggered by the webapp.
+ // Make sure the webapp's class loader is set when calling the
+ // listeners
+ ClassLoader oldTccl = null;
+ if (context.getLoader() != null &&
+ context.getLoader().getClassLoader() != null) {
+ oldTccl = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(
+ context.getLoader().getClassLoader());
+ }
+ try {
+ Object listeners[] = context.getApplicationLifecycleListeners();
+ if (notify && (listeners != null)) {
+ HttpSessionEvent event =
+ new HttpSessionEvent(getSession());
+ for (int i = 0; i < listeners.length; i++) {
+ int j = (listeners.length - 1) - i;
+ if (!(listeners[j] instanceof HttpSessionListener))
+ continue;
+ HttpSessionListener listener =
+ (HttpSessionListener) listeners[j];
try {
fireContainerEvent(context,
+ "beforeSessionDestroyed",
+ listener);
+ listener.sessionDestroyed(event);
+ fireContainerEvent(context,
"afterSessionDestroyed",
listener);
- } catch (Exception e) {
- // Ignore
+ } catch (Throwable t) {
+ try {
+ fireContainerEvent(context,
+ "afterSessionDestroyed",
+ listener);
+ } catch (Exception e) {
+ // Ignore
+ }
+ manager.getContainer().getLogger().error
+ (sm.getString("standardSession.sessionEvent"), t);
}
- manager.getContainer().getLogger().error
- (sm.getString("standardSession.sessionEvent"), t);
}
}
+ } finally {
+ if (oldTccl != null) {
+ Thread.currentThread().setContextClassLoader(oldTccl);
+ }
}
+
if (ACTIVITY_CHECK) {
accessCount.set(0);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org