geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r982402 - /geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/BundleAssignableClassFinder.java
Date Wed, 04 Aug 2010 20:57:36 GMT
Author: gawor
Date: Wed Aug  4 20:57:35 2010
New Revision: 982402

URL: http://svn.apache.org/viewvc?rev=982402&view=rev
Log:
XBEAN-153: Avoid NPE by explicitely checking if passed class is java.lang.Object (classReader.getSuperName()
returns null if class is java.lang.Object)

Modified:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/BundleAssignableClassFinder.java

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/BundleAssignableClassFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/BundleAssignableClassFinder.java?rev=982402&r1=982401&r2=982402&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/BundleAssignableClassFinder.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/BundleAssignableClassFinder.java
Wed Aug  4 20:57:35 2010
@@ -189,11 +189,12 @@ public class BundleAssignableClassFinder
             logger.warn("Unable to check the interface " + interfaceName, e);
             return false;
         } finally {
-            if (in != null)
+            if (in != null) {
                 try {
                     in.close();
                 } catch (Exception e) {
                 }
+            }
         }
     }
 
@@ -205,7 +206,10 @@ public class BundleAssignableClassFinder
     private boolean isSuperClassAssignable(String superClassName) {
         if (targetClassNames.contains(superClassName)) {
             return true;
+        } else if (superClassName.equals("java/lang/Object")) {
+            return false;
         }
+        
         //Check parent class
         URL url = bundle.getResource("/" + superClassName + ".class");
         if (url == null) {
@@ -216,28 +220,27 @@ public class BundleAssignableClassFinder
         try {
             in = url.openStream();
             ClassReader classReader = new ClassReader(in);
-            String[] superInterfaceNames = classReader.getInterfaces();
+            
             //Check interfaces
+            String[] superInterfaceNames = classReader.getInterfaces();            
             for (String superInterfaceName : superInterfaceNames) {
                 if (isInterfaceAssignable(superInterfaceName)) {
                     return true;
-                }
+                }                
             }
+            
             //Check className
-            if (classReader.getSuperName().equals("java/lang/Object")) {
-                return targetClassNames.contains("java/lang/Object");
-            } else {
-                return isSuperClassAssignable(classReader.getSuperName());
-            }
+            return isSuperClassAssignable(classReader.getSuperName());            
         } catch (IOException e) {
             logger.warn("Unable to check the super class  " + superClassName, e);
             return false;
         } finally {
-            if (in != null)
+            if (in != null) {
                 try {
                     in.close();
                 } catch (Exception e) {
                 }
+            }
         }
     }
 



Mime
View raw message