jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r803882 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
Date Thu, 13 Aug 2009 13:47:07 GMT
Author: jukka
Date: Thu Aug 13 13:47:07 2009
New Revision: 803882

URL: http://svn.apache.org/viewvc?rev=803882&view=rev
Log:
JCR-1590: JSR 283: Locking

Store lock timeout information along with the lock tokens.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=803882&r1=803881&r2=803882&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
Thu Aug 13 13:47:07 2009
@@ -213,11 +213,23 @@
     /**
      * Reapply a lock given a lock token that was read from the locks file
      *
-     * @param lockToken lock token to apply
+     * @param lockTokenLine lock token to apply
      */
-    private void reapplyLock(String lockToken) {
+    private void reapplyLock(String lockTokenLine) {
+        String[] parts = lockTokenLine.split(",");
+        String token = parts[0];
+        long timeoutHint = Long.MAX_VALUE;
+        if (parts.length > 1) {
+            try {
+                timeoutHint = Long.parseLong(parts[1]);
+            } catch (NumberFormatException e) {
+                log.warn("Unexpected timeout hint "
+                        + parts[1] + " for lock token " + token, e);
+            }
+        }
+
         try {
-            NodeId id = LockInfo.parseLockToken(lockToken);
+            NodeId id = LockInfo.parseLockToken(parts[0]);
             NodeImpl node = (NodeImpl) sysSession.getItemManager().getItem(id);
             Path path = getPath(sysSession, id);
 
@@ -225,12 +237,11 @@
                     id, false,
                     node.getProperty(NameConstants.JCR_LOCKISDEEP).getBoolean(),
                     node.getProperty(NameConstants.JCR_LOCKOWNER).getString(),
-                    Long.MAX_VALUE);
+                    timeoutHint);
             info.setLive(true);
             lockMap.put(path, info);
         } catch (RepositoryException e) {
-            log.warn("Unable to recreate lock '" + lockToken
-                    + "': " + e.getMessage());
+            log.warn("Unable to recreate lock '" + token + "': " + e.getMessage());
             log.debug("Root cause: ", e);
         }
     }
@@ -262,6 +273,13 @@
                     new OutputStreamWriter(locksFile.getOutputStream()));
             for (LockInfo info : list) {
                 writer.write(info.getLockToken());
+
+                // Store the timeout hint, if one is specified
+                if (info.getTimeoutHint() != Long.MAX_VALUE) {
+                    writer.write(',');
+                    writer.write(Long.toString(info.getTimeoutHint()));
+                }
+
                 writer.newLine();
             }
         } catch (FileSystemException fse) {



Mime
View raw message