Author: mrdon
Date: Tue May 22 05:32:32 2007
New Revision: 540561

URL: http://svn.apache.org/viewvc?view=rev&rev=540561
Log:
Better handling of requests that have no cookies
WW-1920

Modified:
    
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java?view=diff&rev=540561&r1=540560&r2=540561
==============================================================================
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java
 Tue May 22 05:32:32 2007
@@ -202,17 +202,19 @@
         Map cookiesMap = new LinkedHashMap();
 
         Cookie cookies[] = request.getCookies();
-        for (int a=0; a< cookies.length; a++) {
-            String name = cookies[a].getName();
-            String value = cookies[a].getValue();
+        if (cookies != null) {
+            for (int a=0; a< cookies.length; a++) {
+                String name = cookies[a].getName();
+                String value = cookies[a].getValue();
 
-            if (cookiesNameSet.contains("*")) {
-                if (LOG.isDebugEnabled())
-                    LOG.debug("contains cookie name [*] in configured cookies 
name set, cookie with name ["+name+"] with value ["+value+"] will be injected");
-                populateCookieValueIntoStack(name, value, cookiesMap, stack);
-            }
-            else if (cookiesNameSet.contains(cookies[a].getName())) {
-                populateCookieValueIntoStack(name, value, cookiesMap, stack);
+                if (cookiesNameSet.contains("*")) {
+                    if (LOG.isDebugEnabled())
+                        LOG.debug("contains cookie name [*] in configured 
cookies name set, cookie with name ["+name+"] with value ["+value+"] will be 
injected");
+                    populateCookieValueIntoStack(name, value, cookiesMap, 
stack);
+                }
+                else if (cookiesNameSet.contains(cookies[a].getName())) {
+                    populateCookieValueIntoStack(name, value, cookiesMap, 
stack);
+                }
             }
         }
 


Reply via email to