You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by tr...@apache.org on 2011/04/06 03:00:40 UTC

svn commit: r1089287 - in /jackrabbit/branches/2.2: ./ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ jackrabbit-spi2dav/src/main/java/org/apache/jackrabbi...

Author: tripod
Date: Wed Apr  6 01:00:40 2011
New Revision: 1089287

URL: http://svn.apache.org/viewvc?rev=1089287&view=rev
Log:
JCR-2880 Save fails after setting a binary property twice

Modified:
    jackrabbit/branches/2.2/   (props changed)
    jackrabbit/branches/2.2/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java
    jackrabbit/branches/2.2/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
    jackrabbit/branches/2.2/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java

Propchange: jackrabbit/branches/2.2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Apr  6 01:00:40 2011
@@ -2,4 +2,4 @@
 /jackrabbit/sandbox/JCR-1456:774917-886178
 /jackrabbit/sandbox/JCR-2170:812417-816332
 /jackrabbit/sandbox/tripod-JCR-2209:795441-795863
-/jackrabbit/trunk:1038201,1038203,1038205,1038657,1039064,1039347,1039408,1039422-1039423,1039888,1039946,1040033,1040090,1040459,1040601,1040606,1040661,1040958,1041379,1041439,1041761,1042643,1042647,1042978-1042982,1043084-1043086,1043088,1043343,1043357-1043358,1043430,1043554,1043616,1043618,1043637,1043656,1043893,1043897,1044239,1044312,1044451,1044613,1049473,1049491,1049514,1049518,1049520,1049859,1049870,1049874,1049878,1049880,1049883,1049889,1049891,1049894-1049895,1049899-1049901,1049909-1049911,1049915-1049916,1049919,1049923,1049925,1049931,1049936,1049939,1050212,1050298,1050346,1050551,1055068,1055070-1055071,1055116-1055117,1055127,1055134,1055164,1055498,1060431,1060434,1060753,1063756,1065599,1065622,1066059,1066071,1069831,1071562,1071573,1071680,1074140,1079314,1079317
+/jackrabbit/trunk:1038201,1038203,1038205,1038657,1039064,1039347,1039408,1039422-1039423,1039888,1039946,1040033,1040090,1040459,1040601,1040606,1040661,1040958,1041379,1041439,1041761,1042643,1042647,1042978-1042982,1043084-1043086,1043088,1043343,1043357-1043358,1043430,1043554,1043616,1043618,1043637,1043656,1043893,1043897,1044239,1044312,1044451,1044613,1049473,1049491,1049514,1049518,1049520,1049859,1049870,1049874,1049878,1049880,1049883,1049889,1049891,1049894-1049895,1049899-1049901,1049909-1049911,1049915-1049916,1049919,1049923,1049925,1049931,1049936,1049939,1050212,1050298,1050346,1050551,1055068,1055070-1055071,1055116-1055117,1055127,1055134,1055164,1055498,1060431,1060434,1060753,1063756,1065599,1065622,1066059,1066071,1069831,1071562,1071573,1071680,1074140,1079314,1079317,1089032

Modified: jackrabbit/branches/2.2/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java?rev=1089287&r1=1089286&r2=1089287&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java Wed Apr  6 01:00:40 2011
@@ -42,6 +42,8 @@ public class SetPropertyValue extends Ab
     private final QValue[] values;
     private final int valueType;
 
+    private final QValue[] oldValues;
+
     private SetPropertyValue(PropertyState propertyState, int valueType, QValue[] values)
             throws RepositoryException {
         this.propertyState = propertyState;
@@ -50,6 +52,9 @@ public class SetPropertyValue extends Ab
         this.valueType = valueType;
         this.values = values;
 
+        // remember original values
+        oldValues = propertyState.getValues();
+
         addAffectedItemState(propertyState);
     }
 
@@ -70,7 +75,14 @@ public class SetPropertyValue extends Ab
     public void persisted() throws RepositoryException {
         assert status == STATUS_PENDING;
         status = STATUS_PERSISTED;
-        propertyState.getHierarchyEntry().complete(this);
+        try {
+            propertyState.getHierarchyEntry().complete(this);
+        } finally {
+            // dispose the original values
+            for (QValue v : oldValues) {
+                v.discard();
+            }
+        }
     }
 
     /**
@@ -81,6 +93,9 @@ public class SetPropertyValue extends Ab
         assert status == STATUS_PENDING;
         status = STATUS_UNDO;
         propertyState.getHierarchyEntry().complete(this);
+
+        // NOTE: new values don't need to be disposed as the transient change
+        //       has been reverted with implicit value disposal.
     }
 
     //----------------------------------------< Access Operation Parameters >---

Modified: jackrabbit/branches/2.2/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java?rev=1089287&r1=1089286&r2=1089287&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java Wed Apr  6 01:00:40 2011
@@ -206,6 +206,7 @@ public class PropertyState extends ItemS
      * this <code>PropertyState</code>.
      *
      * @return definition of this state
+     * @throws RepositoryException If an error occurs.
      */
     public QPropertyDefinition getDefinition() throws RepositoryException {
         if (definition == null) {
@@ -237,7 +238,7 @@ public class PropertyState extends ItemS
     /**
      * Convenience method for single valued property states.
      *
-     * @return
+     * @return the value of a single valued property.
      * @throws ValueFormatException if {@link #isMultiValued()} returns true.
      */
     public QValue getValue() throws ValueFormatException {
@@ -256,6 +257,8 @@ public class PropertyState extends ItemS
      * Sets the value(s) of this property.
      *
      * @param values the new values
+     * @param type the value type
+     * @throws RepositoryException If an error occurs.
      */
     void setValues(QValue[] values, int type) throws RepositoryException {
         if (getStatus() == Status.NEW) {
@@ -363,8 +366,8 @@ public class PropertyState extends ItemS
             // make sure the arguments are consistent and do not violate the
             // given property definition.
             validate(values, type, definition);
-            // free old values if existing
-            discardValues();
+            // note: discarding original values is deferred to operation completion
+            // -> see JCR-2880
 
             this.type = type;
             this.values = (values == null) ? QValue.EMPTY_ARRAY : values;

Modified: jackrabbit/branches/2.2/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.2/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java?rev=1089287&r1=1089286&r2=1089287&view=diff
==============================================================================
--- jackrabbit/branches/2.2/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java (original)
+++ jackrabbit/branches/2.2/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java Wed Apr  6 01:00:40 2011
@@ -564,7 +564,7 @@ public class RepositoryServiceImpl exten
         public void setValue(PropertyId propertyId, QValue value) throws RepositoryException {
             assertMethod();
             Path p = getPath(propertyId, sessionInfo);
-            setProperty(p, value, false);
+            setProperty(p, value, true);
         }
 
         /**
@@ -573,7 +573,7 @@ public class RepositoryServiceImpl exten
         public void setValue(PropertyId propertyId, QValue[] values) throws RepositoryException {
             assertMethod();
             Path p = getPath(propertyId, sessionInfo);
-            setProperty(p, values, false);
+            setProperty(p, values, true);
         }
 
         /**