From: markt Date: Mon, 14 Dec 2009 22:54:20 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=47774 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5700e6aaeb911f48a921cb489a0156142c9dfc32;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=47774 Ensure any session listeners are called with the Thread CCL set to the web application's class loader git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@890530 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java index f0bfc3823..e8543fe11 100644 --- a/java/org/apache/catalina/connector/Request.java +++ b/java/org/apache/catalina/connector/Request.java @@ -2181,11 +2181,29 @@ public class Request } catch (IOException e) { // Can't find the session } - if ((session != null) && session.isValid()) - return (true); - else - return (false); + // The call to session.isValid() can trigger session listeners so make + // sure we are using the webapp's class loader in case the listeners are + // triggered + ClassLoader oldTccl = null; + if (context.getLoader() != null && + context.getLoader().getClassLoader() != null) { + oldTccl = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader( + context.getLoader().getClassLoader()); + } + + boolean result = false; + try { + if ((session != null) && session.isValid()) { + result = true; + } + } finally { + if (oldTccl != null) { + Thread.currentThread().setContextClassLoader(oldTccl); + } + } + return result; }