jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bae...@apache.org
Subject svn commit: r1721196 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/ main/java/org/apache/jackrabbit/core/persistence/bundle/ main/java/org/apache/jackrabbit/core/persistence/util/ main/java/org/apache/jackrabbit/core/...
Date Mon, 21 Dec 2015 15:34:56 GMT
Author: baedke
Date: Mon Dec 21 15:34:56 2015
New Revision: 1721196

URL: http://svn.apache.org/viewvc?rev=1721196&view=rev
Log:
JCR-2633: Modified externally exception when modifying mixinTypes with single session

Persist jcr:mixinTypes to avoid inconsistencies when adding and removing mixin types.

Added:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/LostFromCacheIssueTest.java
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?rev=1721196&r1=1721195&r2=1721196&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
Mon Dec 21 15:34:56 2015
@@ -381,7 +381,7 @@ public class ItemManager implements Item
             try {
                 state = sism.getItemState(itemId);
             } catch (NoSuchItemStateException nsise) {
-                throw new ItemNotFoundException(itemId.toString());
+                throw new ItemNotFoundException(itemId.toString(), nsise);
             } catch (ItemStateException ise) {
                 String msg = "failed to retrieve item state of item " + itemId;
                 log.error(msg, ise);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=1721196&r1=1721195&r2=1721196&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
Mon Dec 21 15:34:56 2015
@@ -642,9 +642,8 @@ public abstract class AbstractBundlePers
                 bundle.update((NodeState) state);
             } else {
                 PropertyId id = (PropertyId) state.getId();
-                // skip redundant primaryType, mixinTypes and uuid properties
+                // skip redundant primaryType and uuid properties
                 if (id.getName().equals(JCR_PRIMARYTYPE)
-                    || id.getName().equals(JCR_MIXINTYPES)
                     || id.getName().equals(JCR_UUID)) {
                     continue;
                 }
@@ -690,9 +689,8 @@ public abstract class AbstractBundlePers
         for (ItemState state : changeLog.addedStates()) {
             if (!state.isNode()) {
                 PropertyId id = (PropertyId) state.getId();
-                // skip primaryType pr mixinTypes properties
+                // skip primaryType and uuid properties
                 if (id.getName().equals(JCR_PRIMARYTYPE)
-                    || id.getName().equals(JCR_MIXINTYPES)
                     || id.getName().equals(JCR_UUID)) {
                     continue;
                 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java?rev=1721196&r1=1721195&r2=1721196&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
Mon Dec 21 15:34:56 2015
@@ -248,7 +248,6 @@ class BundleReader {
             NodePropBundle.PropertyEntry pState = readPropertyEntry(pId);
             // skip redundant primaryType, mixinTypes and uuid properties
             if (!name.equals(NameConstants.JCR_PRIMARYTYPE)
-                    && !name.equals(NameConstants.JCR_MIXINTYPES)
                     && !name.equals(NameConstants.JCR_UUID)) {
                 bundle.addProperty(pState);
             }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java?rev=1721196&r1=1721195&r2=1721196&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java
Mon Dec 21 15:34:56 2015
@@ -306,7 +306,6 @@ public class NodePropBundle {
      */
     public void addProperty(PropertyEntry entry) {
         assert !NameConstants.JCR_PRIMARYTYPE.equals(entry.getName());
-        assert !NameConstants.JCR_MIXINTYPES.equals(entry.getName());
         assert !NameConstants.JCR_UUID.equals(entry.getName());
         properties.put(entry.getName(), entry);
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=1721196&r1=1721195&r2=1721196&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Mon Dec 21 15:34:56 2015
@@ -264,6 +264,7 @@ public class SharedItemStateManager
             }
         }
 
+        Exception ex = null;
         ISMLocking.ReadLock readLock = acquireReadLock(id);
         try {
             // check internal first
@@ -273,6 +274,7 @@ public class SharedItemStateManager
             // exception-for-control-flow performance hit here, as almost
             // all performance-critical content is non-virtual. With this
             // catch we can avoid an extra hasNonVirtualItemState() call.
+            ex = e;
         } finally {
             readLock.release();
         }
@@ -284,7 +286,8 @@ public class SharedItemStateManager
             }
         }
 
-        throw new NoSuchItemStateException(id.toString());
+        String message = id.toString();
+        throw ex == null ? new NoSuchItemStateException(message) : new NoSuchItemStateException(message,
ex);
     }
 
     /**

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/LostFromCacheIssueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/LostFromCacheIssueTest.java?rev=1721196&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/LostFromCacheIssueTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/LostFromCacheIssueTest.java
Mon Dec 21 15:34:56 2015
@@ -0,0 +1,132 @@
+package org.apache.jackrabbit.core;
+
+import java.io.File;
+import java.io.InputStream;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.Workspace;
+import javax.jcr.nodetype.NodeTypeManager;
+
+import junit.framework.TestCase;
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+public class LostFromCacheIssueTest extends AbstractJCRTest {
+    //public RepositoryImpl repository = null;
+    //public Session session = null;
+    public Property mixinTypes;
+
+//    static private void delete(File path) {
+//        if(path.exists()) {
+//            if(path.isDirectory()) {
+//                File[] files = path.listFiles();
+//                for(int i=0; i<files.length; i++)
+//                    delete(files[i]);
+//            }
+//            path.delete();
+//        }
+//    }
+//
+//    static private void clear() {
+//        String[] files = new String[] { ".lock", "repository", "version", "workspaces"
};
+//        for(int i=0; i<files.length; i++) {
+//            File file = new File(files[i]);
+//            delete(file);
+//        }
+//    }
+
+    public void setUp() throws Exception {
+//        org.apache.jackrabbit.core.config.RepositoryConfig repoConfig = null;
+//        InputStream config = getClass().getResourceAsStream("jackrabbit.xml");
+//        String path = ".";
+//
+//        clear();
+
+        super.setUp();
+
+        //repoConfig = org.apache.jackrabbit.core.config.RepositoryConfig.create(config,
path);
+        //repository = org.apache.jackrabbit.core.RepositoryImpl.create(repoConfig);
+        //Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
+        Session session = superuser;
+
+        System.err.println("Registering namespace and node types...");
+        Workspace workspace = session.getWorkspace();
+        NamespaceRegistry namespaceRegistry = workspace.getNamespaceRegistry();
+        NodeTypeManager ntmgr = workspace.getNodeTypeManager();
+        NodeTypeRegistry nodetypeRegistry = ((NodeTypeManagerImpl)ntmgr).getNodeTypeRegistry();
+        namespaceRegistry.registerNamespace("myprefix", "http://www.onehippo.org/test/1.0");
+        QNodeTypeDefinition nodeTypeDefinition = new QNodeTypeDefinitionImpl(
+                ((SessionImpl)session).getQName("test:mixin"),
+                Name.EMPTY_ARRAY,
+                Name.EMPTY_ARRAY,
+                true,
+                false,
+                true,
+                false,
+                null,
+                QPropertyDefinition.EMPTY_ARRAY,
+                QNodeDefinition.EMPTY_ARRAY
+                );
+        nodetypeRegistry.registerNodeType(nodeTypeDefinition);
+        nodeTypeDefinition = new QNodeTypeDefinitionImpl(
+                ((SessionImpl)session).getQName("test:mxn"),
+                Name.EMPTY_ARRAY,
+                Name.EMPTY_ARRAY,
+                true,
+                false,
+                true,
+                false,
+                null,
+                QPropertyDefinition.EMPTY_ARRAY,
+                QNodeDefinition.EMPTY_ARRAY
+                );
+        nodetypeRegistry.registerNodeType(nodeTypeDefinition);
+
+        /*System.err.println("Initializing tree...");
+        Node node = session.getRootNode();
+        node = node.addNode("test", "nt:unstructured");
+        buildTree(node, 2, 2, 10, 96, 0);
+        session.save();*/
+        session.getRootNode().addNode("test").addNode("node");
+        session.save();
+
+//        session.logout();
+//        this.session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
+    }
+
+//    public void tearDown() throws Exception {
+//        if (session != null) {
+//            session.logout();
+//        }
+//        if (repository != null) {
+//            repository.shutdown();
+//        }
+//    }
+
+    public void testIssue() throws Exception {
+        String path = "/test/node";
+        Session session = superuser;
+        Node node = session.getRootNode().getNode(path.substring(1));
+        node.addMixin("test:mxn");
+        mixinTypes = node.getProperty("jcr:mixinTypes");
+        session.save();
+        node.addMixin("test:mixin");
+        session.save();
+        node.removeMixin("test:mxn");
+        node.removeMixin("test:mixin");
+        session.save();
+        node.addMixin("test:mixin");
+        session.save();
+    }
+}

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java?rev=1721196&r1=1721195&r2=1721196&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
Mon Dec 21 15:34:56 2015
@@ -58,6 +58,8 @@ public class TestAll extends TestCase {
         suite.addTestSuite(ConcurrentReorderTest.class);
         suite.addTestSuite(ConcurrentAddRemoveNodeTest.class);
 
+        suite.addTestSuite(LostFromCacheIssueTest.class);
+
         // TODO: These tests pass, but they cause some instability in other
         // parts of the test suite, most likely due to uncleaned test data
         if (Boolean.getBoolean("org.apache.jackrabbit.test.integration")) {



Mime
View raw message