cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1552704 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
Date Fri, 20 Dec 2013 15:39:21 GMT
Author: sergeyb
Date: Fri Dec 20 15:39:21 2013
New Revision: 1552704

URL: http://svn.apache.org/r1552704
Log:
Autoclosing Response if the exception occurred, re-enabling all the async tests

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java?rev=1552704&r1=1552703&r2=1552704&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
Fri Dec 20 15:39:21 2013
@@ -371,13 +371,10 @@ public final class ResponseImpl extends 
                                                                        entityStream, 
                                                                        mediaType, 
                                                                        responseMessage);
-                if (!entityBufferred && responseStreamCanBeClosed(cls)) {
-                    InputStream.class.cast(entity).close();
-                    entity = null;
-                } 
-                
+                autoClose(cls, false); 
                 return castLastEntity();
             } catch (Exception ex) {
+                autoClose(cls, true);
                 reportMessageHandlerProblem("MSG_READER_PROBLEM", cls, mediaType, ex);
             }
         } else if (entity != null && cls.isAssignableFrom(entity.getClass())) {
@@ -436,10 +433,11 @@ public final class ResponseImpl extends 
         throw new ResponseProcessingException(this, errorMessage, cause);
     }
     
-    protected boolean responseStreamCanBeClosed(Class<?> cls) {
-        return cls != InputStream.class
-            && entity instanceof InputStream
-            && MessageUtils.isTrue(outMessage.getContextualProperty("response.stream.auto.close"));
+    protected void autoClose(Class<?> cls, boolean exception) {
+        if (!entityBufferred && cls != InputStream.class
+            && (exception || MessageUtils.isTrue(outMessage.getContextualProperty("response.stream.auto.close"))))
{
+            close();
+        }
     }
     
     public boolean bufferEntity() throws ProcessingException {

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java?rev=1552704&r1=1552703&r2=1552704&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
Fri Dec 20 15:39:21 2013
@@ -48,7 +48,6 @@ import org.apache.cxf.testutil.common.Ab
 
 import org.junit.Before;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class JAXRSAsyncClientTest extends AbstractBusClientServerTestBase {
@@ -101,16 +100,15 @@ public class JAXRSAsyncClientTest extend
     }
     
     @Test
-    @Ignore
     public void testGetBookAsyncResponse404() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/bookheaders/404";
         WebClient wc = createWebClient(address);
         Future<Response> future = wc.async().get(Response.class);
         assertEquals(404, future.get().getStatus());
+        wc.close();
     }
     
     @Test
-    @Ignore
     public void testGetBookAsync404() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/bookheaders/404";
         WebClient wc = createWebClient(address);
@@ -124,7 +122,6 @@ public class JAXRSAsyncClientTest extend
     }
     
     @Test
-    @Ignore
     public void testPostBookProcessingException() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/";
         List<Object> providers = new ArrayList<Object>();
@@ -141,7 +138,6 @@ public class JAXRSAsyncClientTest extend
     }
     
     @Test
-    @Ignore
     public void testGetBookResponseProcessingException() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/books/123";
         List<Object> providers = new ArrayList<Object>();
@@ -158,7 +154,6 @@ public class JAXRSAsyncClientTest extend
     }
     
     @Test
-    @Ignore
     public void testGetBookAsync404Callback() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/bookheaders/404";
         WebClient wc = createWebClient(address);



Mime
View raw message