jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1538700 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: core/ kernel/ plugins/memory/ plugins/mongomk/ spi/state/
Date Mon, 04 Nov 2013 18:05:55 GMT
Author: jukka
Date: Mon Nov  4 18:05:55 2013
New Revision: 1538700

URL: http://svn.apache.org/r1538700
Log:
OAK-781: Clarify / fix effects of MISSING_NODE as base state of NodeBuilder

NodeBuilder.getBaseState() can no longer return null

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelRootBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoRootBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java?rev=1538700&r1=1538699&r2=1538700&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeBuilder.java
Mon Nov  4 18:05:55 2013
@@ -115,13 +115,9 @@ class SecureNodeBuilder implements NodeB
         this.builder = parent.builder.getChildNode(name);
     }
 
-    @Override @CheckForNull
+    @Override @Nonnull
     public NodeState getBaseState() {
-        NodeState base = builder.getBaseState();
-        if (base != null) { // TODO: should use a missing state instead of null
-            base = new SecureNodeState(base, getSecurityContext());
-        }
-        return base;
+        return new SecureNodeState(builder.getBaseState(), getSecurityContext());
     }
 
     @Override @Nonnull

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelRootBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelRootBuilder.java?rev=1538700&r1=1538699&r2=1538700&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelRootBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelRootBuilder.java
Mon Nov  4 18:05:55 2013
@@ -18,6 +18,8 @@ package org.apache.jackrabbit.oak.kernel
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import javax.annotation.Nonnull;
+
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
@@ -48,6 +50,7 @@ class KernelRootBuilder extends MemoryNo
      * This differs from the base state of super since the latter one reflects
      * the base created by the last purge.
      */
+    @Nonnull
     private NodeState base;
 
     /**
@@ -70,14 +73,14 @@ class KernelRootBuilder extends MemoryNo
     //--------------------------------------------------< MemoryNodeBuilder >---
 
 
-    @Override
+    @Override @Nonnull
     public NodeState getBaseState() {
         return base;
     }
 
     @Override
-    public void reset(NodeState newBase) {
-        base = newBase;
+    public void reset(@Nonnull NodeState newBase) {
+        base = checkNotNull(newBase);
         super.reset(newBase);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java?rev=1538700&r1=1538699&r2=1538700&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeBuilder.java
Mon Nov  4 18:05:55 2013
@@ -108,6 +108,7 @@ public class MemoryNodeBuilder implement
      * The base state of this builder, possibly non-existent if this builder
      * represents a new node that didn't yet exist in the base content tree.
      */
+    @Nonnull
     private NodeState base;
 
     /**
@@ -222,7 +223,7 @@ public class MemoryNodeBuilder implement
      *
      * @param newBase new base state
      */
-    public void reset(NodeState newBase) {
+    public void reset(@Nonnull NodeState newBase) {
         checkState(parent == null);
         base = checkNotNull(newBase);
         baseRevision = rootHead().setState(newBase) + 1;
@@ -242,12 +243,12 @@ public class MemoryNodeBuilder implement
 
     //--------------------------------------------------------< NodeBuilder >---
 
-    @Override
+    @Override @Nonnull
     public NodeState getNodeState() {
         return head().getImmutableNodeState();
     }
 
-    @Override
+    @Override @Nonnull
     public NodeState getBaseState() {
         return base();
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoRootBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoRootBuilder.java?rev=1538700&r1=1538699&r2=1538700&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoRootBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/mongomk/MongoRootBuilder.java
Mon Nov  4 18:05:55 2013
@@ -18,6 +18,8 @@ package org.apache.jackrabbit.oak.plugin
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import javax.annotation.Nonnull;
+
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
@@ -46,6 +48,7 @@ class MongoRootBuilder extends MongoNode
      * This differs from the base state of super since the latter one reflects
      * the base created by the last purge.
      */
+    @Nonnull
     private NodeState base;
 
     /**
@@ -68,14 +71,14 @@ class MongoRootBuilder extends MongoNode
     //--------------------------------------------------< MemoryNodeBuilder >---
 
 
-    @Override
+    @Override @Nonnull
     public NodeState getBaseState() {
         return base;
     }
 
     @Override
-    public void reset(NodeState newBase) {
-        base = newBase;
+    public void reset(@Nonnull NodeState newBase) {
+        base = checkNotNull(newBase);
         super.reset(newBase);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java?rev=1538700&r1=1538699&r2=1538700&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeBuilder.java
Mon Nov  4 18:05:55 2013
@@ -84,12 +84,13 @@ public interface NodeBuilder {
 
     /**
      * Returns the original base state that this builder is modifying.
-     * Returns {@code null} if this builder represents a new node that
+     * The return value may be non-existent (i.e. its {@code exists} method
+     * returns {@code false}) if this builder represents a new node that
      * didn't exist in the base content tree.
      *
-     * @return base node state, or {@code null}
+     * @return base node state, possibly non-existent
      */
-    @CheckForNull
+    @Nonnull
     NodeState getBaseState();
 
     /**

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java?rev=1538700&r1=1538699&r2=1538700&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/ReadOnlyBuilder.java
Mon Nov  4 18:05:55 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.oak.spi.state;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.io.IOException;
 import java.io.InputStream;
 
@@ -32,10 +34,11 @@ import org.apache.jackrabbit.oak.api.Typ
  */
 public class ReadOnlyBuilder implements NodeBuilder {
 
+    @Nonnull
     private final NodeState state;
 
-    public ReadOnlyBuilder(NodeState state) {
-        this.state = state;
+    public ReadOnlyBuilder(@Nonnull NodeState state) {
+        this.state = checkNotNull(state);
     }
 
     protected RuntimeException unsupported() {
@@ -57,12 +60,12 @@ public class ReadOnlyBuilder implements 
         return false;
     }
 
-    @Override
+    @Override @Nonnull
     public NodeState getNodeState() {
         return state;
     }
 
-    @Override
+    @Override @Nonnull
     public NodeState getBaseState() {
         return state;
     }



Mime
View raw message