jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1564523 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock: LockImpl.java LockManagerImpl.java
Date Tue, 04 Feb 2014 22:12:29 GMT
Author: jukka
Date: Tue Feb  4 22:12:29 2014
New Revision: 1564523

URL: http://svn.apache.org/r1564523
Log:
OAK-1329: Relaxed JCR locking behavior

Allow a user that owns a lock to retrieve it's token even with a session
that does not currently hold the lock

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockImpl.java?rev=1564523&r1=1564522&r2=1564523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockImpl.java
Tue Feb  4 22:12:29 2014
@@ -92,9 +92,24 @@ public final class LockImpl implements L
                 String token = node.getPath();
                 if (context.getOpenScopedLocks().contains(token)) {
                     return token;
-                } else {
+                } else if (context.getSessionScopedLocks().contains(token)) {
+                    // Prevent session-scoped locks from exposing their
+                    // tokens to the session that holds the lock. However,
+                    // another session of the lock owner will be able to
+                    // acquire the lock token and thus release the lock.
                     return null;
                 }
+
+                String owner =
+                        context.getSessionDelegate().getAuthInfo().getUserID();
+                if (owner == null) {
+                    owner = "";
+                }
+                if (owner.equals(node.getLockOwner())) {
+                    return token;
+                }
+
+                return null;
             }
         });
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java?rev=1564523&r1=1564522&r2=1564523&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/lock/LockManagerImpl.java
Tue Feb  4 22:12:29 2014
@@ -68,7 +68,7 @@ public class LockManagerImpl implements 
                 @Override
                 protected String perform(NodeDelegate node)
                         throws LockException {
-                    if (node.holdsLock(false)) {
+                    if (node.holdsLock(false)) { // TODO: check ownership?
                         String token = node.getPath();
                         sessionContext.getOpenScopedLocks().add(token);
                         return null;



Mime
View raw message