jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r1333899 - in /jackrabbit/oak/trunk: oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
Date Fri, 04 May 2012 12:16:11 GMT
Author: stefan
Date: Fri May  4 12:16:10 2012
New Revision: 1333899

URL: http://svn.apache.org/viewvc?rev=1333899&view=rev
Log:
OAK-83: Copy operation would recurse indefinitely if memory permitted

Modified:
    jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
    jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java

Modified: jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java?rev=1333899&r1=1333898&r2=1333899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
(original)
+++ jackrabbit/oak/trunk/oak-it/mk/src/main/java/org/apache/jackrabbit/mk/test/MicroKernelIT.java
Fri May  4 12:16:10 2012
@@ -255,6 +255,17 @@ public class MicroKernelIT extends Abstr
     }
 
     @Test
+    public void copyToDescendant() {
+        mk.commit("/",
+                "+\"test/child\":{}\n" +
+                "*\"test\":\"test/copy\"\n",
+                null, "");
+
+        assertTrue(mk.nodeExists("/test/child", null));
+        assertTrue(mk.nodeExists("/test/copy/child", null));
+    }
+
+    @Test
     public void getNodes() {
         String head = mk.getHeadRevision();
 

Modified: jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java?rev=1333899&r1=1333898&r2=1333899&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/main/java/org/apache/jackrabbit/mk/model/CommitBuilder.java
Fri May  4 12:16:10 2012
@@ -284,13 +284,18 @@ public class CommitBuilder {
         }
     }
 
-    void copyStagedNodes(String srcPath, String destPath) throws Exception {
+    void copyStagedNodes(String srcPath, String destPath, String breakAtSrcPath) throws Exception
{
+        if (srcPath.equals(breakAtSrcPath)) {
+            // OAK-83: prevent infinite recursion when copying to descendant path
+            return;
+        }
+
         MutableNode node = staged.get(srcPath);
         if (node != null) {
             staged.put(destPath, new MutableNode(node, store, destPath));
             for (Iterator<String> it = node.getChildNodeNames(0, -1); it.hasNext();
) {
                 String childName = it.next();
-                copyStagedNodes(PathUtils.concat(srcPath, childName), PathUtils.concat(destPath,
childName));
+                copyStagedNodes(PathUtils.concat(srcPath, childName), PathUtils.concat(destPath,
childName), breakAtSrcPath);
             }
         }
     }
@@ -617,7 +622,7 @@ public class CommitBuilder {
                 // the copied subtree is modified
 
                 // update staging area
-                copyStagedNodes(srcPath, destPath);
+                copyStagedNodes(srcPath, destPath, destPath);
             }
         }
 



Mime
View raw message