jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r951483 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/state/ test/java/org/apache/jackrabbit/core/
Date Fri, 04 Jun 2010 16:39:46 GMT
Author: stefan
Date: Fri Jun  4 16:39:45 2010
New Revision: 951483

URL: http://svn.apache.org/viewvc?rev=951483&view=rev
Log:
JCR-2632: Concurrent Session.move() operations failure

Added:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentRenameTest.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?rev=951483&r1=951482&r2=951483&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
Fri Jun  4 16:39:45 2010
@@ -1096,6 +1096,8 @@ public class SessionImpl extends Abstrac
         }
 
         if (srcParentNode.isSame(destParentNode)) {
+            // change definition of target
+            targetNode.onRedefine(newTargetDef.unwrap());
             // do rename
             destParentNode.renameChildNode(srcName.getName(), index, targetId, destName.getName());
         } else {
@@ -1105,6 +1107,8 @@ public class SessionImpl extends Abstrac
                 log.debug(msg);
                 throw new UnsupportedRepositoryOperationException(msg);
             }
+              // change definition of target
+            targetNode.onRedefine(newTargetDef.unwrap());
 
             // do move:
             // 1. remove child node entry from old parent
@@ -1120,9 +1124,6 @@ public class SessionImpl extends Abstrac
                     (NodeState) destParentNode.getOrCreateTransientItemState();
             destParentState.addChildNodeEntry(destName.getName(), targetId);
         }
-
-        // change definition of target
-        targetNode.onRedefine(newTargetDef.unwrap());
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java?rev=951483&r1=951482&r2=951483&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
Fri Jun  4 16:39:45 2010
@@ -131,15 +131,15 @@ class NodeStateMerger {
                         }
                     }
 
-                    // copy child node antries from other state and
+                    // copy child node entries from other state and
                     // re-apply changes made on this state
                     state.setChildNodeEntries(overlayedState.getChildNodeEntries());
-                    for (ChildNodeEntry cne : added) {
-                        state.addChildNodeEntry(cne.getName(), cne.getId());
-                    }
                     for (ChildNodeEntry cne : removed) {
                         state.removeChildNodeEntry(cne.getId());
                     }
+                    for (ChildNodeEntry cne : added) {
+                        state.addChildNodeEntry(cne.getName(), cne.getId());
+                    }
                 }
 
                 // property names

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java?rev=951483&r1=951482&r2=951483&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SessionItemStateManager.java
Fri Jun  4 16:39:45 2010
@@ -965,7 +965,7 @@ public class SessionItemStateManager
                                                 parent.getNodeTypeName(),
                                                 parent.getMixinTypeNames());
                                         QNodeDefinition def = ent.getApplicableChildNodeDef(name,
ns.getNodeTypeName(), ntReg);
-                                        return def != null ? def.allowsSameNameSiblings()
: false;
+                                        return def != null && def.allowsSameNameSiblings();
                                     } catch (Exception e) {
                                         log.warn("Unable to get node definition", e);
                                         return false;

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentRenameTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentRenameTest.java?rev=951483&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentRenameTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/ConcurrentRenameTest.java
Fri Jun  4 16:39:45 2010
@@ -0,0 +1,38 @@
+package org.apache.jackrabbit.core;
+
+import org.apache.jackrabbit.util.Text;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/**
+ * <code>org.apache.jackrabbit.core.ConcurrentRenameTest</code>...
+ */
+public class ConcurrentRenameTest extends AbstractConcurrencyTest {
+
+    private static final int NUM_MOVES = 100;
+    private static final int NUM_THREADS = 2;
+
+    public void testConcurrentRename() throws Exception {
+        runTask(new Task() {
+
+            public void execute(Session session, Node test)
+                    throws RepositoryException {
+                String name = Thread.currentThread().getName();
+                // create node
+                Node n = test.addNode(name);
+                session.save();
+                // do moves
+                for (int i = 0; i < NUM_MOVES; i++) {
+                    String path = n.getPath();
+                    String newName = name + "-" + i;
+                    String newPath = Text.getRelativeParent(path, 1) + "/" + newName;
+                    session.move(path, newPath);
+                    session.save();
+                    n = session.getNode(newPath);
+                }
+            }
+        }, NUM_THREADS, testRootNode.getPath());
+    }
+}
\ No newline at end of file



Mime
View raw message