curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [20/29] git commit: Catch no node exception
Date Fri, 23 May 2014 15:07:21 GMT
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-105
Commit: c9716499642b2dd4a0d77e5df6f9b84e8dfc90d0
Parents: 8a94985
Author: Dominic Wong <dominic@hailocab.com>
Authored: Wed May 21 13:40:39 2014 +0100
Committer: Dominic Wong <dominic@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 )


Mime
View raw message