Author: vgritsenko
Date: Fri Oct 27 20:07:13 2006
New Revision: 468622

URL: http://svn.apache.org/viewvc?view=rev&rev=468622
Log:
fix potential NPE

Modified:
    xml/xindice/trunk/java/src/org/apache/xindice/util/Configuration.java

Modified: xml/xindice/trunk/java/src/org/apache/xindice/util/Configuration.java
URL: 
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/util/Configuration.java?view=diff&rev=468622&r1=468621&r2=468622
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/util/Configuration.java 
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/util/Configuration.java Fri 
Oct 27 20:07:13 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
- * CVS $Id$
+ * $Id$
  */
 
 package org.apache.xindice.util;
@@ -38,7 +38,7 @@
  * fashion.
  *
  * @see org.apache.xindice.util.Configurable
- * @version CVS $Revision$, $Date$
+ * @version $Revision$, $Date$
  */
 public final class Configuration {
 
@@ -643,11 +643,18 @@
      */
     public void processChildren(ConfigurationCallback callback) {
         NodeList list = config.getChildNodes();
-        int size = list.getLength();
+
+        // Copy node list into array since callback can alter the configuration
+        Node[] nl = new Node[list.getLength()];
+        for (int i = 0; i < nl.length; i++) {
+            nl[i] = list.item(i);
+        }
+
+        int size = nl.length;
         try {
             for (int i = 0; i < size; i++) {
-                if (list.item(i).getNodeType() == Node.ELEMENT_NODE) {
-                    callback.process(new Configuration(this, (Element) 
list.item(i), readOnly));
+                if (nl[i].getNodeType() == Node.ELEMENT_NODE) {
+                    callback.process(new Configuration(this, (Element) nl[i], 
readOnly));
                 }
             }
         } catch (Exception e) {
@@ -667,6 +674,7 @@
     public void processChildren(String name, ConfigurationCallback callback) {
         NodeList list = config.getChildNodes();
 
+        // Copy node list into array since callback can alter the configuration
         Node[] nl = new Node[list.getLength()];
         for (int i = 0; i < nl.length; i++) {
             nl[i] = list.item(i);


Reply via email to