jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r752414 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: hierarchy/HierarchyEntryImpl.java state/ItemState.java state/PropertyState.java
Date Wed, 11 Mar 2009 10:06:00 GMT
Author: angela
Date: Wed Mar 11 10:05:59 2009
New Revision: 752414

URL: http://svn.apache.org/viewvc?rev=752414&view=rev
Log:
JCR-2014 Jcr2Spi: Warning upon reloading property values

Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java?rev=752414&r1=752413&r2=752414&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
Wed Mar 11 10:05:59 2009
@@ -230,6 +230,7 @@
             } else if (mergeResult.modified()) {
                 currentState.setStatus(Status.MODIFIED);
             } // else: not modified. just leave status as it is.
+            mergeResult.dispose();
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java?rev=752414&r1=752413&r2=752414&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
Wed Mar 11 10:05:59 2009
@@ -302,7 +302,7 @@
     /**
      * Unmodifiable iterator over the listeners present on this item state.
      *
-     * @return
+     * @return iterator over <code>ItemStateLifeCycleListener</code>s.
      */
     public Iterator getListeners() {
         return Collections.unmodifiableCollection(listeners).iterator();
@@ -348,6 +348,12 @@
          * was modified.
          */
         public boolean modified();
+
+        /**
+         * Dispose this MergeResult and release all internal resources that
+         * are not needed any more.
+         */
+        public void dispose();
     }
 
     /**
@@ -368,6 +374,10 @@
         public boolean modified() {
             return modified;
         }
+
+        public void dispose() {
+            // nothing to do.
+        }
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java?rev=752414&r1=752413&r2=752414&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
Wed Mar 11 10:05:59 2009
@@ -141,11 +141,12 @@
             // reset the pInfo to point to the pInfo of another state.
             this.data = ((PropertyState) another).data;
             // if transient changes should be preserved OR if there are not
-            // transient changes, simply return diff to indicate if this state
-            // was internally changed.
+            // transient changes, return the differ and postpone the effort of
+            // calculating the diff (the test if this state got internally changed)).
             if (keepChanges || transientData == null) {
                 return result;
             } else {
+                result.dispose();
                 transientData.discardValues();
                 transientData = null;
                 modified = true;
@@ -365,8 +366,7 @@
         }
 
         private void discardValues() {
-            discarded = true;
-            if (values != null) {
+            if (!discarded && values != null) {
                 for (int i = 0; i < values.length; i++) {
                     if (values[i] != null) {
                         // make sure temporarily allocated data is discarded
@@ -374,6 +374,7 @@
                         values[i].discard();
                     }
                 }
+                discarded = true;
             }
         }
     }
@@ -382,21 +383,28 @@
      * Helper class for delayed determination of property differences.
      */
     private class PropertyDiffer implements MergeResult {
-        private final PropertyData thisData;
-        private final PropertyData thatData;
 
-        PropertyDiffer(PropertyData thisData, PropertyData thatData) {
+        private final PropertyData oldData;
+        private final PropertyData newData;
+
+        PropertyDiffer(PropertyData oldData, PropertyData newData) {
             super();
-            this.thisData = thisData;
-            this.thatData = thatData;
+            this.oldData = oldData;
+            this.newData = newData;
         }
 
         public boolean modified() {
-            if (thisData.discarded || thatData.discarded) {
-                log.warn("Property data has been discarded");
+            if (oldData.discarded || newData.discarded) {
+                // cannot calculate the diff any more -> return true.
+                String msg = " Diff cannot be calculated: " + ((oldData.discarded) ? "Old
property data" : "New property data") + " have already been discarded.";
+                log.debug(msg);
                 return true;
             }
-            return diff(thisData, thatData);
+            return diff(oldData, newData);
+        }
+
+        public void dispose() {
+            oldData.discardValues();
         }
     }
 



Mime
View raw message