Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 49769 invoked from network); 5 Jan 2010 23:21:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Jan 2010 23:21:43 -0000 Received: (qmail 8779 invoked by uid 500); 5 Jan 2010 23:21:42 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 8683 invoked by uid 500); 5 Jan 2010 23:21:42 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 8674 invoked by uid 99); 5 Jan 2010 23:21:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jan 2010 23:21:42 +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.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jan 2010 23:21:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A1DFB23889FD; Tue, 5 Jan 2010 23:21:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r896267 - /commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationClassLoader.java Date: Tue, 05 Jan 2010 23:21:16 -0000 To: commits@commons.apache.org From: tcurdt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100105232119.A1DFB23889FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tcurdt Date: Tue Jan 5 23:20:59 2010 New Revision: 896267 URL: http://svn.apache.org/viewvc?rev=896267&view=rev Log: https://issues.apache.org/jira/browse/SANDBOX-314 (by Subhajit DasGupta) Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationClassLoader.java Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationClassLoader.java URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationClassLoader.java?rev=896267&r1=896266&r2=896267&view=diff ============================================================================== --- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationClassLoader.java (original) +++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ContinuationClassLoader.java Tue Jan 5 23:20:59 2010 @@ -348,18 +348,25 @@ * @exception SecurityException if there is a security problem while * reading the class from the stream. */ - private Class getClassFromStream(InputStream stream, String classname) - throws IOException, SecurityException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - int bytesRead; - byte[] buffer = new byte[BUFFER_SIZE]; + private Class getClassFromStream(InputStream stream, String classname) throws IOException, SecurityException { - while ((bytesRead = stream.read(buffer, 0, BUFFER_SIZE)) != -1) { - baos.write(buffer, 0, bytesRead); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + try { + + int bytesRead; + byte[] buffer = new byte[BUFFER_SIZE]; + + while ((bytesRead = stream.read(buffer, 0, BUFFER_SIZE)) != -1) { + baos.write(buffer, 0, bytesRead); + } + + byte[] classData = baos.toByteArray(); + return defineClassFromData(classData, classname); + + } finally { + baos.close(); } - - byte[] classData = baos.toByteArray(); - return defineClassFromData(classData, classname); } /**