cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1509863 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
Date Fri, 02 Aug 2013 21:11:35 GMT
Author: sergeyb
Date: Fri Aug  2 21:11:34 2013
New Revision: 1509863

URL: http://svn.apache.org/r1509863
Log:
Protecting a bit against the spec requirement to auto-close Response original stream if the
requested entity is not InputStream

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.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=1509863&r1=1509862&r2=1509863&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 Aug  2 21:11:34 2013
@@ -56,6 +56,7 @@ import org.apache.cxf.jaxrs.utils.HttpUt
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
 
 public final class ResponseImpl extends Response {
     private int status;
@@ -355,7 +356,9 @@ public final class ResponseImpl extends 
                                                                            InputStream.class.cast(entity),

                                                                            mediaType, 
                                                                            responseMessage);
-                    InputStream.class.cast(entity).close();
+                    if (responseStreamCanBeClosed(cls)) {
+                        InputStream.class.cast(entity).close();
+                    }
                     entity = newEntity;
                     entityBufferred = true;
                     
@@ -369,6 +372,10 @@ public final class ResponseImpl extends 
         
     }
     
+    protected boolean responseStreamCanBeClosed(Class<?> cls) {
+        return cls != InputStream.class
+            && MessageUtils.isTrue(responseMessage.getContextualProperty("response.stream.auto.close"));
+    }
     
     public boolean bufferEntity() throws ProcessingException {
         checkEntityIsClosed();



Mime
View raw message