Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: 0.5
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      Description

      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 }

      };

        Activity

        Hide
        Richard A. Sitze added a comment -

        acknowledge - this was a design choice... for better or worse.
        Will consider making [wholesale] changes to accomidate,
        but not likely to be done soon.

        Show
        Richard A. Sitze added a comment - acknowledge - this was a design choice... for better or worse. Will consider making [wholesale] changes to accomidate, but not likely to be done soon.
        Hide
        Henri Yandell added a comment -

        Can't say I see why the change requests can't be made. Doesn't seem like it would hurt anything for the action code to move from the has(..) method to the next(..) method.

        Any thoughts?

        Show
        Henri Yandell added a comment - Can't say I see why the change requests can't be made. Doesn't seem like it would hurt anything for the action code to move from the has(..) method to the next(..) method. Any thoughts?
        Hide
        Henri Yandell added a comment -

        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'.

        Show
        Henri Yandell added a comment - 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'.
        Hide
        Henri Yandell added a comment -

        Punting this to beyond 0.4 - Aiming to get a 0.4 released with the latest in SVN and then we'll see if any activity ever happens.

        Show
        Henri Yandell added a comment - Punting this to beyond 0.4 - Aiming to get a 0.4 released with the latest in SVN and then we'll see if any activity ever happens.
        Hide
        Simone Tripodi added a comment -

        Fixed on trunk, see Service r1090139

        Show
        Simone Tripodi added a comment - Fixed on trunk, see Service r1090139
        Hide
        Simone Tripodi added a comment -

        included in discovery-05 release

        Show
        Simone Tripodi added a comment - included in discovery-05 release

          People

          • Assignee:
            Simone Tripodi
            Reporter:
            matthew_pocock
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development