camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/2] camel git commit: CAMEL-8253 Fixed the IndexOutOfBoundsException of the DefaultCxfRsBinding
Date Sat, 17 Jan 2015 13:41:49 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x 84f1390d4 -> 6968de102
  refs/heads/camel-2.14.x 849f6d12c -> 667d90c2f


CAMEL-8253 Fixed the IndexOutOfBoundsException of the DefaultCxfRsBinding


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/667d90c2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/667d90c2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/667d90c2

Branch: refs/heads/camel-2.14.x
Commit: 667d90c2ff4bbf1dd642ec768194b16efe345a49
Parents: 849f6d1
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Sat Jan 17 20:34:13 2015 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Sat Jan 17 21:40:57 2015 +0800

----------------------------------------------------------------------
 .../cxf/jaxrs/DefaultCxfRsBinding.java          |  2 +-
 .../cxf/jaxrs/DefaultCxfRsBindingTest.java      | 26 ++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/667d90c2/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
index 82a2ed7..4d53563 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBinding.java
@@ -282,7 +282,7 @@ public class DefaultCxfRsBinding implements CxfRsBinding, HeaderFilterStrategyAw
         for (Map.Entry<String, List<String>>entry : headers.entrySet()) {
             // just make sure the first String element is not null
             if (headerFilterStrategy.applyFilterToExternalHeaders(entry.getKey(), entry.getValue(),
camelExchange) 
-                || entry.getValue().get(0) == null) {
+                || entry.getValue().isEmpty()) {
                 LOG.trace("Drop CXF message protocol header: {}={}", entry.getKey(), entry.getValue());
             } else {
                 // just put the first String element, as the complex one is filtered

http://git-wip-us.apache.org/repos/asf/camel/blob/667d90c2/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBindingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBindingTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBindingTest.java
index 40ddb47..2617a37 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBindingTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/DefaultCxfRsBindingTest.java
@@ -16,10 +16,20 @@
  */
 package org.apache.camel.component.cxf.jaxrs;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.camel.Exchange;
+import org.apache.camel.Message;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.impl.DefaultHeaderFilterStrategy;
+import org.apache.camel.impl.DefaultMessage;
 import org.apache.camel.util.IOHelper;
+import org.apache.cxf.message.MessageImpl;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -41,5 +51,21 @@ public class DefaultCxfRsBindingTest extends Assert {
         charset = IOHelper.getCharsetName(exchange);
         assertEquals("Get a worng charset name", "UTF-8", charset);
     }
+    
+    @Test
+    public void testCopyProtocolHeader() {
+        DefaultCxfRsBinding cxfRsBinding = new DefaultCxfRsBinding();
+        cxfRsBinding.setHeaderFilterStrategy(new DefaultHeaderFilterStrategy());
+        Exchange exchange = new DefaultExchange(context);
+        Message camelMessage = new DefaultMessage();
+        org.apache.cxf.message.Message cxfMessage = new MessageImpl();
+        Map<String, List<String>> headers = new HashMap<String, List<String>>();
+        headers.put("emptyList", Collections.EMPTY_LIST);
+        headers.put("zeroSizeList", new ArrayList<String>(0));
+        cxfMessage.put(org.apache.cxf.message.Message.PROTOCOL_HEADERS, headers);
+        cxfRsBinding.copyProtocolHeader(cxfMessage, camelMessage, exchange);
+        assertNull("We should get nothing here", camelMessage.getHeader("emptyList"));
+        assertNull("We should get nothing here", camelMessage.getHeader("zeroSizeList"));
+    }
 
 }


Mime
View raw message