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