Skip to content

Commit 71ad4c5

Browse files
authored
Merge pull request scala/scala#8143 from takayahilton/awaitable-result-throws
Awaitable.result should have a throws annotation of TimeoutException and InterruptedException as well as Awaitable.ready
2 parents bcf954f + 7cd8113 commit 71ad4c5

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

library/src/scala/concurrent/Awaitable.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ trait Awaitable[+T] {
6060
* @throws TimeoutException if after waiting for the specified time this `Awaitable` is still not ready
6161
* @throws IllegalArgumentException if `atMost` is [[scala.concurrent.duration.Duration.Undefined Duration.Undefined]]
6262
*/
63-
@throws(classOf[Exception])
63+
@throws(classOf[TimeoutException])
64+
@throws(classOf[InterruptedException])
6465
def result(atMost: Duration)(implicit permit: CanAwait): T
6566
}
6667

library/src/scala/concurrent/Future.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,8 @@ object Future {
578578
throw new TimeoutException(s"Future timed out after [$atMost]")
579579
}
580580

581-
@throws(classOf[Exception])
581+
@throws(classOf[TimeoutException])
582+
@throws(classOf[InterruptedException])
582583
override def result(atMost: Duration)(implicit permit: CanAwait): Nothing = {
583584
ready(atMost)
584585
throw new TimeoutException(s"Future timed out after [$atMost]")

library/src/scala/concurrent/package.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ package concurrent {
214214
* @throws TimeoutException if after waiting for the specified time `awaitable` is still not ready
215215
* @throws IllegalArgumentException if `atMost` is [[scala.concurrent.duration.Duration.Undefined Duration.Undefined]]
216216
*/
217-
@throws(classOf[Exception])
217+
@throws(classOf[TimeoutException])
218+
@throws(classOf[InterruptedException])
218219
def result[T](awaitable: Awaitable[T], atMost: Duration): T =
219220
blocking(awaitable.result(atMost)(AwaitPermission))
220221
}

0 commit comments

Comments
 (0)