summaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@oath.com>2018-06-21 14:33:56 +0200
committerHåkon Hallingstad <hakon@oath.com>2018-06-21 14:33:56 +0200
commit9669d70f775f5502b7252a390824a99a59a973fe (patch)
treed37e3b16b09d68af1ca7c95382f700d76f06b7b9 /vespajlib
parent3b3920201ae893730e78fb1211f292233014d4df (diff)
Use UncheckedTimeoutException from guava
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/time/TimeBudget.java6
-rw-r--r--vespajlib/src/main/java/com/yahoo/time/TimeoutException.java18
-rw-r--r--vespajlib/src/test/java/com/yahoo/time/TimeBudgetTestCase.java3
3 files changed, 6 insertions, 21 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/time/TimeBudget.java b/vespajlib/src/main/java/com/yahoo/time/TimeBudget.java
index fe2657585bc..fa18cb5e467 100644
--- a/vespajlib/src/main/java/com/yahoo/time/TimeBudget.java
+++ b/vespajlib/src/main/java/com/yahoo/time/TimeBudget.java
@@ -1,6 +1,8 @@
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.time;
+import com.google.common.util.concurrent.UncheckedTimeoutException;
+
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
@@ -40,13 +42,13 @@ public class TimeBudget {
* Returns the time until deadline.
*
* @return time until deadline. It's toMillis() is guaranteed to be positive.
- * @throws TimeoutException if the deadline has been reached or passed.
+ * @throws UncheckedTimeoutException if the deadline has been reached or passed.
*/
public Duration timeLeftOrThrow() {
Instant now = clock.instant();
Duration left = Duration.between(now, start.plus(timeout));
if (left.toMillis() <= 0) {
- throw new TimeoutException("Time since start " + nonNegativeBetween(start, now) +
+ throw new UncheckedTimeoutException("Time since start " + nonNegativeBetween(start, now) +
" exceeds timeout " + timeout);
}
diff --git a/vespajlib/src/main/java/com/yahoo/time/TimeoutException.java b/vespajlib/src/main/java/com/yahoo/time/TimeoutException.java
deleted file mode 100644
index 098d42ddb94..00000000000
--- a/vespajlib/src/main/java/com/yahoo/time/TimeoutException.java
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.time;
-
-/**
- * Exception thrown when a blocking operation times out.
- *
- * <p>Unchecked variant of {@link java.util.concurrent.TimeoutException}
- *
- * @author hakon
- */
-@SuppressWarnings("serial")
-public class TimeoutException extends RuntimeException {
- public TimeoutException() { }
-
- public TimeoutException(String message) {
- super(message);
- }
-}
diff --git a/vespajlib/src/test/java/com/yahoo/time/TimeBudgetTestCase.java b/vespajlib/src/test/java/com/yahoo/time/TimeBudgetTestCase.java
index 7f55272c2ec..ddd57c71a0d 100644
--- a/vespajlib/src/test/java/com/yahoo/time/TimeBudgetTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/time/TimeBudgetTestCase.java
@@ -1,6 +1,7 @@
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.time;
+import com.google.common.util.concurrent.UncheckedTimeoutException;
import com.yahoo.test.ManualClock;
import org.junit.Test;
@@ -32,7 +33,7 @@ public class TimeBudgetTestCase {
try {
timeBudget.timeLeftOrThrow();
fail();
- } catch (TimeoutException e) {
+ } catch (UncheckedTimeoutException e) {
// OK
}
}