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/03/22 14:18:31 UTC

svn commit: r926064 - /tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java

Author: markt
Date: Mon Mar 22 13:18:31 2010
New Revision: 926064

URL: http://svn.apache.org/viewvc?rev=926064&view=rev
Log:
Fire listeners in reverse order for requestDestroyed

Modified:
    tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java?rev=926064&r1=926063&r2=926064&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java Mon Mar 22 13:18:31 2010
@@ -202,17 +202,18 @@ final class StandardContextValve
                 (instances.length > 0)) {
             // create post-service event
             for (int i = 0; i < instances.length; i++) {
-                if (instances[i] == null)
+                int j = (instances.length -1) -i;
+                if (instances[j] == null)
                     continue;
-                if (!(instances[i] instanceof ServletRequestListener))
+                if (!(instances[j] instanceof ServletRequestListener))
                     continue;
                 ServletRequestListener listener =
-                    (ServletRequestListener) instances[i];
+                    (ServletRequestListener) instances[j];
                 try {
                     listener.requestDestroyed(event);
                 } catch (Throwable t) {
                     container.getLogger().error(sm.getString("standardContext.requestListener.requestDestroy",
-                                     instances[i].getClass().getName()), t);
+                                     instances[j].getClass().getName()), t);
                     ServletRequest sreq = request.getRequest();
                     sreq.setAttribute(Globals.EXCEPTION_ATTR,t);
                 }



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


Re: svn commit: r926064 - /tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java

Posted by Mark Thomas <ma...@apache.org>.
On 23/03/2010 08:39, Konstantin Kolinko wrote:
> There is a more easy way to write the same loop:
> for (int i = instances.length; (--i) >= 0; ) {

I know. I was keeping the code consistent with the other places
listeners get called in reverse order. Of course, that doesn't stop you
cleaning them all up :)

Mark



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


Re: svn commit: r926064 - /tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java

Posted by Konstantin Kolinko <kn...@gmail.com>.
2010/3/22  <ma...@apache.org>:
> Author: markt
> Date: Mon Mar 22 13:18:31 2010
> New Revision: 926064
>
> URL: http://svn.apache.org/viewvc?rev=926064&view=rev
> Log:
> Fire listeners in reverse order for requestDestroyed
>
> Modified:
>    tomcat/trunk/java/org/apache/catalina/core/StandardContextValve.java
>

> @@ -202,17 +202,18 @@ final class StandardContextValve
>                 (instances.length > 0)) {
>             // create post-service event
>             for (int i = 0; i < instances.length; i++) {
> -                if (instances[i] == null)
> +                int j = (instances.length -1) -i;
> +                if (instances[j] == null)
>                     continue;
(...)

There is a more easy way to write the same loop:
for (int i = instances.length; (--i) >= 0; ) {

Best regards,
Konstantin Kolinko

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