portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r549664 - /portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
Date Fri, 22 Jun 2007 01:30:56 GMT
Author: ate
Date: Thu Jun 21 18:30:55 2007
New Revision: 549664

URL: http://svn.apache.org/viewvc?view=rev&rev=549664
Log:
Fix in getParameterMap() cache invalidation:
The old solution is kinda tricky and didn't work on Jetty.
Added a new check which I think is the correct/real one needed, but I'll keep the old check
too as this hasn't been tested properly on other app servers than Tomcat and Jetty so far.

Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java?view=diff&rev=549664&r1=549663&r2=549664
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/ServletRequestImpl.java
Thu Jun 21 18:30:55 2007
@@ -84,6 +84,9 @@
     
     private Map portalParameters;
     
+    private String currentIncludeQueryString;    
+    private String currentForwardQueryString;    
+    
     // request attributes map which is cached for each paralleled worker.
     // this should be re-created when it is called for the first time or when some attributes
are added/modified/removed.
     private Map cachedAttributes;
@@ -208,10 +211,41 @@
             return (value.toString());
         }
     }
+    
+    private boolean isEqual(String one, String two)
+    {
+        return one == null && two == null || (one != null && two != null
&& one.equals(two));
+    }
+    
+    private boolean checkQueryStringChanged()
+    {
+        boolean changed = false;
+        ServletRequest request = getRequest();
+        String includeQueryString = (String)request.getAttribute("javax.servlet.include.query_string");
       
+        String forwardQueryString = (String)request.getAttribute("javax.servlet.forward.query_string");
+        
+        if (!isEqual(currentIncludeQueryString,includeQueryString))
+        {
+            currentIncludeQueryString = includeQueryString;
+            changed = true;
+        }
+        if (!isEqual(currentForwardQueryString,forwardQueryString))
+        {
+            currentForwardQueryString = forwardQueryString;
+            changed = true;
+        }        
+        return changed;
+    }
 
     public Map getParameterMap()
     {
-        if (currentRequest == null || currentRequest != getRequest() )
+        // if included or forwarded with a query string, parameterMap might have changed
+        // this is/should be the only check needed, and the other "tricky" check below probably
+        // can be removed.
+        // I'll keep it in for now though as it hasn't been tested enough on other app servers
+        boolean queryStringChanged = checkQueryStringChanged();
+        
+        if (queryStringChanged || currentRequest == null || currentRequest != getRequest()
)
         {
             // Cache the parameters for as long as the wrapped request stays the same.
             // According to Servlet 2.3 SRV.6.2.2 the passed on ServletRequest object



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


Mime
View raw message