wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r819193 - in /incubator/wink/trunk/wink-common/src: main/java/org/apache/wink/common/internal/ test/java/org/apache/wink/common/internal/
Date Sat, 26 Sep 2009 19:21:24 GMT
Author: bluk
Date: Sat Sep 26 19:21:23 2009
New Revision: 819193

URL: http://svn.apache.org/viewvc?rev=819193&view=rev
Log:
Guard against null keys in MultivaluedMap

Modified:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/MultivaluedMapImpl.java
    incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/CaseInsensitiveMultivaluedMapTest.java
    incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/MultivaluedMapImplTest.java

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/MultivaluedMapImpl.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/MultivaluedMapImpl.java?rev=819193&r1=819192&r2=819193&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/MultivaluedMapImpl.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/MultivaluedMapImpl.java
Sat Sep 26 19:21:23 2009
@@ -132,7 +132,11 @@
         for (Object name : params.keySet()) {
             for (Object value : params.get(name)) {
                 result.append(delim);
-                result.append(name.toString());
+                if(name == null) {
+                    result.append("null");
+                } else {
+                    result.append(name.toString());
+                }
                 if (value != null) {
                     result.append('=');
                     result.append(value.toString());

Modified: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/CaseInsensitiveMultivaluedMapTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/CaseInsensitiveMultivaluedMapTest.java?rev=819193&r1=819192&r2=819193&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/CaseInsensitiveMultivaluedMapTest.java
(original)
+++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/CaseInsensitiveMultivaluedMapTest.java
Sat Sep 26 19:21:23 2009
@@ -26,8 +26,6 @@
 import java.util.Set;
 import java.util.Map.Entry;
 
-import org.apache.wink.common.internal.CaseInsensitiveMultivaluedMap;
-
 import junit.framework.TestCase;
 
 public class CaseInsensitiveMultivaluedMapTest extends TestCase {
@@ -121,4 +119,13 @@
         assertFalse(keySet.contains("c"));
         assertFalse(keySet.contains("C"));
     }
+
+    public void testNullValue() {
+        CaseInsensitiveMultivaluedMap<String> map = new CaseInsensitiveMultivaluedMap<String>();
+        map.putSingle(null, "valueForNull");
+        map.putSingle("d", null);
+        assertEquals("valueForNull", map.getFirst(null));
+        assertEquals(null, map.getFirst("d"));
+        assertEquals("CaseInsensitiveMultivaluedMap [map=[null=valueForNull,d]]", map.toString());
+    }
 }

Modified: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/MultivaluedMapImplTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/MultivaluedMapImplTest.java?rev=819193&r1=819192&r2=819193&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/MultivaluedMapImplTest.java
(original)
+++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/MultivaluedMapImplTest.java
Sat Sep 26 19:21:23 2009
@@ -91,4 +91,13 @@
         assertNull(map.get("e"));
     }
 
+    public void testNullValue() {
+        MultivaluedMapImpl<String, String> map = new MultivaluedMapImpl<String,
String>();
+        map.putSingle(null, "valueForNull");
+        map.putSingle("d", null);
+        assertEquals("valueForNull", map.getFirst(null));
+        assertEquals(null, map.getFirst("d"));
+        assertEquals("[null=valueForNull,d]", map.toString());
+    }
+
 }



Mime
View raw message