jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1360923 - in /jackrabbit/oak/trunk/oak-jcr/src: main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java
Date Thu, 12 Jul 2012 20:46:30 GMT
Author: jukka
Date: Thu Jul 12 20:46:30 2012
New Revision: 1360923

URL: http://svn.apache.org/viewvc?rev=1360923&view=rev
Log:
OAK-185: Trying to remove a missing property throws PathNotFoundException

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java?rev=1360923&r1=1360922&r2=1360923&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeDelegate.java
Thu Jul 12 20:46:30 2012
@@ -291,6 +291,10 @@ public class NodeDelegate extends ItemDe
         return new PropertyDelegate(sessionDelegate, getTree(), propertyState);
     }
 
+    public void removeProperty(String name) throws InvalidItemStateException {
+        getTree().removeProperty(name);
+    }
+
     /**
      * Set a multi valued property
      * @param name  oak name

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java?rev=1360923&r1=1360922&r2=1360923&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/NodeImpl.java
Thu Jul 12 20:46:30 2012
@@ -264,15 +264,16 @@ public class NodeImpl extends ItemImpl<N
             throws RepositoryException {
         checkStatus();
 
-        int targetType = getTargetType(value, type);
-        Value targetValue = ValueHelper.convert(value, targetType, getValueFactory());
+        String oakName = sessionDelegate.getOakPathOrThrow(jcrName);
         if (value == null) {
-            Property p = getProperty(jcrName);
-            p.remove();
-            return p;
+            dlg.removeProperty(oakName);
+            return null;
         } else {
-            String oakName = sessionDelegate.getOakPathOrThrow(jcrName);
-            CoreValue oakValue = ValueConverter.toCoreValue(targetValue, sessionDelegate);
+            int targetType = getTargetType(value, type);
+            Value targetValue =
+                    ValueHelper.convert(value, targetType, getValueFactory());
+            CoreValue oakValue =
+                    ValueConverter.toCoreValue(targetValue, sessionDelegate);
             return new PropertyImpl(dlg.setProperty(oakName, oakValue));
         }
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java?rev=1360923&r1=1360922&r2=1360923&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/CRUDTest.java
Thu Jul 12 20:46:30 2012
@@ -57,4 +57,11 @@ public class CRUDTest extends AbstractRe
         }
     }
 
+    @Test
+    public void testRemoveMissingProperty() throws RepositoryException {
+        Session session = getSession();
+        Node root = session.getRootNode();
+        root.setProperty("missing", (String) null);
+    }
+
 }



Mime
View raw message