Uploaded image for project: 'Jackrabbit Content Repository'
  1. Jackrabbit Content Repository
  2. JCR-586

Removing a mixin that adds a same-name-sibling child node throws an ItemNotFoundException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.9, 1.0, 1.0.1, 1.1
    • 1.1.1
    • jackrabbit-core, nodetype
    • None
    • Tested with trunk from 04-Oct-2006 (1.1)

    Description

      Apologies in advance if this has previously been noted in JIRA or on the lists but I couldn't find anything. When removing a mixin that defines a same-name-sibling child an ItemNotFoundException is thrown due to child node indicies not being maintained. A similar method of NodeImpl (onRemove) recongnized this and amended to remove from the tail but the removeMixin also has this issue.

      Simple test reproduction:

      Types:

      [mix:foo] mixin
      + bar (nt:bar) multiple

      [nt:bar] > nt:unstructured, mix:referenceable

      Code:

      public class RemoveMixinTest extends AbstractServerTest {
      private static final String MIXIN = "mix:foo";
      private static final String CHILD = "bar";
      private static final String PTYPE = "nt:bar";

      public void testRemoveMixin() throws RepositoryException {
      Session session = getSession();
      Node root = session.getRootNode().addNode("root");
      root.addMixin(MIXIN);

      root.addNode(CHILD, PTYPE);
      root.addNode(CHILD, PTYPE);
      root.addNode(CHILD, PTYPE);

      session.save();

      for (NodeIterator it = root.getNodes(); it.hasNext(); )

      { Node node = it.nextNode(); System.out.println(node.getPath() + " : " + node.getUUID()); }

      try

      { root.removeMixin(MIXIN); root.save(); }

      catch (RepositoryException ex)

      { ex.printStackTrace(); }

      }
      }

      Output:

      /root/bar : 0b09e0b4-0727-4194-978a-4eadfbf93fa8
      /root/bar[2] : 84d5e556-6f12-43fb-98e3-614bcf1f7bb7
      /root/bar[3] : 8db95029-df3b-4e26-affb-438de0206cf5

      javax.jcr.ItemNotFoundException: 8db95029-df3b-4e26-affb-438de0206cf5
      at org.apache.jackrabbit.core.ItemManager.createItemInstance(ItemManager.java:463)
      at org.apache.jackrabbit.core.ItemManager.getItem(ItemManager.java:319)
      at org.apache.jackrabbit.core.NodeImpl.removeMixin(NodeImpl.java:1212)
      at org.apache.jackrabbit.core.NodeImpl.removeMixin(NodeImpl.java:2624)
      at com.ms.appmw.rcf.server.RemoveMixinTest.testRemoveMixin(RemoveMixinTest.java:48)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at junit.framework.TestCase.runTest(TestCase.java:154)
      at msjava.base.testutils.junit3.MSTestCase.runTest(MSTestCase.java:203)
      at msjava.base.testutils.junit3.TestCaseTearDownEvenIfSetUpFails.runBare(TestCaseTearDownEvenIfSetUpFails.java:92)
      at msjava.base.testutils.junit3.MSTestCase.runBare(MSTestCase.java:170)
      at junit.framework.TestResult$1.protect(TestResult.java:106)

      The missing UUID for the last node is the one not found because upon removal of the second the index [2] is still valid. Thanks!

      Attachments

        Activity

          People

            stefan@jira Stefan Guggisberg
            mdaglian Michael Daglian
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: