geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1617090 - /geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
Date Sun, 10 Aug 2014 11:09:12 GMT
Author: rmannibucau
Date: Sun Aug 10 11:09:12 2014
New Revision: 1617090

URL: http://svn.apache.org/r1617090
Log:
easy way to avoid duplicates in findImplementations, real fix needs really more refactoring
so ok for now

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

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java?rev=1617090&r1=1617089&r2=1617090&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
Sun Aug 10 11:09:12 2014
@@ -1062,24 +1062,29 @@ public class AnnotationFinder implements
         // Collect all interfaces extending the main interface (recursively)
         // Collect all implementations of interfaces
         // i.e. all *directly* implementing classes
-        List<ClassInfo> infos = collectImplementations(interfaceName);
+        final List<ClassInfo> infos = collectImplementations(interfaceName);
 
         // Collect all subclasses of implementations
-        List<Class<? extends T>> classes = new LinkedList<Class<? extends
T>>();
+        final List<Class<? extends T>> classes = new LinkedList<Class<?
extends T>>();
         for (ClassInfo info : infos) {
             try {
                 final Class<? extends T> impl = (Class<? extends T>) info.get();
 
-                if (clazz.isAssignableFrom(impl)) {
+                if (!classes.contains(impl) && clazz.isAssignableFrom(impl)) {
                     classes.add(impl);
 
                     // Optimization: Don't need to call this method if parent class was already
searched
 
 
-                    classes.addAll(_findSubclasses(impl));
+                    final List<Class<? extends T>> c = _findSubclasses((Class<T>)
impl);
+                    for (final Class<? extends T> cl : c) {
+                        if (!classes.contains(cl)) {
+                            classes.add(cl);
+                        }
+                    }
                 }
 
-            } catch (ClassNotFoundException e) {
+            } catch (final ClassNotFoundException e) {
                 classesNotLoaded.add(info.getName());
             }
         }



Mime
View raw message