You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2015/01/17 13:39:02 UTC
camel git commit: CAMEL-8253 Fixed the IndexOutOfBoundsException of
the DefaultCxfRsBinding
Repository: camel
Updated Branches:
refs/heads/master 94d527783 -> 53f2df112
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/53f2df11
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/53f2df11
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/53f2df11
Branch: refs/heads/master
Commit: 53f2df1121be11ce4686d3b20f8eb7b70b576774
Parents: 94d5277
Author: Willem Jiang <wi...@gmail.com>
Authored: Sat Jan 17 20:34:13 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sat Jan 17 20:34:32 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/53f2df11/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/53f2df11/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"));
+ }
}