Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java (revision 1768507) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java (working copy) @@ -35,6 +35,8 @@ import com.google.common.collect.Sets; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.commons.PathUtils; +import org.apache.jackrabbit.oak.commons.json.JsopStream; +import org.apache.jackrabbit.oak.commons.json.JsopWriter; import org.apache.jackrabbit.oak.plugins.document.util.Utils; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.slf4j.Logger; @@ -277,6 +279,10 @@ } } + for (String p : bundledNodes.keySet()){ + markChanged(p); + } + // push branch changes to journal if (baseBranchRevision != null) { // store as external change @@ -662,27 +668,50 @@ } UpdateOp op = operations.get(path); - //In case its bundled the op would be the one for - //bundling root - boolean bundled = isBundled(path); - if (bundled){ - String bundlingRoot = bundledNodes.get(path); - op = operations.get(bundlingRoot); - } - - boolean isNew = op != null && op.isNew(); - if (op == null || !hasContentChanges(op) || denotesRoot(path)) { - // track intermediate node and root - if (!bundled) { + // track _lastRev and apply to cache only when + // path is not for a bundled node state + if (!isBundled(path)) { + boolean isNew = op != null && op.isNew(); + if (op == null || !hasContentChanges(op) || denotesRoot(path)) { + // track intermediate node and root tracker.track(path); } + nodeStore.applyChanges(before, after, rev, path, isNew, + added, removed, changed); } - nodeStore.applyChanges(before, after, rev, path, isNew, - added, removed, changed, cacheEntry); + addChangesToDiffCacheEntry(path, added, removed, changed, cacheEntry); } cacheEntry.done(); } + /** + * Apply the changes of a node to the cache. + * + * @param path the path + * @param added the list of added child nodes + * @param removed the list of removed child nodes + * @param changed the list of changed child nodes + * @param cacheEntry the cache entry changes are added to + */ + private void addChangesToDiffCacheEntry(String path, + List added, + List removed, + List changed, + DiffCache.Entry cacheEntry) { + // update diff cache + JsopWriter w = new JsopStream(); + for (String p : added) { + w.tag('+').key(PathUtils.getName(p)).object().endObject(); + } + for (String p : removed) { + w.tag('-').value(PathUtils.getName(p)); + } + for (String p : changed) { + w.tag('^').key(PathUtils.getName(p)).object().endObject(); + } + cacheEntry.append(path, w.toString()); + } + private void markChanged(String path) { if (!denotesRoot(path) && !PathUtils.isAbsolute(path)) { throw new IllegalArgumentException("path: " + path); Index: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java =================================================================== --- oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (revision 1768507) +++ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (working copy) @@ -1161,8 +1161,7 @@ void applyChanges(RevisionVector before, RevisionVector after, Revision rev, String path, boolean isNew, List added, - List removed, List changed, - DiffCache.Entry cacheEntry) { + List removed, List changed) { if (isNew) { // determine the revision for the nodeChildrenCache entry when // the node is new. Fallback to after revision in case document @@ -1252,19 +1251,6 @@ } } } - - // update diff cache - JsopWriter w = new JsopStream(); - for (String p : added) { - w.tag('+').key(PathUtils.getName(p)).object().endObject(); - } - for (String p : removed) { - w.tag('-').value(PathUtils.getName(p)); - } - for (String p : changed) { - w.tag('^').key(PathUtils.getName(p)).object().endObject(); - } - cacheEntry.append(path, w.toString()); } /** Index: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java =================================================================== --- oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java (revision 1768507) +++ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java (working copy) @@ -39,6 +39,7 @@ import org.apache.jackrabbit.oak.plugins.document.DocumentNodeState; import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore; import org.apache.jackrabbit.oak.plugins.document.NodeDocument; +import org.apache.jackrabbit.oak.plugins.document.PathRev; import org.apache.jackrabbit.oak.plugins.document.TestNodeObserver; import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore; import org.apache.jackrabbit.oak.plugins.document.util.Utils; @@ -52,7 +53,6 @@ import org.apache.jackrabbit.oak.spi.state.NodeStateDiff; import org.apache.jackrabbit.oak.spi.state.NodeStateUtils; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; @@ -511,6 +511,29 @@ } @Test + public void bundledNodeAndNodeChildrenCache() throws Exception{ + NodeBuilder builder = store.getRoot().builder(); + NodeBuilder appNB = newNode("app:Asset"); + createChild(appNB, + "jcr:content", + "jcr:content/comments", //not bundled + "jcr:content/metadata", + "jcr:content/metadata/xmp", //not bundled + "jcr:content/renditions", //includes all + "jcr:content/renditions/original", + "jcr:content/renditions/original/jcr:content" + ); + builder.child("test").setChildNode("book.jpg", appNB.getNodeState()); + + merge(builder); + + Set cachedPaths = store.getNodeChildrenCache().asMap().keySet(); + for (PathRev pr : cachedPaths){ + assertFalse(pr.getPath().contains("jcr:content/renditions")); + } + } + + @Test public void recreatedBundledNode() throws Exception{ NodeBuilder builder = store.getRoot().builder(); NodeBuilder fileNode = newNode("nt:file"); @@ -617,7 +640,6 @@ assertFalse(hasNodeProperty("/test/book.jpg", concat("comments", DocumentBundlor.META_PROP_NODE))); } - @Ignore("OAK-5070") @Test public void journalDiffAndBundling() throws Exception{ NodeBuilder builder = store.getRoot().builder();