cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5851] Ignoring null attachments in client proxies
Date Fri, 04 Jul 2014 16:00:20 GMT
Repository: cxf
Updated Branches:
  refs/heads/master c5752fd7e -> 5a9bcf36e


[CXF-5851] Ignoring null attachments in client proxies


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

Branch: refs/heads/master
Commit: 5a9bcf36ea3c15e89357a61161c51830583ac526
Parents: c5752fd
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Jul 4 17:00:00 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Jul 4 17:00:00 2014 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/client/ClientProxyImpl.java    |  5 ++++-
 .../apache/cxf/systest/jaxrs/JAXRSMultipartTest.java    |  7 +++++++
 .../org/apache/cxf/systest/jaxrs/MultipartStore.java    | 12 ++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5a9bcf36/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
index 9faed5b..b151398 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
@@ -567,7 +567,10 @@ public class ClientProxyImpl extends AbstractClient implements
         for (Parameter p : fm) {
             Multipart part = getMultipart(ori, p.getIndex());
             if (part != null) {
-                atts.add(new Attachment(part.value(), part.type(), params[p.getIndex()]));
+                Object partObject = params[p.getIndex()];
+                if (partObject != null) {
+                    atts.add(new Attachment(part.value(), part.type(), partObject));
+                }
             }
         }
         return atts;        

http://git-wip-us.apache.org/repos/asf/cxf/blob/5a9bcf36/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
index 884941a..2662507 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
@@ -307,6 +307,13 @@ public class JAXRSMultipartTest extends AbstractBusClientServerTestBase
{
     }
     
     @Test
+    public void testNullPartProxy() throws Exception {
+        MultipartStore store = 
+            JAXRSClientFactory.create("http://localhost:" + PORT, MultipartStore.class);
+        assertEquals("nobody home2", store.testNullParts("value1", null));
+    }
+    
+    @Test
     public void testUseProxyToAddBookAndSimpleParts() throws Exception {
         MultipartStore store = 
             JAXRSClientFactory.create("http://localhost:" + PORT, MultipartStore.class);

http://git-wip-us.apache.org/repos/asf/cxf/blob/5a9bcf36/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
index 10b4bf9..58c1609 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
@@ -186,6 +186,18 @@ public class MultipartStore {
             return "nobody home";
         }
     }
+    @POST
+    @Path("/books/testnullparts")
+    @Consumes("multipart/form-data")
+    @Produces("text/plain")
+    public String testNullParts(@Multipart(value = "someid") String value,
+                                @Multipart(value = "someid2", required = false) String value2)
{
+        if (value2 != null) {
+            return value + value2;
+        } else {
+            return "nobody home2";
+        }
+    }
     
     @POST
     @Path("/books/testnullpartprimitive")


Mime
View raw message