jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alex...@apache.org
Subject svn commit: r820337 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java
Date Wed, 30 Sep 2009 16:27:28 GMT
Author: alexkli
Date: Wed Sep 30 16:27:28 2009
New Revision: 820337

URL: http://svn.apache.org/viewvc?rev=820337&view=rev
Log:
JCR-2321: ZombieHierarchyManager can return wrong child node entries for replaced nodes

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java?rev=820337&r1=820336&r2=820337&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ZombieHierarchyManager.java
Wed Sep 30 16:27:28 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core;
 
+import java.util.Iterator;
+
 import org.apache.jackrabbit.core.id.ItemId;
 import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.state.ChildNodeEntry;
@@ -99,16 +101,19 @@
     protected ChildNodeEntry getChildNodeEntry(NodeState parent,
                                                          Name name,
                                                          int index) {
-        // check removed child node entries first
-        for (ChildNodeEntry entry : parent.getRemovedChildNodeEntries()) {
-            if (entry.getName().equals(name)
-                    && entry.getIndex() == index) {
-                return entry;
+        // first look for the entry in the current child node entry list
+        ChildNodeEntry entry = super.getChildNodeEntry(parent, name, index);
+        if (entry == null) {
+            // if not found, we need to look for a removed child node entry
+            for (ChildNodeEntry candidate : parent.getRemovedChildNodeEntries()) {
+                if (candidate.getName().equals(name)
+                        && candidate.getIndex() == index) {
+                    entry = candidate;
+                    break;
+                }
             }
         }
-        // no matching removed child node entry found in parent,
-        // delegate to base class
-        return super.getChildNodeEntry(parent, name, index);
+        return entry;
     }
 
     /**
@@ -118,14 +123,17 @@
      */
     protected ChildNodeEntry getChildNodeEntry(NodeState parent,
                                                          NodeId id) {
-        // check removed child node entries first
-        for (ChildNodeEntry entry : parent.getRemovedChildNodeEntries()) {
-            if (entry.getId().equals(id)) {
-                return entry;
+        // first look for the entry in the current child node entry list
+        ChildNodeEntry entry = super.getChildNodeEntry(parent, id);
+        if (entry == null) {
+            // if not found, we need to look for a removed child node entry
+            for (ChildNodeEntry candidate : parent.getRemovedChildNodeEntries()) {
+                if (candidate.getId().equals(id)) {
+                    entry = candidate;
+                    break;
+                }
             }
         }
-        // no matching removed child node entry found in parent,
-        // delegate to base class
-        return super.getChildNodeEntry(parent, id);
+        return entry;
     }
 }



Mime
View raw message