You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2014/05/23 14:25:26 UTC
[2/5] git commit: Catch no node exception
Catch no node exception
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/c9716499
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/c9716499
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/c9716499
Branch: refs/heads/CURATOR-107
Commit: c9716499642b2dd4a0d77e5df6f9b84e8dfc90d0
Parents: 8a94985
Author: Dominic Wong <do...@hailocab.com>
Authored: Wed May 21 13:40:39 2014 +0100
Committer: Dominic Wong <do...@hailocab.com>
Committed: Wed May 21 13:40:39 2014 +0100
----------------------------------------------------------------------
.../framework/recipes/locks/LockInternals.java | 42 +++++++++++++-------
1 file changed, 27 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/c9716499/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
index 4b0d085..c66e4d1 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
@@ -295,29 +295,41 @@ public class LockInternals
synchronized(this)
{
- byte[] data = client.getData().usingWatcher(watcher).forPath(previousSequencePath);
- if ( data != null )
+ try
{
- if ( millisToWait != null )
+ byte[] data = client.getData().usingWatcher(watcher).forPath(previousSequencePath);
+ if ( data != null )
{
- millisToWait -= (System.currentTimeMillis() - startMillis);
- startMillis = System.currentTimeMillis();
- if ( millisToWait <= 0 )
+ if ( millisToWait != null )
{
- doDelete = true; // timed out - delete our node
- break;
- }
+ millisToWait -= (System.currentTimeMillis() - startMillis);
+ startMillis = System.currentTimeMillis();
+ if ( millisToWait <= 0 )
+ {
+ doDelete = true; // timed out - delete our node
+ break;
+ }
- wait(millisToWait);
- }
- else
- {
- wait();
+ wait(millisToWait);
+ }
+ else
+ {
+ wait();
+ }
}
}
+ catch ( KeeperException.NoNodeException e )
+ {
+ // ignore - clearly already deleted
+ }
+ catch ( Exception e)
+ {
+ // bubble it up
+ throw e;
+ }
}
- // else it may have been deleted (i.e. lock released). Try to acquire again
}
+ // else it may have been deleted (i.e. lock released). Try to acquire again
}
}
catch ( Exception e )