jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r384322 - in /incubator/jackrabbit/branches/1.0: RELEASE-NOTES.txt jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Date Wed, 08 Mar 2006 20:32:17 GMT
Author: jukka
Date: Wed Mar  8 12:32:15 2006
New Revision: 384322

URL: http://svn.apache.org/viewcvs?rev=384322&view=rev
Log:
1.0: Merged revision 383935: JCR-335 Deadlock caused by versioning operations within transaction

Modified:
    incubator/jackrabbit/branches/1.0/RELEASE-NOTES.txt
    incubator/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Modified: incubator/jackrabbit/branches/1.0/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/branches/1.0/RELEASE-NOTES.txt?rev=384322&r1=384321&r2=384322&view=diff
==============================================================================
--- incubator/jackrabbit/branches/1.0/RELEASE-NOTES.txt (original)
+++ incubator/jackrabbit/branches/1.0/RELEASE-NOTES.txt Wed Mar  8 12:32:15 2006
@@ -96,6 +96,10 @@
 Change History
 --------------
 
+Changes since 1.0-rc1:
+
+  [JCR-335] Deadlock caused by versioning operations within transaction
+
 Changes since 0.9:
 
   [JCR-334] loadURI compile error with Maven 1.0.2

Modified: incubator/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=384322&r1=384321&r2=384322&view=diff
==============================================================================
--- incubator/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ incubator/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Wed Mar  8 12:32:15 2006
@@ -424,6 +424,11 @@
         private EventStateCollection events;
 
         /**
+         * Flag indicating whether we are holding write lock.
+         */
+        private boolean holdingWriteLock;
+
+        /**
          * Create a new instance of this class.
          */
         public Update(ChangeLog local, EventStateCollectionFactory factory,
@@ -454,6 +459,7 @@
             }
 
             acquireWriteLock();
+            holdingWriteLock = true;
 
             boolean succeeded = false;
 
@@ -572,8 +578,6 @@
                 }
             }
 
-            boolean holdingWriteLock = true;
-
             try {
                 /* Let the shared item listeners know about the change */
                 shared.persisted();
@@ -601,6 +605,7 @@
                 if (holdingWriteLock) {
                     // exception occured before downgrading lock
                     rwLock.writeLock().release();
+                    holdingWriteLock = false;
                 } else {
                     rwLock.readLock().release();
                 }
@@ -612,29 +617,35 @@
          * on the item state manager will have been released.
          */
         public void cancel() {
-            local.disconnect();
+            try {
+                local.disconnect();
 
-            for (Iterator iter = shared.modifiedStates(); iter.hasNext();) {
-                ItemState state = (ItemState) iter.next();
-                try {
-                    state.copy(loadItemState(state.getId()));
-                } catch (ItemStateException e) {
-                    state.discard();
+                for (Iterator iter = shared.modifiedStates(); iter.hasNext();) {
+                    ItemState state = (ItemState) iter.next();
+                    try {
+                        state.copy(loadItemState(state.getId()));
+                    } catch (ItemStateException e) {
+                        state.discard();
+                    }
                 }
-            }
-            for (Iterator iter = shared.deletedStates(); iter.hasNext();) {
-                ItemState state = (ItemState) iter.next();
-                try {
-                    state.copy(loadItemState(state.getId()));
-                } catch (ItemStateException e) {
+                for (Iterator iter = shared.deletedStates(); iter.hasNext();) {
+                    ItemState state = (ItemState) iter.next();
+                    try {
+                        state.copy(loadItemState(state.getId()));
+                    } catch (ItemStateException e) {
+                        state.discard();
+                    }
+                }
+                for (Iterator iter = shared.addedStates(); iter.hasNext();) {
+                    ItemState state = (ItemState) iter.next();
                     state.discard();
                 }
+            } finally {
+                if (holdingWriteLock) {
+                    rwLock.writeLock().release();
+                    holdingWriteLock = false;
+                }
             }
-            for (Iterator iter = shared.addedStates(); iter.hasNext();) {
-                ItemState state = (ItemState) iter.next();
-                state.discard();
-            }
-            rwLock.writeLock().release();
         }
     }
 



Mime
View raw message