cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1478349 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java
Date Thu, 02 May 2013 12:42:20 GMT
Author: sergeyb
Date: Thu May  2 12:42:19 2013
New Revision: 1478349

URL: http://svn.apache.org/r1478349
Log:
Merged revisions 1478340 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1478340 | sergeyb | 2013-05-02 13:08:44 +0100 (Thu, 02 May 2013) | 1 line
  
  If modifyable MetadataMap has unmodifiable Lists the replace them if needed
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1478340

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java?rev=1478349&r1=1478348&r2=1478349&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
Thu May  2 12:42:19 2013
@@ -92,10 +92,21 @@ public class MetadataMap<K, V> implement
     
     private void addValue(K key, V value, boolean last) {
         List<V> data = getList(key);
-        if (last) {
-            data.add(value);
-        } else {
-            data.add(0, value);
+        try {
+            if (last) {
+                data.add(value);
+            } else {
+                data.add(0, value);
+            }
+        } catch (UnsupportedOperationException ex) {
+            // this may happen if an unmodifiable List was set via put or putAll
+            if (!readOnly) {
+                List<V> newList = new ArrayList<V>(data);
+                put(key, newList);
+                addValue(key, value, last);
+            } else {
+                throw ex;
+            }
         }
     }
 

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java?rev=1478349&r1=1478348&r2=1478349&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java
Thu May  2 12:42:19 2013
@@ -20,6 +20,7 @@
 package org.apache.cxf.jaxrs.impl;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -66,6 +67,21 @@ public class MetadataMapTest extends Ass
     }
     
     @Test
+    public void testAddFirstUnmodifiableListFirst() {
+        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
+        m.put("baz", Arrays.<Object>asList("foo"));
+        List<Object> values = m.get("baz");
+        assertEquals(1, values.size());
+        assertEquals("foo", values.get(0));
+        
+        m.addFirst("baz", "clazz");
+        values = m.get("baz");
+        assertEquals(2, values.size());
+        assertEquals("clazz", values.get(0));
+        assertEquals("foo", values.get(1));
+    }
+    
+    @Test
     public void testAddAll() {
         MetadataMap<String, Object> m = new MetadataMap<String, Object>();
         List<Object> values = new ArrayList<Object>();



Mime
View raw message