cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5675] Fixing CPE caused by non-String headers making it into the client via the local transport
Date Fri, 11 Apr 2014 16:13:46 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 7823e9956 -> b632aa139


[CXF-5675] Fixing CPE caused by non-String headers making it into the client via the local
transport


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

Branch: refs/heads/master
Commit: b632aa139c80589b54bef1e9a7ccef885342f97c
Parents: 7823e99
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Apr 11 17:13:15 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Apr 11 17:13:15 2014 +0100

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxrs/client/AbstractClient.java | 11 ++++++-----
 .../java/org/apache/cxf/systest/jaxrs/BookStore.java     |  3 ++-
 .../cxf/systest/jaxrs/JAXRSLocalTransportTest.java       |  2 ++
 3 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b632aa13/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
index 8e7123d..76f8335 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
@@ -379,12 +379,12 @@ public abstract class AbstractClient implements Client {
             return currentResponseBuilder;
         }
                 
-        Map<String, List<String>> protocolHeaders = 
+        Map<String, List<Object>> protocolHeaders = 
             CastUtils.cast((Map<?, ?>)responseMessage.get(Message.PROTOCOL_HEADERS));
         
         boolean splitHeaders = 
             MessageUtils.isTrue(outMessage.getContextualProperty(HEADER_SPLIT_PROPERTY));
-        for (Map.Entry<String, List<String>> entry : protocolHeaders.entrySet())
{
+        for (Map.Entry<String, List<Object>> entry : protocolHeaders.entrySet())
{
             if (null == entry.getKey()) {
                 continue;
             }
@@ -393,8 +393,9 @@ public abstract class AbstractClient implements Client {
                     currentResponseBuilder.header(entry.getKey(), entry.getValue().get(0));
                     continue;                    
                 }
-                for (String val : entry.getValue()) {
-                    if (splitHeaders) {
+                for (Object valObject : entry.getValue()) {
+                    if (splitHeaders && valObject instanceof String) {
+                        String val = (String)valObject;
                         String[] values;
                         if (val == null || val.length() == 0) {
                             values = new String[]{""};
@@ -414,7 +415,7 @@ public abstract class AbstractClient implements Client {
                             }
                         }
                     } else {
-                        currentResponseBuilder.header(entry.getKey(), val);
+                        currentResponseBuilder.header(entry.getKey(), valObject);
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/cxf/blob/b632aa13/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
index 2af981c..34e36fb 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
@@ -1181,7 +1181,8 @@ public class BookStore {
         }
         
         book.setId(bookId + 1);
-        return Response.ok(book).build();
+        URI uri = ui.getRequestUriBuilder().path(Long.toString(book.getId())).build();
+        return Response.ok(book).location(uri).build();
     }
     
     @POST

http://git-wip-us.apache.org/repos/asf/cxf/blob/b632aa13/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
index 285e1c9..05229fd 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.jaxrs;
 
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -156,6 +157,7 @@ public class JAXRSLocalTransportTest extends AbstractBusClientServerTestBase
{
         
         Response response = localProxy.addBook(new Book("New", 124L));
         assertEquals(200, response.getStatus());
+        assertTrue(response.getMetadata().getFirst("Location") instanceof URI);
     }
     
     @Test


Mime
View raw message