Revision: 642
          http://stripes.svn.sourceforge.net/stripes/?rev=642&view=rev
Author:   bengunter
Date:     2007-12-03 21:24:15 -0800 (Mon, 03 Dec 2007)

Log Message:
-----------
Fixed STS-448: StripesFilter should not wrap the request more than once. The 
filter now only picks the locale and character encoding and wraps the request 
on the initial invocation for a given request. After that, it uses whatever 
request it receives in doFilter(...).

Modified Paths:
--------------
    trunk/stripes/src/net/sourceforge/stripes/controller/StripesFilter.java

Modified: 
trunk/stripes/src/net/sourceforge/stripes/controller/StripesFilter.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/controller/StripesFilter.java     
2007-12-03 19:07:36 UTC (rev 641)
+++ trunk/stripes/src/net/sourceforge/stripes/controller/StripesFilter.java     
2007-12-04 05:24:15 UTC (rev 642)
@@ -167,36 +167,40 @@
         try {
             log.trace("Intercepting request to URL: ", 
httpRequest.getRequestURI());
 
-            // Pop the configuration into thread local
-            StripesFilter.configurationStash.set(this.configuration);
+            if (initial) {
+                // Pop the configuration into thread local
+                StripesFilter.configurationStash.set(this.configuration);
 
-            // Figure out the locale and character encoding to use. The 
ordering of things here
-            // is very important!! We pick the locale first since picking the 
encoding is
-            // locale dependent, but the encoding *must* be set on the request 
before any
-            // parameters or parts are accessed, and wrapping the request 
accesses stuff.
-            Locale locale = 
this.configuration.getLocalePicker().pickLocale(httpRequest);
-            log.debug("LocalePicker selected locale: ", locale);
+                // Figure out the locale and character encoding to use. The 
ordering of things here
+                // is very important!! We pick the locale first since picking 
the encoding is
+                // locale dependent, but the encoding *must* be set on the 
request before any
+                // parameters or parts are accessed, and wrapping the request 
accesses stuff.
+                Locale locale = 
this.configuration.getLocalePicker().pickLocale(httpRequest);
+                log.debug("LocalePicker selected locale: ", locale);
 
-            String encoding = 
this.configuration.getLocalePicker().pickCharacterEncoding(httpRequest, locale);
-            if (encoding != null) {
-                httpRequest.setCharacterEncoding(encoding);
-                log.debug("LocalePicker selected character encoding: ", 
encoding);
-            }
-            else {
-                log.debug("LocalePicker did not pick a character encoding, 
using default: ",
-                          httpRequest.getCharacterEncoding());
-            }
+                String encoding = 
this.configuration.getLocalePicker().pickCharacterEncoding(
+                        httpRequest, locale);
+                if (encoding != null) {
+                    httpRequest.setCharacterEncoding(encoding);
+                    log.debug("LocalePicker selected character encoding: ", 
encoding);
+                }
+                else {
+                    log.debug("LocalePicker did not pick a character encoding, 
using default: ",
+                            httpRequest.getCharacterEncoding());
+                }
 
-            StripesRequestWrapper request = wrapRequest(httpRequest);
-            request.setLocale(locale);
-            httpResponse.setLocale(locale);
-            if (encoding != null) {
-                httpResponse.setCharacterEncoding(encoding);
+                StripesRequestWrapper request = wrapRequest(httpRequest);
+                request.setLocale(locale);
+                httpResponse.setLocale(locale);
+                if (encoding != null) {
+                    httpResponse.setCharacterEncoding(encoding);
+                }
+                httpRequest = request;
             }
 
             // Execute the rest of the chain
-            flashInbound(request);
-            filterChain.doFilter(request, servletResponse);
+            flashInbound(httpRequest);
+            filterChain.doFilter(httpRequest, servletResponse);
         }
         catch (Throwable t) {
             this.configuration.getExceptionHandler().handle(t, httpRequest, 
httpResponse);
@@ -223,7 +227,12 @@
      */
     protected StripesRequestWrapper wrapRequest(HttpServletRequest 
servletRequest)
             throws StripesServletException {
-        return new StripesRequestWrapper(servletRequest);
+        try {
+            return StripesRequestWrapper.findStripesWrapper(servletRequest);
+        }
+        catch (IllegalStateException e) {
+            return new StripesRequestWrapper(servletRequest);
+        }
     }
 
     /**


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to