Author: jcompagner
Date: Sun Apr  6 04:40:02 2008
New Revision: 645227

URL: http://svn.apache.org/viewvc?rev=645227&view=rev
Log:
WICKET-1478
when setting an error status, the container will try to resolve that in that 
call itself. This will result in a second wicket call in the same thread. 
Because of that we will clean all thread locals like RequestCycle and 
Application. I do reset those now to the previous values.

The problem is that we have more thread locals which also could be affected. 
Like Sessions thread locals (dirty pages) Also the RequestContext for our 
portlet support how to handle that?
We need to look at this in a next release a bit more (1.4)

Modified:
    
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java
    
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java

Modified: 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java?rev=645227&r1=645226&r2=645227&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java 
(original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java 
Sun Apr  6 04:40:02 2008
@@ -212,6 +212,8 @@
                current.set(cycle);
        }
 
+       private RequestCycle previousOne = null;
+
        /**
         * True if the request cycle should automatically clear feedback 
messages after processing. True
         * by default.
@@ -285,6 +287,7 @@
                originalResponse = response;
                processor = safeGetRequestProcessor();
 
+               previousOne = (RequestCycle)current.get();
                // Set this RequestCycle into ThreadLocal variable
                current.set(this);
        }
@@ -1382,7 +1385,7 @@
 
                // Clear ThreadLocal reference; makes sense as this object 
should not be
                // reused
-               current.set(null);
+               current.set(previousOne);
        }
 
        /**

Modified: 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java?rev=645227&r1=645226&r2=645227&view=diff
==============================================================================
--- 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
 (original)
+++ 
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
 Sun Apr  6 04:40:02 2008
@@ -181,6 +181,11 @@
 
                if (isWicketRequest(relativePath))
                {
+                       Application previous = null;
+                       if (Application.exists())
+                       {
+                               previous = Application.get();
+                       }
                        try
                        {
                                // Set the webapplication for this thread
@@ -224,9 +229,16 @@
                        }
                        finally
                        {
-                               // always unset the application thread local
-                               Application.unset();
-                               RequestContext.unset();
+                               // unset the application thread local if it 
didn't exist already.
+                               if (previous == null)
+                               {
+                                       Application.unset();
+                                       RequestContext.unset();
+                               }
+                               else
+                               {
+                                       Application.set(previous);
+                               }
                        }
                }
                else


Reply via email to