cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1344018 - in /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client: ClientProxyImpl.java WebClient.java
Date Tue, 29 May 2012 21:45:15 GMT
Author: sergeyb
Date: Tue May 29 21:45:15 2012
New Revision: 1344018

URL: http://svn.apache.org/viewvc?rev=1344018&view=rev
Log:
[CXF-4349] Updating the client runtime to check if current types are compatible with the original
ones

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1344018&r1=1344017&r2=1344018&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Tue May 29 21:45:15 2012
@@ -23,6 +23,7 @@ import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
+import java.lang.reflect.Type;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -632,9 +633,13 @@ public class ClientProxyImpl extends Abs
             Object body = objs.get(0);
             try {
                 if (bodyIndex != -1) {
+                    Class<?> paramClass = method.getParameterTypes()[bodyIndex];
+                    Type paramType = method.getGenericParameterTypes()[bodyIndex];
+                    
+                    boolean isAssignable = paramClass.isAssignableFrom(body.getClass());
                     writeBody(body, outMessage,
-                              method.getParameterTypes()[bodyIndex],
-                              method.getGenericParameterTypes()[bodyIndex],
+                              isAssignable ? paramClass : body.getClass(),
+                              isAssignable ? paramType : body.getClass(),
                               anns, headers, os);
                 } else {
                     writeBody(body, outMessage, body.getClass(), body.getClass(), 

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=1344018&r1=1344017&r2=1344018&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Tue
May 29 21:45:15 2012
@@ -880,10 +880,11 @@ public class WebClient extends AbstractC
                 requestClass = (Class<?>)requestContext.get(REQUEST_CLASS);
                 requestType = (Type)requestContext.get(REQUEST_TYPE);
             }
+            boolean isAssignable = requestClass != null && requestClass.isAssignableFrom(body.getClass());
             try {
                 writeBody(body, outMessage, 
-                          requestClass == null ? body.getClass() : requestClass,
-                          requestType == null ? body.getClass() : requestType, 
+                          requestClass == null || !isAssignable ? body.getClass() : requestClass,
+                          requestType == null || !isAssignable ? body.getClass() : requestType,

                           new Annotation[]{}, headers, os);
                 if (os != null) {
                     os.flush();



Mime
View raw message