2012/11/12  <ma...@apache.org>:
> Author: markt
> Date: Sun Nov 11 23:32:43 2012
> New Revision: 1408150
>
> URL: http://svn.apache.org/viewvc?rev=1408150&view=rev
> Log:
> both timeout and complete, as with all container callbacks must be invoked 
> with the right context
> Backport of fhanik's r1356898


1. The change only takes care of timeout().
What about complete (fireOnComplete()) that is mentioned in the commit
message and in the changelog?

2. I wonder what about running with SecurityManager. (Well, timeout()
is probably called by Tomcat code, so there might be no concern, or
maybe you will notice it while running TCK).

There is already ready-to-use class AsyncContextImpl$PrivilegedSetTccl(..).

Best regards,
Konstantin Kolinko

>
> Modified:
>     tomcat/tc7.0.x/trunk/   (props changed)
>     tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/AsyncContextImpl.java
>     tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
>
> Propchange: tomcat/tc7.0.x/trunk/
> ------------------------------------------------------------------------------
>   Merged /tomcat/trunk:r1356898
>
> 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=1408150&r1=1408149&r2=1408150&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 
> Sun Nov 11 23:32:43 2012
> @@ -110,21 +110,30 @@ public class AsyncContextImpl implements
>          request.getCoyoteRequest().action(ActionCode.ASYNC_TIMEOUT, result);
>
>          if (result.get()) {
> -            boolean listenerInvoked = false;
> -            List<AsyncListenerWrapper> listenersCopy =
> -                new ArrayList<AsyncListenerWrapper>();
> -            listenersCopy.addAll(listeners);
> -            for (AsyncListenerWrapper listener : listenersCopy) {
> -                listener.fireOnTimeout(event);
> -                listenerInvoked = true;
> -            }
> -            if (listenerInvoked) {
> -                request.getCoyoteRequest().action(
> -                        ActionCode.ASYNC_IS_TIMINGOUT, result);
> -                return !result.get();
> -            } else {
> -                // No listeners, container calls complete
> -                complete();
> +
> +            ClassLoader oldCL = 
> Thread.currentThread().getContextClassLoader();
> +            ClassLoader newCL = 
> request.getContext().getLoader().getClassLoader();
> +            try {
> +                Thread.currentThread().setContextClassLoader(newCL);
> +                boolean listenerInvoked = false;
> +                List<AsyncListenerWrapper> listenersCopy =
> +                    new ArrayList<AsyncListenerWrapper>();
> +                listenersCopy.addAll(listeners);
> +                for (AsyncListenerWrapper listener : listenersCopy) {
> +                    listener.fireOnTimeout(event);
> +                    listenerInvoked = true;
> +                }
> +                if (listenerInvoked) {
> +                    request.getCoyoteRequest().action(
> +                            ActionCode.ASYNC_IS_TIMINGOUT, result);
> +                    return !result.get();
> +                } else {
> +                    // No listeners, container calls complete
> +                    complete();
> +                }
> +
> +            } finally {
> +                Thread.currentThread().setContextClassLoader(oldCL);
>              }
>          }
>          return true;
>
> Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
> URL: 
> http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1408150&r1=1408149&r2=1408150&view=diff
> ==============================================================================
> --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
> +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Sun Nov 11 23:32:43 2012
> @@ -118,6 +118,11 @@
>          In FormAuthenticator: If it is configured to change Session IDs,
>          do the change before displaying the login form. (kkolinko)
>        </fix>
> +      <fix>
> +        Ensure <code>AsyncListener.timeout()</code> and
> +        <code>AsyncListener.complete()</code> are called with the correct
> +        thread context class loader. (fhanik)
> +      </fix>
>      </changelog>
>    </subsection>
>    <subsection name="Coyote">
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to