commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
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 GMT
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);
     }
 
     /**



Mime
View raw message