version of AsyncLocker.release() that ignores unheld locks
Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/318bed14 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/318bed14 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/318bed14 Branch: refs/heads/CURATOR-397 Commit: 318bed14f050dd579f76a768bcc7c3125d832049 Parents: eeabe8b Author: randgalt <[email protected]> Authored: Tue Jun 27 00:10:24 2017 -0500 Committer: randgalt <[email protected]> Committed: Tue Jun 27 00:10:24 2017 -0500 ---------------------------------------------------------------------- .../org/apache/curator/x/async/AsyncLocker.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/318bed14/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncLocker.java ---------------------------------------------------------------------- diff --git a/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncLocker.java b/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncLocker.java index e04c11d..b15fd4b 100644 --- a/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncLocker.java +++ b/curator-x-async/src/main/java/org/apache/curator/x/async/AsyncLocker.java @@ -175,10 +175,28 @@ public class AsyncLocker */ public static void release(InterProcessLock lock) { + release(lock, true); + } + + /** + * Release the lock and wrap any exception in <code>RuntimeException</code> + * + * @param lock lock to release + * @param ignoreNoLockExceptions if true {@link java.lang.IllegalStateException} is ignored + */ + public static void release(InterProcessLock lock, boolean ignoreNoLockExceptions) + { try { lock.release(); } + catch ( IllegalStateException e ) + { + if ( !ignoreNoLockExceptions ) + { + throw new RuntimeException(e); + } + } catch ( Exception e ) { ThreadUtils.checkInterrupted(e);
