# HG changeset patch # Parent 0eb503d2b56761a35de73329cacda0c4d8515731 RT-33103: children may change, iterate over a copy diff -r 0eb503d2b567 modules/graphics/src/main/java/javafx/scene/Parent.java --- a/modules/graphics/src/main/java/javafx/scene/Parent.java Tue Oct 01 10:06:51 2013 -0700 +++ b/modules/graphics/src/main/java/javafx/scene/Parent.java Wed Oct 02 13:01:02 2013 -0400 @@ -1216,9 +1216,28 @@ // Let the super implementation handle CSS for this node super.impl_processCSS(); + // avoid the following call to children.toArray if there are no children + if (children.isEmpty()) return; + + // + // RT-33103 + // + // It is possible for a child to be removed from children in the middle of + // the following loop. Iterating over the children may result in an IndexOutOfBoundsException. + // So a copy is made and the copy is iterated over. + // + // Note that we don't want the fail-fast feature of an iterator, not to mention the general iterator overhead. + // + final Node[] childArray = children.toArray(new Node[children.size()]); + // For each child, process CSS - for (int i=0, max=children.size(); i