cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1084241 - in /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client: AbstractClient.java ClientProxyImpl.java WebClient.java
Date Tue, 22 Mar 2011 16:33:37 GMT
Author: sergeyb
Date: Tue Mar 22 16:33:37 2011
New Revision: 1084241

URL: http://svn.apache.org/viewvc?rev=1084241&view=rev
Log:
[JAX-RS] Avoid checking HttpURLConnection for the status code on the client side

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    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/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1084241&r1=1084240&r2=1084241&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Tue Mar 22 16:33:37 2011
@@ -18,7 +18,6 @@
  */
 package org.apache.cxf.jaxrs.client;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
@@ -408,30 +407,27 @@ public class AbstractClient implements C
     }
     
     @SuppressWarnings("unchecked")
-    protected Object readBody(Response r, HttpURLConnection conn, Message outMessage, Class<?>
cls, 
+    protected Object readBody(Response r, Message inMessage, Class<?> cls, 
                               Type type, Annotation[] anns) {
 
         InputStream inputStream = (InputStream)r.getEntity();
         if (inputStream == null) {
             return cls == Response.class ? r : null;
         }
-        try {
-            int status = conn.getResponseCode();
-            if (status < 200 || status == 204 || status > 300) {
-                Object length = r.getMetadata().getFirst(HttpHeaders.CONTENT_LENGTH);
-                if (length == null || Integer.parseInt(length.toString()) == 0
-                    || status >= 400) {
-                    return cls == Response.class ? r : status >= 400 ? inputStream : null;
-                }
+        
+        int status = r.getStatus();
+        if (status < 200 || status == 204 || status > 300) {
+            Object length = r.getMetadata().getFirst(HttpHeaders.CONTENT_LENGTH);
+            if (length == null || Integer.parseInt(length.toString()) == 0
+                || status >= 400) {
+                return cls == Response.class ? r : status >= 400 ? inputStream : null;
             }
-        } catch (IOException ex) {
-            // won't happen at this stage
         }
         
         MediaType contentType = getResponseContentType(r);
         
-        MessageBodyReader mbr = ProviderFactory.getInstance(outMessage).createMessageBodyReader(
-            cls, type, anns, contentType, outMessage);
+        MessageBodyReader mbr = ProviderFactory.getInstance(inMessage).createMessageBodyReader(
+            cls, type, anns, contentType, inMessage);
         if (mbr != null) {
             try {
                 return mbr.readFrom(cls, type, anns, contentType, 

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=1084241&r1=1084240&r2=1084241&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 Mar 22 16:33:37 2011
@@ -460,7 +460,7 @@ public class ClientProxyImpl extends Abs
             return r;
         }
         
-        return readBody(r, connect, outMessage, method.getReturnType(), 
+        return readBody(r, outMessage, method.getReturnType(), 
                         method.getGenericReturnType(), method.getDeclaredAnnotations());
     }
 

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=1084241&r1=1084240&r2=1084241&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
Mar 22 16:33:37 2011
@@ -634,7 +634,7 @@ public class WebClient extends AbstractC
             ResponseBuilder rb = setResponseBuilder(conn, outMessage.getExchange());
             Response currentResponse = rb.clone().build();
             
-            Object entity = readBody(currentResponse, conn, outMessage, responseClass, genericType,
+            Object entity = readBody(currentResponse, outMessage, responseClass, genericType,
                                      new Annotation[]{});
             rb.entity(entity instanceof Response 
                       ? ((Response)entity).getEntity() : entity);



Mime
View raw message