Uploaded image for project: 'Commons Discovery'
  1. Commons Discovery
  2. DISCOVERY-17

Enumeration returned by Service.providers has a broken behavior

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 0.5
    • 0.5
    • 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

      Attachments

        1. org.apache.commons.logging.Log
          0.2 kB
          Joerg Schaible

        Activity

          People

            simone.tripodi Simone Tripodi
            simone.tripodi Simone Tripodi
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

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