Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1490

orderBefore causes exception

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • 2.8.2.Final
    • 2.7.0.Final
    • JCR

    Description

      In Modeshape 3.0-Alpha4 calling orderBefore on a checked-out node multiple times causes a hang in org.modeshape.jcr.cache.document.AbstractChildReferences from lines 119 - 128 unless each call is followed by save().

      It also fails on Modeshape 2.7, but throws an Exception ("No item exists at path {}Child 0 in workspace "workspace1"")

      This code runs fine on Jackrabbit 1.6 and 2.3.

      You have my permission to include the attached tests in your test suite if you find them useful.

      The following test will exercise the bug:

      package com.mom.jcrperf.tests;
      
      import javax.jcr.Node;
      import javax.jcr.NodeIterator;
      import javax.jcr.RepositoryException;
      import javax.jcr.Session;
      
      /**
       * Measure the speed of reordering child nodes.
       * 
       * Create 10 parents Give each one 100 children Reorder the children in reverse
       * order
       */
      public class ReorderChildNodesTest extends PerformanceTest {
      
           private static final int PARENT_COUNT = 10;
           private static final int CHILD_COUNT = 100;
      
           private Session session;
      
           private Node node;
      
           private String bigProperty = "this is a nice big string";
      
           public void beforeSuite() throws RepositoryException {
      
                for (int i = 0; i < 8; i++) {
                     bigProperty = bigProperty + bigProperty + i;
                }
      
                session = getRepository().login(getCredentials());
                node = session.getRootNode().addNode("testnode", "nt:unstructured");
                for (int i = 0; i < PARENT_COUNT; i++) {
      
                     Node parent = node.addNode("node" + i, "nt:unstructured");
                     parent.addMixin("mix:versionable");
                     parent.setProperty("prop_" + i, bigProperty + i);
                     
                     session.save();
                     
                     parent.checkout();
      
                     for (int j = 0; j < CHILD_COUNT; j++) {
                          Node child = parent.addNode("Child " + j, "nt:unstructured");
                          child.addMixin("mix:versionable");
                          child.setProperty("prop_" + j, bigProperty + j);
                     }
                     parent.save();
                     parent.checkin();
                }
                session.save();
           }
      
           public void beforeTest() throws RepositoryException {
                //
           }
      
           public void runTest() throws Exception {
      
                for (NodeIterator i = node.getNodes(); i.hasNext();) {
      
                     Node parent = i.nextNode();
                     parent.checkout();
                     
                     int kid = 0;
      
                     for (NodeIterator j = parent.getNodes(); j.hasNext();) {
                          Node child = j.nextNode();
                          parent.orderBefore("Child " + kid, "Child 0");
                          kid++;
                     }
                     parent.save(); // !!!! Moving this code up into the loop eliminates the problem !!!!
                     parent.checkin();
                }
                session.save();
           }
      
           public void afterTest() throws RepositoryException {
                session.save();
           }
      
           public void afterSuite() throws RepositoryException {
                session.getRootNode().getNode("testnode").remove();
                session.save();
                session.logout();
           }
      
      }
      

      Attachments

        Issue Links

          Activity

            People

              hchiorean Horia Chiorean (Inactive)
              duncanmcintyre Duncan McIntyre (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: