cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Avoiding auto-closing Reader and StreamingOutput, patch from Michail Nikolaev applied with minor updates, This closes #211
Date Thu, 08 Dec 2016 16:53:03 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 2389837fa -> 45d41dc1c


Avoiding auto-closing Reader and StreamingOutput, patch from Michail Nikolaev applied with
minor updates, This closes #211


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/45d41dc1
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/45d41dc1
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/45d41dc1

Branch: refs/heads/3.0.x-fixes
Commit: 45d41dc1c727de8b637267ca9b1c2a05e4ac2215
Parents: 2389837
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Dec 8 16:50:18 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Dec 8 16:52:46 2016 +0000

----------------------------------------------------------------------
 .../main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java    | 2 +-
 .../src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java | 8 ++++++++
 .../java/org/apache/cxf/jaxrs/client/AbstractClient.java     | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/45d41dc1/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
index f172737..f123a1a 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ResponseImpl.java
@@ -439,7 +439,7 @@ public final class ResponseImpl extends Response {
     }
     
     protected void autoClose(Class<?> cls, boolean exception) {
-        if (!entityBufferred && cls != InputStream.class
+        if (!entityBufferred && !JAXRSUtils.isStreamingOutType(cls)
             && (exception || MessageUtils.isTrue(outMessage.getContextualProperty("response.stream.auto.close"))))
{
             close();
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/45d41dc1/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index 41c12f6..9c4f3dd 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -22,6 +22,7 @@ package org.apache.cxf.jaxrs.utils;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.Reader;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -70,6 +71,7 @@ import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
 import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.StreamingOutput;
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.MessageBodyReader;
@@ -165,10 +167,16 @@ public final class JAXRSUtils {
     private static final String NO_CONTENT_EXCEPTION = "javax.ws.rs.core.NoContentException";
     private static final String HTTP_CHARSET_PARAM = "charset";
     private static final Annotation[] EMPTY_ANNOTATIONS = new Annotation[0]; 
+    private static final Set<Class<?>> STREAMING_OUT_TYPES = new HashSet<Class<?>>(
+        Arrays.asList(InputStream.class, Reader.class, StreamingOutput.class));
     
     private JAXRSUtils() {        
     }
     
+    public static boolean isStreamingOutType(Class<?> type) {
+        return STREAMING_OUT_TYPES.contains(type);
+    }
+    
     public static List<PathSegment> getPathSegments(String thePath, boolean decode)
{
         return getPathSegments(thePath, decode, true);
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/45d41dc1/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 efdc25a..11d1246 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
@@ -523,7 +523,7 @@ public abstract class AbstractClient implements Client {
     }
     
     protected boolean responseStreamCanBeClosed(Message outMessage, Class<?> cls) {
-        return cls != InputStream.class
+        return !JAXRSUtils.isStreamingOutType(cls)
             && MessageUtils.isTrue(outMessage.getContextualProperty("response.stream.auto.close"));
     }
     


Mime
View raw message