jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1404909 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Date Fri, 02 Nov 2012 10:22:54 GMT
Author: mduerig
Date: Fri Nov  2 10:22:54 2012
New Revision: 1404909

URL: http://svn.apache.org/viewvc?rev=1404909&view=rev
Log:
 OAK-418: Reduce/avoid re-resolving the underlying tree instances on every access in Item/Property/NodeDelegate

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.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=1404909&r1=1404908&r2=1404909&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
Fri Nov  2 10:22:54 2012
@@ -658,7 +658,7 @@ public class TreeImpl implements Tree, P
             String name = PathUtils.getName(relPath);
             PropertyState property = child.internalGetProperty(name);
             if (property != null) {
-                return new PropertyLocation(new NodeLocation(child), property);
+                return new PropertyLocation(new NodeLocation(child), name);
             }
             else {
                 child = child.internalGetChild(name);
@@ -691,11 +691,11 @@ public class TreeImpl implements Tree, P
 
     public class PropertyLocation implements TreeLocation {
         private final NodeLocation parent;
-        private final PropertyState property;
+        private final String name;
 
-        private PropertyLocation(NodeLocation parent, PropertyState property) {
+        private PropertyLocation(NodeLocation parent, String name) {
             this.parent = checkNotNull(parent);
-            this.property = checkNotNull(property);
+            this.name = checkNotNull(name);
         }
 
         @Override
@@ -710,7 +710,7 @@ public class TreeImpl implements Tree, P
 
         @Override
         public String getPath() {
-            return PathUtils.concat(parent.getPath(), property.getName());
+            return PathUtils.concat(parent.getPath(), name);
         }
 
         @Override
@@ -720,6 +720,7 @@ public class TreeImpl implements Tree, P
 
         @Override
         public PropertyState getProperty() {
+            PropertyState property = parent.tree.internalGetProperty(name);
             return canRead(property)
                 ? property
                 : null;
@@ -727,7 +728,7 @@ public class TreeImpl implements Tree, P
 
         @Override
         public Status getStatus() {
-            return parent.tree.getPropertyStatus(property.getName());
+            return parent.tree.getPropertyStatus(name);
         }
 
         /**
@@ -743,7 +744,7 @@ public class TreeImpl implements Tree, P
          * @return  {@code true} on success false otherwise
          */
         public boolean remove() {
-            parent.tree.removeProperty(property.getName());
+            parent.tree.removeProperty(name);
             return true;
         }
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?rev=1404909&r1=1404908&r2=1404909&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Fri Nov  2 10:22:54 2012
@@ -911,6 +911,19 @@ public class RepositoryTest extends Abst
     }
 
     @Test
+    public void setPropertyAgain() throws RepositoryException {
+        Session session = getAdminSession();
+        Property p1 = session.getProperty("/foo/stringProp");
+
+        Property p2 = p1.getParent().setProperty("stringProp", "newValue");
+        Property p3 = session.getProperty("/foo/stringProp");
+
+        assertEquals("newValue", p1.getString());
+        assertEquals("newValue", p2.getString());
+        assertEquals("newValue", p3.getString());
+    }
+
+    @Test
     public void setDoubleNaNProperty() throws RepositoryException, IOException {
         Node parentNode = getNode(TEST_PATH);
         addProperty(parentNode, "NaN", getAdminSession().getValueFactory().createValue(Double.NaN));



Mime
View raw message