Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9FC3C200BD5 for ; Thu, 8 Dec 2016 17:50:39 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 9E6A1160B1F; Thu, 8 Dec 2016 16:50:39 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id F135E160B0A for ; Thu, 8 Dec 2016 17:50:38 +0100 (CET) Received: (qmail 61383 invoked by uid 500); 8 Dec 2016 16:50:38 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 61367 invoked by uid 99); 8 Dec 2016 16:50:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Dec 2016 16:50:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E9F27E7DE3; Thu, 8 Dec 2016 16:50:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sergeyb@apache.org To: commits@cxf.apache.org Message-Id: <3369565fc3ad4ad1b243f5c59b4df927@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: Avoiding auto-closing Reader and StreamingOutput, patch from Michail Nikolaev applied with minor updates, This closes #211 Date: Thu, 8 Dec 2016 16:50:37 +0000 (UTC) archived-at: Thu, 08 Dec 2016 16:50:39 -0000 Repository: cxf Updated Branches: refs/heads/master 40dd6d61c -> aa0293ec6 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/aa0293ec Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/aa0293ec Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/aa0293ec Branch: refs/heads/master Commit: aa0293ec68a635a2b3ef2b585fd7b5e0a3cdcf8e Parents: 40dd6d6 Author: Sergey Beryozkin Authored: Thu Dec 8 16:50:18 2016 +0000 Committer: Sergey Beryozkin Committed: Thu Dec 8 16:50:18 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/aa0293ec/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 12127b9..fa56e9f 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 @@ -440,7 +440,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/aa0293ec/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 5b87b64..442b50f 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; @@ -71,6 +72,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; @@ -166,10 +168,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> STREAMING_OUT_TYPES = new HashSet>( + 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 getPathSegments(String thePath, boolean decode) { return getPathSegments(thePath, decode, true); } http://git-wip-us.apache.org/repos/asf/cxf/blob/aa0293ec/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 b97483e..b83989f 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 @@ -525,7 +525,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")); }