Revision: 989
          http://stripes.svn.sourceforge.net/stripes/?rev=989&view=rev
Author:   bengunter
Date:     2008-10-22 19:00:52 +0000 (Wed, 22 Oct 2008)

Log Message:
-----------
Fixed STS-557. Existing cookies with the same name as the one being added are 
removed from the list before the new one is added.

Modified Paths:
--------------
    trunk/stripes/src/net/sourceforge/stripes/mock/MockHttpServletResponse.java

Modified: 
trunk/stripes/src/net/sourceforge/stripes/mock/MockHttpServletResponse.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/mock/MockHttpServletResponse.java 
2008-10-22 16:47:40 UTC (rev 988)
+++ trunk/stripes/src/net/sourceforge/stripes/mock/MockHttpServletResponse.java 
2008-10-22 19:00:52 UTC (rev 989)
@@ -19,6 +19,7 @@
 import javax.servlet.ServletOutputStream;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.ListIterator;
 import java.util.Locale;
 import java.util.Map;
 import java.util.HashMap;
@@ -50,8 +51,17 @@
     private String redirectUrl;
 
     /** Adds a cookie to the set of cookies in the response. */
-    public void addCookie(Cookie cookie) { this.cookies.add(cookie); }
+    public void addCookie(Cookie cookie) {
+        // Remove existing cookies with the same name as the new one
+        ListIterator<Cookie> iterator = cookies.listIterator();
+        while (iterator.hasNext()) {
+            if (iterator.next().getName().equals(cookie.getName()))
+                iterator.remove();
+        }
 
+        this.cookies.add(cookie);
+    }
+
     /** Gets the set of cookies stored in the response. */
     public Cookie[] getCookies() { return this.cookies.toArray(new 
Cookie[this.cookies.size()]); }
 


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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to