shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pledbr...@apache.org
Subject svn commit: r915202 - /incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/OncePerRequestFilter.java
Date Tue, 23 Feb 2010 06:39:00 GMT
Author: pledbrook
Date: Tue Feb 23 06:39:00 2010
New Revision: 915202

URL: http://svn.apache.org/viewvc?rev=915202&view=rev
Log:
OncePerRequestFilter now removes the 'already filtered' request attribute
once the request has completed. This helps fix a problem that the filter
has on Tomcat, when the request completes before the server forwards to
the error handler.

If the error handler tries to access the security manager, the attempt
fails because the SM has already been removed from the request thread.
With this fix, the Shiro filter can be configured to trigger on the ERROR
dispatcher, so the security manager will be rebound to the thread.

Modified:
    incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/OncePerRequestFilter.java

Modified: incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/OncePerRequestFilter.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/OncePerRequestFilter.java?rev=915202&r1=915201&r2=915202&view=diff
==============================================================================
--- incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/OncePerRequestFilter.java
(original)
+++ incubator/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/OncePerRequestFilter.java
Tue Feb 23 06:39:00 2010
@@ -78,7 +78,14 @@
             // Do invoke this filter...
             log.trace("Filter '{}' not yet executed.  Executing now.", getName());
             request.setAttribute(alreadyFilteredAttributeName, Boolean.TRUE);
-            doFilterInternal(request, response, filterChain);
+
+            try {
+                doFilterInternal(request, response, filterChain);
+            } finally {
+                // Once the request has finished, we're done and we don't
+                // need to mark as 'already filtered' any more.
+                request.removeAttribute(alreadyFilteredAttributeName);
+            }
         }
     }
 



Mime
View raw message