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

        Simone Tripodi created issue -
        Simone Tripodi made changes -
        Field Original Value New Value
        Description I find the current Enumeration behavior broken, but please tell me if I'm wrong!!!
        This is the actual current behavior:

        {code}
        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
                            }
                        }
                        return null;
                    }
                };
        {code}

        but shouldn't it be

        {code}
        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 (Throwable e) {
                            // TODO log exception
                            return null;
                        }
                    }
                };
        {code}


        I think there's no need to comment both codes, please tell me why the first one should be right :P
        I find the current Enumeration behavior broken, but please tell me if I'm wrong!!!
        This is the actual current behavior:

        {code}
        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) {
                                return null;
                            } catch (UnsatisfiedLinkError ule) {
                                return null;
                            } catch (ExceptionInInitializerError eiie) {
                                return null;
                            }
                        }
                        return null;
                    }
                };
        {code}

        but shouldn't it be

        {code}
        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 (Throwable e) {
                            // TODO log exception
                            return null;
                        }
                    }
                };
        {code}


        I think there's no need to comment both codes, please tell me why the first one should be right :P
        Simone Tripodi made changes -
        Description I find the current Enumeration behavior broken, but please tell me if I'm wrong!!!
        This is the actual current behavior:

        {code}
        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) {
                                return null;
                            } catch (UnsatisfiedLinkError ule) {
                                return null;
                            } catch (ExceptionInInitializerError eiie) {
                                return null;
                            }
                        }
                        return null;
                    }
                };
        {code}

        but shouldn't it be

        {code}
        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 (Throwable e) {
                            // TODO log exception
                            return null;
                        }
                    }
                };
        {code}


        I think there's no need to comment both codes, please tell me why the first one should be right :P
        I find the current Enumeration behavior broken, but please tell me if I'm wrong!!!
        This is the actual current behavior:

        {code}
        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) {
                                return null;
                            } catch (UnsatisfiedLinkError ule) {
                                return null;
                            } catch (ExceptionInInitializerError eiie) {
                                return null;
                            }
                        }
                        return null;
                    }
                };
        {code}

        but shouldn't it be

        {code}
        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) {
                            return null;
                        } catch (UnsatisfiedLinkError ule) {
                            return null;
                        } catch (ExceptionInInitializerError eiie) {
                            return null;
                        }
                    }
                };
        {code}


        I think there's no need to comment both codes, please tell me why the first one should be right :P
        Simone Tripodi made changes -
        Description I find the current Enumeration behavior broken, but please tell me if I'm wrong!!!
        This is the actual current behavior:

        {code}
        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) {
                                return null;
                            } catch (UnsatisfiedLinkError ule) {
                                return null;
                            } catch (ExceptionInInitializerError eiie) {
                                return null;
                            }
                        }
                        return null;
                    }
                };
        {code}

        but shouldn't it be

        {code}
        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) {
                            return null;
                        } catch (UnsatisfiedLinkError ule) {
                            return null;
                        } catch (ExceptionInInitializerError eiie) {
                            return null;
                        }
                    }
                };
        {code}


        I think there's no need to comment both codes, please tell me why the first one should be right :P
        I find the current Enumeration behavior broken, but please tell me if I'm wrong!!!
        This is the actual current behavior:

        {code}
        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;
                    }
                };
        {code}

        but shouldn't it be

        {code}
        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;
                    }
                };
        {code}


        I think there's no need to comment both codes, please tell me why the first one should be right :P
        Simone Tripodi made changes -
        Description I find the current Enumeration behavior broken, but please tell me if I'm wrong!!!
        This is the actual current behavior:

        {code}
        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;
                    }
                };
        {code}

        but shouldn't it be

        {code}
        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;
                    }
                };
        {code}


        I think there's no need to comment both codes, please tell me why the first one should be right :P
        I find the current Enumeration behavior broken, but please tell me if I'm wrong!!!
        This is the actual current behavior:

        {code}
        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;
                    }
                };
        {code}

        but it should be

        {code}
        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;
                    }
                };
        {code}


        I think there's no need to comment both codes, please tell me why the first one should be right :P
        Joerg Schaible made changes -
        Attachment org.apache.commons.logging.Log [ 12475855 ]
        Simone Tripodi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Simone Tripodi made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Simone Tripodi made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Invalid [ 6 ]
        Simone Tripodi made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          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