Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 26955 invoked from network); 18 Oct 2009 13:19:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Oct 2009 13:19:55 -0000 Received: (qmail 28192 invoked by uid 500); 18 Oct 2009 13:19:54 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 28086 invoked by uid 500); 18 Oct 2009 13:19:54 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 28076 invoked by uid 99); 18 Oct 2009 13:19:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Oct 2009 13:19:54 +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.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Oct 2009 13:19:52 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 43BB2234C045 for ; Sun, 18 Oct 2009 06:19:31 -0700 (PDT) Message-ID: <1033246955.1255871971262.JavaMail.jira@brutus> Date: Sun, 18 Oct 2009 06:19:31 -0700 (PDT) From: "Subhajit DasGupta (JIRA)" To: issues@commons.apache.org Subject: [jira] Created: (SANDBOX-314) ContinuationClassLoader does not close output stream in getClassFromStream(InputStream,String) 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 ContinuationClassLoader does not close output stream in getClassFromStream(InputStream,String) ---------------------------------------------------------------------------------------------- Key: SANDBOX-314 URL: https://issues.apache.org/jira/browse/SANDBOX-314 Project: Commons Sandbox Issue Type: Bug Components: Javaflow Environment: This is a problem with the way the getClassFromStream method is coded. The problem is independent of the environment. Reporter: Subhajit DasGupta Priority: Minor The getClassFromStream(InputStream,String) method creates a ByteArrayOutputStream but fails to close it after it finishes using it. This could lead to memory leaks in long running programs using the "getClassFromStream" method. I am submitting a patch below. This code opens and uses the ByteArrayIOutputStream object "baos" inside a "try", and closes baos in a "finally" block. Index: ContinuationClassLoader.java =================================================================== --- ContinuationClassLoader.java (revision 826428) +++ ContinuationClassLoader.java (working copy) @@ -350,7 +350,9 @@ */ private Class getClassFromStream(InputStream stream, String classname) throws IOException, SecurityException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ByteArrayOutputStream baos = null; + try{ + baos = new ByteArrayOutputStream(); int bytesRead; byte[] buffer = new byte[BUFFER_SIZE]; @@ -360,6 +362,11 @@ byte[] classData = baos.toByteArray(); return defineClassFromData(classData, classname); + }finally{ + if ( baos != null ){ + baos.close(); + } + } } /** -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.