[
https://issues.apache.org/jira/browse/JCR-1040?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12518161
]
Julian Reschke commented on JCR-1040:
-------------------------------------
Turns out, adding addMixin("mix:referenceable") makes the test fail here as
well:
public void testRemoveThenAdd() throws RepositoryException {
Session session = testRootNode.getSession();
Node testnode;
String name = "delete-test";
Node root = session.getRootNode();
// make sure it's there
if (! root.hasNode(name)) {
testnode = root.addNode(name, "nt:folder");
testnode.addMixin("mix:referenceable");
session.save();
}
// now test remove/add in one batch
if (root.hasNode(name)) {
testnode = root.getNode(name);
testnode.remove();
// session.save(); // un-commenting this makes the test pass
}
testnode = root.addNode(name, "nt:folder");
testnode.addMixin("mix:referenceable");
// add one child
testnode = testnode.addNode(name, "nt:folder"); // commenting this out
makes the test pass
testnode.addMixin("mix:referenceable");
session.save();
}
...yields...
testRemoveThenAdd(org.apache.jackrabbit.jcr2spi.RemoveReferenceableTest) Time
elapsed: 0.015 sec <<< ERROR!
javax.jcr.ItemExistsException: Cannot add child node 'delete-test' to
/delete-test: colliding with same-named existing node.
at
org.apache.jackrabbit.jcr2spi.state.ItemStateValidator.checkCollision(ItemStateValidator.java:594)
at
org.apache.jackrabbit.jcr2spi.state.ItemStateValidator.checkAddNode(ItemStateValidator.java:387)
at
org.apache.jackrabbit.jcr2spi.state.SessionItemStateManager.addNodeState(SessionItemStateManager.java:610)
at
org.apache.jackrabbit.jcr2spi.state.SessionItemStateManager.visit(SessionItemStateManager.java:263)
at
org.apache.jackrabbit.jcr2spi.operation.AddNode.accept(AddNode.java:63)
at
org.apache.jackrabbit.jcr2spi.state.SessionItemStateManager.execute(SessionItemStateManager.java:229)
> JCR2SPI: remove node operation missing in submitted SPI batch
> -------------------------------------------------------------
>
> Key: JCR-1040
> URL: https://issues.apache.org/jira/browse/JCR-1040
> Project: Jackrabbit
> Issue Type: Bug
> Components: SPI
> Reporter: Julian Reschke
>
> In JCR2SPI, the following sequence of operations seems to lead to an
> incorrect SPI batch being submitted:
> 1) remove "/a"
> 2) add "/a"
> 3) add "/a/b"
> 4) session.save()
> This seems to create an SPI batch where the first remove operation is missing.
> Note that the problem only seems to occur when step 3 is part of the sequence.
> Full Java source for test:
> try {
> if
> (session.getRepository().getDescriptor(Repository.LEVEL_2_SUPPORTED).equals("true"))
> {
> Node testnode;
> String name = "delete-test";
>
> Node root = session.getRootNode();
>
> // make sure it's there
> if (! root.hasNode(name)) {
> root.addNode(name, "nt:folder");
> session.save();
> }
>
> // now test remove/add in one batch
> if (root.hasNode(name)) {
> testnode = root.getNode(name);
> testnode.remove();
> // session.save(); // un-commenting this makes the test pass
> }
>
> testnode = root.addNode(name, "nt:folder");
> // add one child
> testnode.addNode(name, "nt:folder"); // commenting this out makes the
> test pass
>
> session.save();
> }
> } finally {
> session.logout();
> }
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.