tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1408722 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/core/AsyncContextImpl.java
Date Tue, 13 Nov 2012 13:47:49 GMT
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message