Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3C867F5DA for ; Wed, 3 Apr 2013 16:15:22 +0000 (UTC) Received: (qmail 27862 invoked by uid 500); 3 Apr 2013 16:15:22 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 26562 invoked by uid 500); 3 Apr 2013 16:15:20 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 24343 invoked by uid 99); 3 Apr 2013 16:15:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Apr 2013 16:15:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Apr 2013 16:15:16 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 45580238889B; Wed, 3 Apr 2013 16:14:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1464088 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java Date: Wed, 03 Apr 2013 16:14:56 -0000 To: oak-commits@jackrabbit.apache.org From: mduerig@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130403161456.45580238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mduerig Date: Wed Apr 3 16:14:55 2013 New Revision: 1464088 URL: http://svn.apache.org/r1464088 Log: OAK-744: Invalid base node states in TreeImpl after commit/refresh/rebase recalculate a tree's base state on access instead of memoising it Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java?rev=1464088&r1=1464087&r2=1464088&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java (original) +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java Wed Apr 3 16:14:55 2013 @@ -18,9 +18,17 @@ */ package org.apache.jackrabbit.oak.core; +import static com.google.common.base.Objects.toStringHelper; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static org.apache.jackrabbit.oak.api.Type.STRING; +import static org.apache.jackrabbit.oak.commons.PathUtils.elements; + import java.util.Collections; import java.util.Iterator; import java.util.Set; + import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -44,13 +52,6 @@ import org.apache.jackrabbit.oak.spi.sta import org.apache.jackrabbit.oak.spi.state.NodeStateUtils; import org.apache.jackrabbit.oak.spi.state.PropertyBuilder; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static org.apache.jackrabbit.oak.api.Type.STRING; -import static org.apache.jackrabbit.oak.commons.PathUtils.elements; - public class TreeImpl implements Tree { /** @@ -64,11 +65,6 @@ public class TreeImpl implements Tree { private final RootImpl root; /** - * The node state this tree is based on. {@code null} if this is a newly added tree. - */ - private NodeState baseState; - - /** * The {@code NodeBuilder} for the underlying node state */ private NodeBuilder nodeBuilder; @@ -92,7 +88,6 @@ public class TreeImpl implements Tree { this.root = checkNotNull(root); this.name = ""; this.nodeBuilder = root.createRootBuilder(); - this.baseState = root.getBaseState(); this.pendingMoves = checkNotNull(pendingMoves); } @@ -102,14 +97,8 @@ public class TreeImpl implements Tree { this.name = checkNotNull(name); this.nodeBuilder = parent.getNodeBuilder().child(name); this.pendingMoves = checkNotNull(pendingMoves); - - if (parent.baseState == null) { - this.baseState = null; - } else { - this.baseState = parent.baseState.getChildNode(name); - } // readstatus is ALLOW_ALL for new items - readStatus = (baseState == null) ? ReadStatus.ALLOW_ALL : ReadStatus.getChildStatus(parent.readStatus); + readStatus = (getBaseState() == null) ? ReadStatus.ALLOW_ALL : ReadStatus.getChildStatus(parent.readStatus); } @Override @@ -164,7 +153,7 @@ public class TreeImpl implements Tree { return null; } - NodeState parentBase = nodeBuilder.getBaseState(); + NodeState parentBase = getBaseState(); PropertyState base = parentBase == null ? null : parentBase.getProperty(name); if (base == null) { @@ -429,9 +418,22 @@ public class TreeImpl implements Tree { return nodeBuilder; } + /** + * The node state this tree is based on. {@code null} if this is a newly added tree. + * @return the base node state of this tree + */ @CheckForNull - NodeState getBaseState() { - return baseState; + final NodeState getBaseState() { + if (parent == null) { + return root.getBaseState(); + } + + NodeState parentBase = parent.getBaseState(); + if (parentBase != null) { + return parentBase.getChildNode(name); + } + + return null; } @Nonnull @@ -458,7 +460,6 @@ public class TreeImpl implements Tree { void reset(NodeState state) { checkState(parent == null); nodeBuilder.reset(state); - baseState = state; } /**