jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1606645 - in /jackrabbit/oak/branches/1.0: ./ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Date Mon, 30 Jun 2014 08:39:46 GMT
Author: mreutegg
Date: Mon Jun 30 08:39:46 2014
New Revision: 1606645

URL: http://svn.apache.org/r1606645
Log:
OAK-1861: Limit memory usage of DocumentNodeStore.readChildren()

Add test to verify fix.

Modified:
    jackrabbit/oak/branches/1.0/   (props changed)
    jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java

Propchange: jackrabbit/oak/branches/1.0/
------------------------------------------------------------------------------
  Merged /jackrabbit/oak/trunk:r1606638,1606641,1606644

Modified: jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java?rev=1606645&r1=1606644&r2=1606645&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
(original)
+++ jackrabbit/oak/branches/1.0/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Mon Jun 30 08:39:46 2014
@@ -443,6 +443,47 @@ public class DocumentNodeStoreTest {
         ns2.dispose();
     }
 
+    // OAK-1861
+    @Test
+    public void readChildrenWithDeletedSiblings() throws Exception {
+        final AtomicInteger maxLimit = new AtomicInteger(0);
+        DocumentStore docStore = new MemoryDocumentStore() {
+            @Nonnull
+            @Override
+            public <T extends Document> List<T> query(Collection<T> collection,
+                                                      String fromKey,
+                                                      String toKey,
+                                                      int limit) {
+                if (collection == Collection.NODES) {
+                    maxLimit.set(Math.max(limit, maxLimit.get()));
+                }
+                return super.query(collection, fromKey, toKey, limit);
+            }
+        };
+        DocumentNodeStore ns = new DocumentMK.Builder()
+                .setDocumentStore(docStore)
+                .setAsyncDelay(0).getNodeStore();
+        NodeBuilder builder = ns.getRoot().builder();
+        for (int i = 0; i < 1000; i++) {
+            builder.child("node-" + i);
+        }
+        ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+
+        // now remove all except the last one
+        for (int i = 0; i < 999; i++) {
+            builder = ns.getRoot().builder();
+            builder.getChildNode("node-" + i).remove();
+            ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+        }
+
+        for (ChildNodeEntry entry : ns.getRoot().getChildNodeEntries()) {
+            entry.getName();
+        }
+        // must not read more than DocumentNodeState.INITIAL_FETCH_SIZE + 1
+        assertTrue(maxLimit.get() + " > " + (DocumentNodeState.INITIAL_FETCH_SIZE + 1),
+                maxLimit.get() <= DocumentNodeState.INITIAL_FETCH_SIZE + 1);
+    }
+
     private static class TestHook extends EditorHook {
 
         TestHook(final String prefix) {



Mime
View raw message