Return-Path: Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: (qmail 91273 invoked from network); 16 Apr 2010 22:17:50 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Apr 2010 22:17:50 -0000 Received: (qmail 87312 invoked by uid 500); 16 Apr 2010 22:17:50 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 87286 invoked by uid 500); 16 Apr 2010 22:17:50 -0000 Mailing-List: contact issues-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 issues@cxf.apache.org Received: (qmail 87278 invoked by uid 99); 16 Apr 2010 22:17:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Apr 2010 22:17:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Apr 2010 22:17:47 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o3GMHPTf008269 for ; Fri, 16 Apr 2010 18:17:26 -0400 (EDT) Message-ID: <11882065.19161271456245754.JavaMail.jira@thor> Date: Fri, 16 Apr 2010 18:17:25 -0400 (EDT) From: "Nathan Waldman (JIRA)" To: issues@cxf.apache.org Subject: [jira] Commented: (CXF-2768) Temporary files are not deleted for requests >64kb when using LoggingInInterceptor In-Reply-To: <10421544.17081271450725399.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CXF-2768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12858034#action_12858034 ] Nathan Waldman commented on CXF-2768: ------------------------------------- This is possibly related to CXF-1743, but it is definitely not working on Windows XP. > Temporary files are not deleted for requests >64kb when using LoggingInInterceptor > ---------------------------------------------------------------------------------- > > Key: CXF-2768 > URL: https://issues.apache.org/jira/browse/CXF-2768 > Project: CXF > Issue Type: Bug > Components: Core > Affects Versions: 2.2.3, 2.2.5 > Environment: Windows XP, Linux > Java 1.6 > Reporter: Nathan Waldman > > When we use the LoggingInInterceptor and receive a request that is larger than 64kb, CXF creates a temporary file, but does not delete it. > The LoggingInInterceptor closes the message's original input stream and opens a new one. In the case of a request that is larger than 64kb, the CachedOutputStream creates a temporary file which the new input stream is reads. The new FileInputStream's close method is overridden to delete the temporary file when it is closed, but that close is never called. > It appears that CXF assumes that the input stream passed to the interceptors does not need to be closed explicitly, because in the normal case that input stream is the HttpServletRequest input stream which will be closed by the container. However when LoggingInInterceptor passes along a new input stream to the rest of the interceptor chain, it is left unclosed. > I created a new InputStreamClosingInterceptor that explicitly closes the input stream if it exists and set it for the PRE_INVOKE phase so that it runs after all other interceptors are done with the input stream. With this change the new input stream is successfully closed and the temporary file is correctly deleted. Is this safe? > public class InputStreamClosingInterceptor > extends AbstractPhaseInterceptor > { > public InputStreamClosingInterceptor() { > super(Phase.PRE_INVOKE); > } > public void handleMessage(Message message) > throws Fault > { > InputStream inputStream = message.getContent(InputStream.class); > if(inputStream != null) { > closeInputStream(inputStream); > } > } > private void closeInputStream(InputStream inputStream) { > try { > inputStream.close(); > } > catch (IOException e) { > throw new Fault(e); > } > } > } > A more elegant solution would be to modify CXF so that it does not assume that the input stream passed to the interceptor chain is the same stream at the end of the chain, and that it explicitly closes the resultant stream at the end of the chain processing in the framework. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira