commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1090660 - /commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/Service.java
Date Sat, 09 Apr 2011 19:51:50 GMT
Author: simonetripodi
Date: Sat Apr  9 19:51:49 2011
New Revision: 1090660

URL: http://svn.apache.org/viewvc?rev=1090660&view=rev
Log:
DISCOVERY-17: Enumeration returned by Service.providers has a broken behavior

Modified:
    commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/Service.java

Modified: commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/Service.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/Service.java?rev=1090660&r1=1090659&r2=1090660&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/Service.java
(original)
+++ commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/Service.java
Sat Apr  9 19:51:49 2011
@@ -91,32 +91,24 @@ public class Service {
             (new DiscoverClasses<T>(loaders)).findResourceClasses(servicesIter);
 
         return new Enumeration<S>() {
-            private S object = getNextClassInstance();
 
             public boolean hasMoreElements() {
-                return object != null;
+                return services.hasNext();
             }
 
             public S nextElement() {
-                if (object == null) {
+                ResourceClass<S> info = services.nextResourceClass();
+
+                if (info == null) {
                     throw new NoSuchElementException();
                 }
 
-                S obj = object;
-                object = getNextClassInstance();
-                return obj;
-            }
-
-            private S getNextClassInstance() {
-                while (services.hasNext()) {
-                    ResourceClass<S> info = services.nextResourceClass();
-                    try {
-                        return spi.newInstance(info.loadClass());
-                    } catch (Exception e) {
-                        // ignore
-                    } catch (LinkageError le) {
-                        // ignore
-                    }
+                try {
+                    return spi.newInstance(info.loadClass());
+                } catch (Exception e) {
+                    // ignore
+                } catch (LinkageError le) {
+                    // ignore
                 }
                 return null;
             }



Mime
View raw message