curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cammcken...@apache.org
Subject curator git commit: CURATOR-337: Do not attempt to release a mutex unless it has actually been acquired
Date Thu, 28 Jul 2016 00:48:24 GMT
Repository: curator
Updated Branches:
  refs/heads/master ba85368e9 -> 6cebfc13c


CURATOR-337: Do not attempt to release a mutex unless it has actually been acquired


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/6cebfc13
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/6cebfc13
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/6cebfc13

Branch: refs/heads/master
Commit: 6cebfc13ccdcd9cb2a5b576fa369b957e651752a
Parents: ba85368
Author: Mark Payne <markap14@hotmail.com>
Authored: Wed Jul 27 20:23:13 2016 -0400
Committer: Mark Payne <markap14@hotmail.com>
Committed: Wed Jul 27 20:23:13 2016 -0400

----------------------------------------------------------------------
 .../recipes/leader/LeaderSelector.java          | 21 +++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/6cebfc13/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
index ec33533..c177302 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderSelector.java
@@ -419,16 +419,19 @@ public class LeaderSelector implements Closeable
         }
         finally
         {
-            hasLeadership = false;
-            try
-            {
-                mutex.release();
-            }
-            catch ( Exception e )
+            if ( hasLeadership )
             {
-                ThreadUtils.checkInterrupted(e);
-                log.error("The leader threw an exception", e);
-                // ignore errors - this is just a safety
+                hasLeadership = false;
+                try
+                {
+                    mutex.release();
+                }
+                catch ( Exception e )
+                {
+                    ThreadUtils.checkInterrupted(e);
+                    log.error("The leader threw an exception", e);
+                    // ignore errors - this is just a safety
+                }
             }
         }
     }


Mime
View raw message