Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 60B5C62BD for ; Wed, 1 Jun 2011 20:42:29 +0000 (UTC) Received: (qmail 40521 invoked by uid 500); 1 Jun 2011 20:42:29 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 40447 invoked by uid 500); 1 Jun 2011 20:42:28 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 40439 invoked by uid 99); 1 Jun 2011 20:42:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jun 2011 20:42:28 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jun 2011 20:42:27 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id A68A6EEFB2 for ; Wed, 1 Jun 2011 20:41:47 +0000 (UTC) Date: Wed, 1 Jun 2011 20:41:47 +0000 (UTC) From: "Simone Tripodi (JIRA)" To: issues@commons.apache.org Message-ID: <2012113120.60834.1306960907678.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Closed] (DISCOVERY-3) [discovery] Enumeration in Service broken MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DISCOVERY-3?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Simone Tripodi closed DISCOVERY-3. ---------------------------------- included in discovery-05 release > [discovery] Enumeration in Service broken > ----------------------------------------- > > Key: DISCOVERY-3 > URL: https://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 > Assignee: Simone Tripodi > Fix For: 0.5 > > > 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. For more information on JIRA, see: http://www.atlassian.com/software/jira