Author: mreutegg
Date: Tue Jun 23 06:43:23 2015
New Revision: 1686971
URL: http://svn.apache.org/r1686971
Log:
OAK-3019: VersionablePathHook must not process hidden nodes
Added:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VisibleChangesTest.java
(with props)
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java?rev=1686971&r1=1686970&r2=1686971&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionablePathHook.java
Tue Jun 23 06:43:23 2015
@@ -37,6 +37,7 @@ import org.apache.jackrabbit.oak.spi.com
import org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
import static
org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
@@ -108,6 +109,10 @@ public class VersionablePathHook impleme
@Override
public boolean childNodeChanged(
String name, NodeState before, NodeState after) {
+ if (NodeStateUtils.isHidden(name)) {
+ // stop comparison
+ return false;
+ }
Node node = new Node(nodeAfter, name);
return after.compareAgainstBaseState(
before, new Diff(versionManager, node, exceptions));
@@ -117,7 +122,8 @@ public class VersionablePathHook impleme
if (JcrConstants.JCR_VERSIONHISTORY.equals(after.getName()) &&
nodeAfter.isVersionable(versionManager)) {
NodeBuilder vhBuilder;
try {
- vhBuilder =
versionManager.getOrCreateVersionHistory(nodeAfter.builder,
Collections.EMPTY_MAP);
+ vhBuilder = versionManager.getOrCreateVersionHistory(
+ nodeAfter.builder, Collections.<String,
Object>emptyMap());
} catch (CommitFailedException e) {
exceptions.add(e);
// stop further comparison
Added:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VisibleChangesTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VisibleChangesTest.java?rev=1686971&view=auto
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VisibleChangesTest.java
(added)
+++
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VisibleChangesTest.java
Tue Jun 23 06:43:23 2015
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.document;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.Nonnull;
+
+import com.google.common.collect.Sets;
+
+import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
+import org.apache.jackrabbit.oak.plugins.version.VersionablePathHook;
+import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
+import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.junit.Test;
+
+import static
org.apache.jackrabbit.oak.plugins.document.util.Utils.getIdFromPath;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * <code>VisibleChangesTest</code>...
+ */
+public class VisibleChangesTest {
+
+ // OAK-3019
+ @Test
+ public void versionablePathHook() throws CommitFailedException {
+ TestStore store = new TestStore();
+ DocumentNodeStore ns = new DocumentMK.Builder()
+ .setDocumentStore(store).getNodeStore();
+ NodeBuilder builder = ns.getRoot().builder();
+ builder.child(":hidden");
+ ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+ builder = ns.getRoot().builder();
+ NodeBuilder hidden = builder.child(":hidden");
+
+ for (int i = 0; i <= DocumentMK.MANY_CHILDREN_THRESHOLD; i++) {
+ hidden.child("child-" + i);
+ }
+ // add more changes until a branch is created
+ NodeBuilder foo = builder.child("foo");
+ int numRevs = getRevisionsSize(store, "/");
+ while (numRevs == getRevisionsSize(store, "/")) {
+ foo.setProperty("p", "v");
+ foo.removeProperty("p");
+ }
+
+ store.paths.clear();
+ VersionablePathHook hook = new VersionablePathHook("default");
+ hook.processCommit(ns.getRoot(), builder.getNodeState(),
CommitInfo.EMPTY);
+ assertEquals("Must not query for hidden paths: " +
store.paths.toString(),
+ 0, store.paths.size());
+
+ ns.dispose();
+ }
+
+ private static int getRevisionsSize(DocumentStore store, String path) {
+ NodeDocument doc = store.find(Collection.NODES, getIdFromPath(path));
+ assertNotNull(doc);
+ return doc.getLocalRevisions().size();
+ }
+
+ private static final class TestStore extends MemoryDocumentStore {
+
+ private final Set<String> paths = Sets.newHashSet();
+
+ @Nonnull
+ @Override
+ public <T extends Document> List<T> query(Collection<T> collection,
+ String fromKey,
+ String toKey,
+ String indexedProperty,
+ long startValue,
+ int limit) {
+ if (indexedProperty != null) {
+ paths.add(fromKey);
+ }
+ return super.query(collection, fromKey, toKey, indexedProperty,
startValue, limit);
+ }
+ }
+}
Propchange:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/VisibleChangesTest.java
------------------------------------------------------------------------------
svn:eol-style = native