jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r430067 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Date Wed, 09 Aug 2006 15:09:10 GMT
Author: stefan
Date: Wed Aug  9 08:09:07 2006
New Revision: 430067

URL: http://svn.apache.org/viewvc?rev=430067&view=rev
Log:
JCR-533: failing Node.lock() might leave inconsistent transient state

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/NodeImpl.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?rev=430067&r1=430066&r2=430067&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/NodeImpl.java Wed
Aug  9 08:09:07 2006
@@ -4032,12 +4032,29 @@
         synchronized (lockMgr) {
             Lock lock = lockMgr.lock(this, isDeep, isSessionScoped);
 
-            // add properties to content
-            internalSetProperty(QName.JCR_LOCKOWNER,
-                    InternalValue.create(getSession().getUserID()));
-            internalSetProperty(QName.JCR_LOCKISDEEP,
-                    InternalValue.create(isDeep));
-            save();
+            boolean succeeded = false;
+
+            try {
+                // add properties to content
+                internalSetProperty(QName.JCR_LOCKOWNER,
+                        InternalValue.create(getSession().getUserID()));
+                internalSetProperty(QName.JCR_LOCKISDEEP,
+                        InternalValue.create(isDeep));
+                save();
+                succeeded = true;
+            } finally {
+                if (!succeeded) {
+                    // failed to set lock meta-data content, cleanup
+                    try {
+                        lockMgr.unlock(this);
+                        refresh(false);
+                    } catch (RepositoryException re) {
+                        // cleanup failed
+                        log.error("error while cleaning up after failed lock attempt", re);
+                    }
+                }
+            }
+
             return lock;
         }
     }



Mime
View raw message