cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1549623 - in /cxf/trunk: rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Date Mon, 09 Dec 2013 17:31:10 GMT
Author: sergeyb
Date: Mon Dec  9 17:31:10 2013
New Revision: 1549623

URL: http://svn.apache.org/r1549623
Log:
[CXF-5447] Checking for empty byte arrays to prevent POST issues over HTTPUrlConnection

Modified:
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1549623&r1=1549622&r2=1549623&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java (original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java Mon
Dec  9 17:31:10 2013
@@ -925,12 +925,15 @@ public abstract class AbstractClient imp
 
     
     protected Object checkIfBodyEmpty(Object body) {
+        //CHECKSTYLE:OFF
         if (body != null 
             && (body.getClass() == String.class && ((String)body).length()
== 0 
             || body.getClass() == Form.class && ((Form)body).asMap().isEmpty()
-            || Map.class.isAssignableFrom(body.getClass()) && ((Map<?, ?>)body).isEmpty()))
{
+            || Map.class.isAssignableFrom(body.getClass()) && ((Map<?, ?>)body).isEmpty()

+            || body instanceof byte[] && ((byte[])body).length == 0)) {
             body = null;
         }
+        //CHECKSTYLE:ON
         return body;
     }
     

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1549623&r1=1549622&r2=1549623&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Mon Dec  9 17:31:10 2013
@@ -1063,6 +1063,16 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testEmptyPostBytes() throws Exception {
+        WebClient wc = 
+            WebClient.create("http://localhost:" 
+                             + PORT + "/bookstore/emptypost");
+        Response response = wc.post(new byte[]{});
+        assertEquals(204, response.getStatus());
+        assertNull(response.getMetadata().getFirst("Content-Type"));
+    }
+    
+    @Test
     public void testEmptyPut() throws Exception {
         WebClient wc = 
             WebClient.create("http://localhost:" 



Mime
View raw message