[
https://issues.apache.org/jira/browse/CURATOR-259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15900292#comment-15900292
]
ASF GitHub Bot commented on CURATOR-259:
----------------------------------------
Github user cammckenzie commented on the issue:
https://github.com/apache/curator/pull/103
Curator 2.x only supports Java 1.6 so can't support the auto close features
in Java 1.7
Curator 3.x supports Java 1.7. The Locker class is present in this version.
cheers
On Wed, Mar 8, 2017 at 4:20 AM, Paul Vorbach <[email protected]>
wrote:
> This class is no longer available. Is this correct?
>
> It is still mentioned on http://curator.apache.org/utilities.html, which
> is why I found this PR.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/apache/curator/pull/103#issuecomment-284792965>, or
mute
> the thread
>
<https://github.com/notifications/unsubscribe-auth/AHZ0sd0PMT71pLepftwyaVl-Gghrgbjeks5rjZH1gaJpZM4F4pym>
> .
>
> Add try-with-resources class for Curator locks
> ----------------------------------------------
>
> Key: CURATOR-259
> URL: https://issues.apache.org/jira/browse/CURATOR-259
> Project: Apache Curator
> Issue Type: New Feature
> Components: Recipes
> Reporter: Jordan Zimmerman
> Assignee: Jordan Zimmerman
> Priority: Minor
> Fix For: 3.0.0
>
>
> For Java7+, try-with-resources makes using locks safer. Curator should have a
> utility for this. Something like:
> {code}
> 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();
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)