Author: dbrosius
Date: Sun Oct 18 01:03:30 2009
New Revision: 826324

URL: http://svn.apache.org/viewvc?rev=826324&view=rev
Log:
make sure streams get closed

Modified:
    
jakarta/bcel/trunk/src/main/java/org/apache/bcel/util/SyntheticRepository.java

Modified: 
jakarta/bcel/trunk/src/main/java/org/apache/bcel/util/SyntheticRepository.java
URL: 
http://svn.apache.org/viewvc/jakarta/bcel/trunk/src/main/java/org/apache/bcel/util/SyntheticRepository.java?rev=826324&r1=826323&r2=826324&view=diff
==============================================================================
--- 
jakarta/bcel/trunk/src/main/java/org/apache/bcel/util/SyntheticRepository.java 
(original)
+++ 
jakarta/bcel/trunk/src/main/java/org/apache/bcel/util/SyntheticRepository.java 
Sun Oct 18 01:03:30 2009
@@ -145,17 +145,29 @@
      *   Repository, and its representation could not be found
      */
     public JavaClass loadClass( Class clazz ) throws ClassNotFoundException {
-        String className = clazz.getName();
-        JavaClass repositoryClass = findClass(className);
-        if (repositoryClass != null) {
-            return repositoryClass;
-        }
-        String name = className;
-        int i = name.lastIndexOf('.');
-        if (i > 0) {
-            name = name.substring(i + 1);
-        }
-        return loadClass(clazz.getResourceAsStream(name + ".class"), 
className);
+       InputStream clsStream = null;
+       try{
+               String className = clazz.getName();
+               JavaClass repositoryClass = findClass(className);
+               if (repositoryClass != null) {
+                   return repositoryClass;
+               }
+               String name = className;
+               int i = name.lastIndexOf('.');
+               if (i > 0) {
+                   name = name.substring(i + 1);
+               }
+               clsStream = clazz.getResourceAsStream(name + ".class");
+               return loadClass(clsStream, className);
+       } finally {
+               try{
+                       if (clsStream != null){
+                               clsStream.close();
+                       }
+               } catch(IOException ioe){
+                       //don't care
+               }
+       }
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-dev-unsubscr...@jakarta.apache.org
For additional commands, e-mail: bcel-dev-h...@jakarta.apache.org

Reply via email to