Community
Participate
Working Groups
Build Identifier: While running ad-hoc testing on eclipse, the .log file had displayed the error: java.util.NoSuchElementException at java.util.AbstractList$SimpleListIterator.next(Unknown Source) at org.eclipse.wst.server.ui.internal.view.servers.AbstractServerAction.run(Unknown Source) at org.eclipse.ui.actions.RetargetAction.run(Unknown Source) at org.eclipse.ui.navigator.CommonNavigatorManager$3.open(Unknown Source) at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(Unknown Source) at org.eclipse.jface.viewers.StructuredViewer$2.run(Unknown Source) at org.eclipse.core.runtime.SafeRunner.run(Unknown Source) at org.eclipse.ui.internal.JFaceUtil$1.run(Unknown Source) ....... Since it was ad-hoc, I have been unable to reproduce the exact steps to throw that error. In org.eclipse.wst.server.ui.internal.view.servers.AbstractServerAction.run(), it should not be assumed that the iterator will have a next element. Reproducible: Always
Created attachment 200040 [details] Initial patch
I have attached a patch, that will return from the method to avoid the NoSuchElementException if the iterator has no elements. Tests run: 1. If the iterator has elements - the code will continue as usual after the check 2. If the iterator does not have an element - this was reproduced by temporarily making Iterator iterator = new StructuredSelection().iterator(). The iterator will have no next element and the method will exit silently (not throw an exception or write a trace) and not have a NoSuchElementException exception
Changes looks good with sufficient test coverage. Code committed 32M and 33M. One minor change to the original patch to update the copyright statement.
Code released to HEAD.
Code released to 32M and 33M.
New Gerrit change created: https://git.eclipse.org/r/109052