|
Description: |
If it cannot be guaranteed that the Iterator will successfully access the next element using the "next" method, it is necessary to use the "hasNext" method to check before attempting to access the next element.
1.
If the number of nodes is an odd number, the second "it.next()" may cause NoSuchElementExceptions. { quote code }// xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/doc/XWikiDocumentArchive.java public void setArchive(String text) throws XWikiException { ... Collection nodes = archive.getNodes(getWikiReference(), getId()); for (Iterator it = nodes.iterator(); it.hasNext();) { XWikiRCSNodeInfo nodeInfo = (XWikiRCSNodeInfo) it.next(); XWikiRCSNodeContent nodeContent = (XWikiRCSNodeContent) it.next(); updateNode(nodeInfo); this.updatedNodeInfos.add(nodeInfo);
{ quote code } 2.
I couldn't find any logic that ensures the 'tables' variable is not empty. If there is no such logic in place, it is recommended to add proper validation to ensure that 'tables' is not empty before accessing it.
{ quote code }// xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/store/hibernate/query/HqlQueryUtils.java private static String getTableName(Table table, Map<String, String> tables) { String tableName = tables.values().iterator().next();
{ quote code } |
Assignee: |
Vincent Massol |
Pull Request Status: |
Awaiting Committer feedback |
|