Description
For Java7+, try-with-resources makes using locks safer. Curator should have a utility for this. Something like:
public class SafeLock implements AutoCloseable { private final InterProcessLock lock; private final boolean acquired; public SafeLock(InterProcessLock lock, long timeout, TimeUnit unit) { this.lock = lock; acquired = lock.acquire(timeout, unit); } public void close() throws Exception { if ( acquired ) { lock.release(); } } }
Attachments
Issue Links
- links to