cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Minor update to AbstractClient
Date Fri, 13 Jan 2017 12:02:44 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 78fbd425b -> 41eaa4d97


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/41eaa4d9
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/41eaa4d9
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/41eaa4d9

Branch: refs/heads/3.1.x-fixes
Commit: 41eaa4d9735e09d954d1a89bf60c1e5df608c095
Parents: 78fbd42
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Fri Jan 13 11:59:04 2017 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Fri Jan 13 12:02:25 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/41eaa4d9/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;
         }


Mime
View raw message