Author: markt
Date: Tue Nov 13 13:47:48 2012
New Revision: 1408722
URL: http://svn.apache.org/viewvc?rev=1408722&view=rev
Log:
Ensure onComplete() is called with the correct context.
Review from kkolinko
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/AsyncContextImpl.java
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1408721
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/AsyncContextImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/AsyncContextImpl.java?rev=1408722&r1=1408721&r2=1408722&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/AsyncContextImpl.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/AsyncContextImpl.java
Tue Nov 13 13:47:48 2012
@@ -97,13 +97,22 @@ public class AsyncContextImpl implements
List<AsyncListenerWrapper> listenersCopy =
new ArrayList<AsyncListenerWrapper>();
listenersCopy.addAll(listeners);
- for (AsyncListenerWrapper listener : listenersCopy) {
- try {
- listener.fireOnComplete(event);
- } catch (IOException ioe) {
- log.warn("onComplete() failed for listener of type [" +
- listener.getClass().getName() + "]", ioe);
+
+ ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
+ ClassLoader newCL = request.getContext().getLoader().getClassLoader();
+
+ try {
+ Thread.currentThread().setContextClassLoader(newCL);
+ for (AsyncListenerWrapper listener : listenersCopy) {
+ try {
+ listener.fireOnComplete(event);
+ } catch (IOException ioe) {
+ log.warn("onComplete() failed for listener of type [" +
+ listener.getClass().getName() + "]", ioe);
+ }
}
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldCL);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]