Commons Discovery
  1. Commons Discovery
  2. DISCOVERY-17

Enumeration returned by Service.providers has a broken behavior

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 0.5
    • Fix Version/s: 0.5
    • Labels:
      None

      Description

      I find the current Enumeration behavior broken, but please tell me if I'm wrong!!!
      This is the actual current behavior:

      return new Enumeration<S>() {
                  private S object = getNextClassInstance();
      
                  public boolean hasMoreElements() {
                      return object != null;
                  }
      
                  public S nextElement() {
                      if (object == 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 (UnsatisfiedLinkError ule) {
                              // ignore
                          } catch (ExceptionInInitializerError eiie) {
                              // ignore
                          }
                      }
                      return null;
                  }
              };
      

      but it should be

      return new Enumeration<S>() {
      
                  public boolean hasMoreElements() {
                      return services.hasNext();
                  }
      
                  public S nextElement() {
                      ResourceClass<S> info = services.nextResourceClass();
                      try {
                          return spi.newInstance(info.loadClass());
                      } catch (Exception e) {
                          // ignore
                      } catch (UnsatisfiedLinkError ule) {
                          // ignore
                      } catch (ExceptionInInitializerError eiie) {
                          // ignore
                      }
                      return null;
                  }
              };
      

      I think there's no need to comment both codes, please tell me why the first one should be right

        Activity

        No work has yet been logged on this issue.

          People

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

            Dates

            • Due:
              Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 20m
              20m
              Remaining:
              Remaining Estimate - 20m
              20m
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development