commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DISCOVERY-3) [discovery] Enumeration in Service broken
Date Wed, 29 Nov 2006 02:57:22 GMT
    [ http://issues.apache.org/jira/browse/DISCOVERY-3?page=comments#action_12454218 ] 
            
Henri Yandell commented on DISCOVERY-3:
---------------------------------------

However... I also don't want to go changing the source much before getting a release out.
Tempted to push this to 'later', which will probably be 'never'.

> [discovery] Enumeration in Service broken
> -----------------------------------------
>
>                 Key: DISCOVERY-3
>                 URL: http://issues.apache.org/jira/browse/DISCOVERY-3
>             Project: Commons Discovery
>          Issue Type: Bug
>    Affects Versions: Nightly Builds
>         Environment: Operating System: other
> Platform: Other
>            Reporter: matthew_pocock
>             Fix For: 0.4
>
>
> The Enumeration in org.apache.commons.discovery.tools.Service is broken - it
> will only work in the (admittedly common) case where you do:
>   while(e.hasMoreElements()) e.nextElement();
> If you repeatedly call nextElement(), you will get the wrong results. In
> particular, this uggly but technically correct code will fail to behave sanely:
>   try {
>     while(true)
>       e.nextElement();
>   } catch (NoSuchElementException e) {
>   }
> The code needs hacking arround to look something more like this:
> return new Enumeration() {
>   private Object object = getNextClassInstance();
>   public boolean hasMoreElements() {
>     return object != null;
>   }
>   public Object nextElement() {
>     if(object == null) {
>       throw new NoSuchElementException();
>     }
>     Object obj = object;
>     object = getNextClassInstance();
>     return obj;
>   }
>   private Object getNextClassInstance() {
>     // as before
>   }
> };

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message