jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bae...@apache.org
Subject svn commit: r1721205 - in /jackrabbit/branches/2.10/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/jackrabb...
Date Mon, 21 Dec 2015 16:15:48 GMT
Author: baedke
Date: Mon Dec 21 16:15:48 2015
New Revision: 1721205

URL: http://svn.apache.org/viewvc?rev=1721205&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 (patch
created by berry@halderen.net).

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

Modified: jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?rev=1721205&r1=1721204&r2=1721205&view=diff
==============================================================================
--- jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
(original)
+++ jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
Mon Dec 21 16:15:48 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/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java?rev=1721205&r1=1721204&r2=1721205&view=diff
==============================================================================
--- jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
(original)
+++ jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/AbstractBundlePersistenceManager.java
Mon Dec 21 16:15:48 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/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java?rev=1721205&r1=1721204&r2=1721205&view=diff
==============================================================================
--- jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
(original)
+++ jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/BundleReader.java
Mon Dec 21 16:15:48 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/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java?rev=1721205&r1=1721204&r2=1721205&view=diff
==============================================================================
--- jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java
(original)
+++ jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/NodePropBundle.java
Mon Dec 21 16:15:48 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/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=1721205&r1=1721204&r2=1721205&view=diff
==============================================================================
--- jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/branches/2.10/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Mon Dec 21 16:15:48 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/branches/2.10/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/LostFromCacheIssueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.10/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/LostFromCacheIssueTest.java?rev=1721205&view=auto
==============================================================================
--- jackrabbit/branches/2.10/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/LostFromCacheIssueTest.java
(added)
+++ jackrabbit/branches/2.10/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/LostFromCacheIssueTest.java
Mon Dec 21 16:15:48 2015
@@ -0,0 +1,84 @@
+package org.apache.jackrabbit.core;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Session;
+import javax.jcr.Workspace;
+import javax.jcr.nodetype.NodeTypeManager;
+
+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 Property mixinTypes;
+
+
+    public void setUp() throws Exception {
+
+        super.setUp();
+        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();
+        try {
+            namespaceRegistry.registerNamespace("lfcit", "data:lfcit");
+        } catch (NamespaceException ignore) { /* mapping may already be present */  }
+        QNodeTypeDefinition nodeTypeDefinition = new QNodeTypeDefinitionImpl(
+                ((SessionImpl)session).getQName("lfcit: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("lfcit:mxn"),
+                Name.EMPTY_ARRAY,
+                Name.EMPTY_ARRAY,
+                true,
+                false,
+                true,
+                false,
+                null,
+                QPropertyDefinition.EMPTY_ARRAY,
+                QNodeDefinition.EMPTY_ARRAY
+                );
+        nodetypeRegistry.registerNodeType(nodeTypeDefinition);
+
+        session.getRootNode().addNode("test").addNode("node");
+        session.save();
+    }
+
+    public void testIssue() throws Exception {
+        String path = "/test/node";
+        Session session = superuser;
+        Node node = session.getRootNode().getNode(path.substring(1));
+        node.addMixin("lfcit:mxn");
+        mixinTypes = node.getProperty("jcr:mixinTypes");
+        session.save();
+        node.addMixin("lfcit:mixin");
+        session.save();
+        node.removeMixin("lfcit:mxn");
+        node.removeMixin("lfcit:mixin");
+        session.save();
+        node.addMixin("lfcit:mixin");
+        session.save();
+    }
+}

Modified: jackrabbit/branches/2.10/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.10/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java?rev=1721205&r1=1721204&r2=1721205&view=diff
==============================================================================
--- jackrabbit/branches/2.10/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
(original)
+++ jackrabbit/branches/2.10/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/TestAll.java
Mon Dec 21 16:15:48 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