You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2010/08/04 16:47:07 UTC

svn commit: r982270 - in /jackrabbit/branches/2.0: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveVersionTest.java

Author: jukka
Date: Wed Aug  4 14:47:07 2010
New Revision: 982270

URL: http://svn.apache.org/viewvc?rev=982270&view=rev
Log:
2.0: Merged revision 982266 (JCR-2613)

Added:
    jackrabbit/branches/2.0/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveVersionTest.java
      - copied unchanged from r982266, jackrabbit/branches/2.1/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RemoveVersionTest.java
Modified:
    jackrabbit/branches/2.0/   (props changed)
    jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java

Propchange: jackrabbit/branches/2.0/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug  4 14:47:07 2010
@@ -1,6 +1,6 @@
 /jackrabbit/branches/1.5:794012,794100,794102
-/jackrabbit/branches/2.1:955314
+/jackrabbit/branches/2.1:955314,982266
 /jackrabbit/sandbox/JCR-1456:774917-886178
 /jackrabbit/sandbox/JCR-2170:812417-816332
 /jackrabbit/sandbox/tripod-JCR-2209:795441-795863
-/jackrabbit/trunk:891595,891629,892253,892263,894150-894151,896408,896513,896532,896857,896870,896876,896908,896940,896942-896943,896969,896977,897071,897836,897842,897858,897935,897983,897992-897993,897996,898002,898042,898267,898325,898540,898677,898699,898701,898715,898872,899102,899181,899391,899393-899394,899583,899594,899643,900305,900310,900314,900453,900702,900736,900762-900763,900767,900782,901095,901122,901139,901144,901170,901176,901191,901193,901196,901216,901228,901285,902058,902062,926324,928888,955307
+/jackrabbit/trunk:891595,891629,892253,892263,894150-894151,896408,896513,896532,896857,896870,896876,896908,896940,896942-896943,896969,896977,897071,897836,897842,897858,897935,897983,897992-897993,897996,898002,898042,898267,898325,898540,898677,898699,898701,898715,898872,899102,899181,899391,899393-899394,899583,899594,899643,900305,900310,900314,900453,900702,900736,900762-900763,900767,900782,901095,901122,901139,901144,901170,901176,901191,901193,901196,901216,901228,901285,902058,902062,926324,928888,936668,955307

Modified: jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java?rev=982270&r1=982269&r2=982270&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java (original)
+++ jackrabbit/branches/2.0/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java Wed Aug  4 14:47:07 2010
@@ -288,6 +288,34 @@ class InternalVersionHistoryImpl extends
      * {@inheritDoc}
      */
     public InternalVersion getVersion(NodeId id) {
+        InternalVersion v = getCachedVersion(id);
+
+        // If the version was not found, our cache may not have been
+        // synchronized with updates from another cluster node.  Reload the history
+        // to be sure we have the latest updates and try again.
+        if (v == null) {
+            try {
+                reload();
+            } catch (RepositoryException e) {
+
+                // We should add the checked exception to this method definition
+                // so we don't need to wrap it.
+                // Avoiding it for now to limit impact of this fix.
+                throw new RuntimeException(e);
+            }
+            v = getCachedVersion(id);
+        }
+
+        return v;
+    }
+
+    /**
+     * Returns the version from cache, or <code>null</code> if it is not
+     * present.
+     * @param id the id of the version
+     * @return the version or <code>null</code> if not cached.
+     */
+    private synchronized InternalVersion getCachedVersion(NodeId id) {
         InternalVersion v = versionCache.get(id);
         if (v == null) {
             for (Name versionName : nameCache.keySet()) {
@@ -413,6 +441,8 @@ class InternalVersionHistoryImpl extends
                 parentNode.removeNode(node.getName());
                 // store changes for this node and his children
                 parentNode.store();
+            } else {
+                node.store();
             }
         } else {
             log.debug("Current version history has at least one reference");
@@ -435,7 +465,7 @@ class InternalVersionHistoryImpl extends
      * or <code>null</code> of the label was not moved.
      *
      * @param versionName the name of the version
-     * @param label the label to assgign
+     * @param label the label to assign
      * @param move  flag what to do by collisions
      * @return the version that was previously assigned by this label or <code>null</code>.
      * @throws VersionException if the version does not exist or if the label is already defined.