Repository: cxf
Updated Branches:
  refs/heads/master 0d4441e70 -> 343a2a8a2


Minor update to AbstractClient


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

Branch: refs/heads/master
Commit: 343a2a8a2d2a271de61a9a326e6d966c3fb7dbfa
Parents: 0d4441e
Author: Sergey Beryozkin <sberyoz...@gmail.com>
Authored: Fri Jan 13 11:59:04 2017 +0000
Committer: Sergey Beryozkin <sberyoz...@gmail.com>
Committed: Fri Jan 13 11:59:04 2017 +0000

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxrs/client/AbstractClient.java  | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/343a2a8a/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 4a7d277..99e3bf9 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
@@ -973,9 +973,10 @@ public abstract class AbstractClient implements Client {
             m.put(Message.REQUEST_URI, requestURIProperty.toString());
         }
         
-        m.put(Message.CONTENT_TYPE, 
headers.getFirst(HttpHeaders.CONTENT_TYPE));
+        String ct = headers.getFirst(HttpHeaders.CONTENT_TYPE);
+        m.put(Message.CONTENT_TYPE, ct);
         
-        body = checkIfBodyEmpty(body);
+        body = checkIfBodyEmpty(body, ct);
         setEmptyRequestPropertyIfNeeded(m, body);    
         
         m.setContent(List.class, getContentsList(body));
@@ -1020,12 +1021,13 @@ public abstract class AbstractClient implements Client {
     }
 
     
-    protected Object checkIfBodyEmpty(Object body) {
+    protected Object checkIfBodyEmpty(Object body, String contentType) {
         //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()
+                && !MediaType.APPLICATION_JSON.equals(contentType)
             || body instanceof byte[] && ((byte[])body).length == 0)) {
             body = null;
         }

Reply via email to