diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-06-29 14:38:22 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-06-29 14:38:22 +0200 |
commit | f3f5cdab4931b42eafceee0402c896efc199aa2a (patch) | |
tree | 9a24b9580ba104206fe6562e2e2264accaefb1be /vespajlib | |
parent | 7fced9de852045224e7901093e1d070dba5023a8 (diff) |
Use Guava UncheckedTimeoutException instead
Diffstat (limited to 'vespajlib')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/concurrent/Locks.java | 6 | ||||
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/concurrent/TimeoutException.java | 16 |
2 files changed, 4 insertions, 18 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/concurrent/Locks.java b/vespajlib/src/main/java/com/yahoo/concurrent/Locks.java index 7700033a249..fcac7f31356 100644 --- a/vespajlib/src/main/java/com/yahoo/concurrent/Locks.java +++ b/vespajlib/src/main/java/com/yahoo/concurrent/Locks.java @@ -1,5 +1,7 @@ package com.yahoo.concurrent; +import com.google.common.util.concurrent.UncheckedTimeoutException; + import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -37,14 +39,14 @@ public class Locks<TYPE> { * * @param key the key to lock * @return the acquired lock - * @throws TimeoutException if the lock could not be acquired within the timeout + * @throws UncheckedTimeoutException if the lock could not be acquired within the timeout */ public Lock lock(TYPE key) { try { ReentrantLock lock = locks.computeIfAbsent(key, k -> new ReentrantLock(true)); boolean acquired = lock.tryLock(timeoutMs, TimeUnit.MILLISECONDS); if ( ! acquired) - throw new TimeoutException("Timed out waiting for the lock to " + key); + throw new UncheckedTimeoutException("Timed out waiting for the lock to " + key); return new Lock(lock); } catch (InterruptedException e) { throw new RuntimeException("Interrupted while waiting for lock of " + key); diff --git a/vespajlib/src/main/java/com/yahoo/concurrent/TimeoutException.java b/vespajlib/src/main/java/com/yahoo/concurrent/TimeoutException.java deleted file mode 100644 index 0b0d112fd82..00000000000 --- a/vespajlib/src/main/java/com/yahoo/concurrent/TimeoutException.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.yahoo.concurrent; - -/** - * Throws on timeout - * - * @author bratseth - */ -public class TimeoutException extends RuntimeException { - - private static final long serialVersionUID = 1245343; - - public TimeoutException(String message) { - super(message); - } - -} |