This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 257181

Summary: ExplorerManager#setSelectedNodes(): Error in validation code for nodes not under root
Product: platform Reporter: sjaenick
Component: ExplorerAssignee: Jan Peska <JPESKA>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.1   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description sjaenick 2015-12-16 16:58:36 UTC
If the setSelectedNodes() method is invoked with a node not existing below the
current root context, the checkAndSet() method of the inner class creates a new 
list instance for valid nodes and copies over previously validated nodes;
however, the copy loop uses the wrong index variable (i instead of j), thus 
repeatedly adding the same node:


               if (!isUnderRoot(value[i])) {
                   if (validNodes == null) {
                       validNodes = new ArrayList<Node>(value.length);
                       for (int j = 0; j < i; j++) {
---->                       validNodes.add(value[i]);   <-----
                       }
                   }

(starting at line 251 in 8.1)