diff --git a/akka-actor-tests/src/test/java/akka/dispatch/JavaFutureTests.java b/akka-actor-tests/src/test/java/akka/dispatch/JavaFutureTests.java index b03fe3b5fc..bb6b3b79a6 100644 --- a/akka-actor-tests/src/test/java/akka/dispatch/JavaFutureTests.java +++ b/akka-actor-tests/src/test/java/akka/dispatch/JavaFutureTests.java @@ -39,7 +39,7 @@ public class JavaFutureTests { } @Test - public void mustBeAbleToMapAFuture() { + public void mustBeAbleToMapAFuture() throws Exception { Future f1 = Futures.future(new Callable() { public String call() { @@ -163,7 +163,7 @@ public class JavaFutureTests { // TODO: Improve this test, perhaps with an Actor @Test - public void mustSequenceAFutureList() { + public void mustSequenceAFutureList() throws Exception{ LinkedList> listFutures = new LinkedList>(); LinkedList listExpected = new LinkedList(); @@ -183,7 +183,7 @@ public class JavaFutureTests { // TODO: Improve this test, perhaps with an Actor @Test - public void foldForJavaApiMustWork() { + public void foldForJavaApiMustWork() throws Exception{ LinkedList> listFutures = new LinkedList>(); StringBuilder expected = new StringBuilder(); @@ -206,7 +206,7 @@ public class JavaFutureTests { } @Test - public void reduceForJavaApiMustWork() { + public void reduceForJavaApiMustWork() throws Exception{ LinkedList> listFutures = new LinkedList>(); StringBuilder expected = new StringBuilder(); @@ -229,7 +229,7 @@ public class JavaFutureTests { } @Test - public void traverseForJavaApiMustWork() { + public void traverseForJavaApiMustWork() throws Exception{ LinkedList listStrings = new LinkedList(); LinkedList expectedStrings = new LinkedList(); @@ -252,7 +252,7 @@ public class JavaFutureTests { } @Test - public void findForJavaApiMustWork() { + public void findForJavaApiMustWork() throws Exception{ LinkedList> listFutures = new LinkedList>(); for (int i = 0; i < 10; i++) { final Integer fi = i; @@ -273,7 +273,7 @@ public class JavaFutureTests { } @Test - public void blockMustBeCallable() { + public void blockMustBeCallable() throws Exception { Promise p = Futures.promise(system.dispatcher()); Duration d = Duration.create(1, TimeUnit.SECONDS); p.success("foo"); @@ -282,7 +282,7 @@ public class JavaFutureTests { } @Test - public void mapToMustBeCallable() { + public void mapToMustBeCallable() throws Exception { Promise p = Futures.promise(system.dispatcher()); Future f = p.future().mapTo(manifest(String.class)); Duration d = Duration.create(1, TimeUnit.SECONDS); @@ -292,7 +292,7 @@ public class JavaFutureTests { } @Test - public void recoverToMustBeCallable() { + public void recoverToMustBeCallable() throws Exception { final IllegalStateException fail = new IllegalStateException("OHNOES"); Promise p = Futures.promise(system.dispatcher()); Future f = p.future().recover(new Recover() { @@ -309,7 +309,7 @@ public class JavaFutureTests { } @Test - public void recoverWithToMustBeCallable() { + public void recoverWithToMustBeCallable() throws Exception{ final IllegalStateException fail = new IllegalStateException("OHNOES"); Promise p = Futures.promise(system.dispatcher()); Future f = p.future().recoverWith(new Recover>() { diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index d9e179a160..80d40a5cc7 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -39,12 +39,14 @@ object Await { * Should throw [[java.util.concurrent.TimeoutException]] if times out * This method should not be called directly. */ + @throws(classOf[TimeoutException]) def ready(atMost: Duration)(implicit permit: CanAwait): this.type /** * Throws exceptions if cannot produce a T within the specified time * This method should not be called directly. */ + @throws(classOf[Exception]) def result(atMost: Duration)(implicit permit: CanAwait): T } @@ -57,6 +59,7 @@ object Await { * @throws [[java.util.concurrent.TimeoutException]] if times out * @return The returned value as returned by Awaitable.ready */ + @throws(classOf[TimeoutException]) def ready[T <: Awaitable[_]](awaitable: T, atMost: Duration): T = awaitable.ready(atMost) /** @@ -66,6 +69,7 @@ object Await { * @throws [[java.util.concurrent.TimeoutException]] if times out * @return The returned value as returned by Awaitable.result */ + @throws(classOf[Exception]) def result[T](awaitable: Awaitable[T], atMost: Duration): T = awaitable.result(atMost) } @@ -819,10 +823,12 @@ class DefaultPromise[T](implicit val executor: ExecutionContext) extends Abstrac awaitUnsafe(if (atMost.isFinite) atMost.toNanos else Long.MaxValue) } + @throws(classOf[TimeoutException]) def ready(atMost: Duration)(implicit permit: CanAwait): this.type = if (isCompleted || tryAwait(atMost)) this else throw new TimeoutException("Futures timed out after [" + atMost.toMillis + "] milliseconds") + @throws(classOf[Exception]) def result(atMost: Duration)(implicit permit: CanAwait): T = ready(atMost).value.get match { case Left(e: AskTimeoutException) ⇒ throw new AskTimeoutException(e.getMessage, e) // to get meaningful stack trace diff --git a/akka-docs/java/code/akka/docs/actor/FaultHandlingTestBase.java b/akka-docs/java/code/akka/docs/actor/FaultHandlingTestBase.java index bb8f11467c..dc2ce9bae7 100644 --- a/akka-docs/java/code/akka/docs/actor/FaultHandlingTestBase.java +++ b/akka-docs/java/code/akka/docs/actor/FaultHandlingTestBase.java @@ -150,7 +150,7 @@ public class FaultHandlingTestBase { } @Test - public void mustEmploySupervisorStrategy() { + public void mustEmploySupervisorStrategy() throws Exception { // code here //#testkit EventFilter ex1 = (EventFilter) new ErrorFilter(ArithmeticException.class); diff --git a/akka-docs/java/code/akka/docs/actor/UntypedActorDocTestBase.java b/akka-docs/java/code/akka/docs/actor/UntypedActorDocTestBase.java index 749dd1e1d9..1237797b62 100644 --- a/akka-docs/java/code/akka/docs/actor/UntypedActorDocTestBase.java +++ b/akka-docs/java/code/akka/docs/actor/UntypedActorDocTestBase.java @@ -130,7 +130,7 @@ public class UntypedActorDocTestBase { } @Test - public void usingAsk() { + public void usingAsk() throws Exception { ActorSystem system = ActorSystem.create("MySystem"); ActorRef myActor = system.actorOf(new Props(new UntypedActorFactory() { public UntypedActor create() { @@ -188,7 +188,7 @@ public class UntypedActorDocTestBase { } @Test - public void useWatch() { + public void useWatch() throws Exception { ActorSystem system = ActorSystem.create("MySystem"); ActorRef myActor = system.actorOf(new Props(WatchActor.class)); Future future = Patterns.ask(myActor, "kill", 1000); @@ -197,7 +197,7 @@ public class UntypedActorDocTestBase { } @Test - public void usePatternsGracefulStop() { + public void usePatternsGracefulStop() throws Exception { ActorSystem system = ActorSystem.create("MySystem"); ActorRef actorRef = system.actorOf(new Props(MyUntypedActor.class)); //#gracefulStop diff --git a/akka-docs/java/code/akka/docs/future/FutureDocTestBase.java b/akka-docs/java/code/akka/docs/future/FutureDocTestBase.java index e541c925c1..5a6d2e5acd 100644 --- a/akka-docs/java/code/akka/docs/future/FutureDocTestBase.java +++ b/akka-docs/java/code/akka/docs/future/FutureDocTestBase.java @@ -74,7 +74,7 @@ public class FutureDocTestBase { } @Test - public void useBlockingFromActor() { + public void useBlockingFromActor() throws Exception { ActorRef actor = system.actorOf(new Props(MyActor.class)); String msg = "hello"; //#ask-blocking @@ -86,7 +86,7 @@ public class FutureDocTestBase { } @Test - public void useFutureEval() { + public void useFutureEval() throws Exception { //#future-eval Future f = future(new Callable() { public String call() { @@ -99,7 +99,7 @@ public class FutureDocTestBase { } @Test - public void useMap() { + public void useMap() throws Exception { //#map Future f1 = future(new Callable() { public String call() { @@ -162,7 +162,7 @@ public class FutureDocTestBase { } @Test - public void useFlatMap() { + public void useFlatMap() throws Exception { //#flat-map Future f1 = future(new Callable() { public String call() { @@ -186,7 +186,7 @@ public class FutureDocTestBase { } @Test - public void useSequence() { + public void useSequence() throws Exception { List> source = new ArrayList>(); source.add(Futures.successful(1, system.dispatcher())); source.add(Futures.successful(2, system.dispatcher())); @@ -214,7 +214,7 @@ public class FutureDocTestBase { } @Test - public void useTraverse() { + public void useTraverse() throws Exception { //#traverse //Just a sequence of Strings Iterable listStrings = Arrays.asList("a", "b", "c"); @@ -236,7 +236,7 @@ public class FutureDocTestBase { } @Test - public void useFold() { + public void useFold() throws Exception { List> source = new ArrayList>(); source.add(Futures.successful("a", system.dispatcher())); source.add(Futures.successful("b", system.dispatcher())); @@ -258,7 +258,7 @@ public class FutureDocTestBase { } @Test - public void useReduce() { + public void useReduce() throws Exception { List> source = new ArrayList>(); source.add(Futures.successful("a", system.dispatcher())); source.add(Futures.successful("b", system.dispatcher())); @@ -280,7 +280,7 @@ public class FutureDocTestBase { } @Test - public void useSuccessfulAndFailed() { + public void useSuccessfulAndFailed() throws Exception { //#successful Future future = Futures.successful("Yay!", system.dispatcher()); //#successful @@ -294,7 +294,7 @@ public class FutureDocTestBase { } @Test - public void useFilter() { + public void useFilter() throws Exception { //#filter Future future1 = Futures.successful(4, system.dispatcher()); Future successfulFilter = future1.filter(new Filter() { @@ -338,7 +338,7 @@ public class FutureDocTestBase { } @Test - public void useRecover() { + public void useRecover() throws Exception { //#recover Future future = future(new Callable() { public Integer call() { @@ -358,7 +358,7 @@ public class FutureDocTestBase { } @Test - public void useTryRecover() { + public void useTryRecover() throws Exception { //#try-recover Future future = future(new Callable() { public Integer call() { @@ -382,7 +382,7 @@ public class FutureDocTestBase { } @Test - public void useOnSuccessOnFailureAndOnComplete() { + public void useOnSuccessOnFailureAndOnComplete() throws Exception { { Future future = Futures.successful("foo", system.dispatcher()); @@ -429,7 +429,7 @@ public class FutureDocTestBase { } @Test - public void useOrAndZip() { + public void useOrAndZip() throws Exception { { //#zip Future future1 = Futures.successful("foo", system.dispatcher()); diff --git a/akka-docs/java/code/akka/docs/jrouting/CustomRouterDocTestBase.java b/akka-docs/java/code/akka/docs/jrouting/CustomRouterDocTestBase.java index a20a351f06..6620c9e130 100644 --- a/akka-docs/java/code/akka/docs/jrouting/CustomRouterDocTestBase.java +++ b/akka-docs/java/code/akka/docs/jrouting/CustomRouterDocTestBase.java @@ -55,7 +55,7 @@ public class CustomRouterDocTestBase { //#crTest @Test - public void countVotesAsIntendedNotAsInFlorida() { + public void countVotesAsIntendedNotAsInFlorida() throws Exception { ActorRef routedActor = system.actorOf(new Props().withRouter(new VoteCountRouter())); routedActor.tell(DemocratVote); routedActor.tell(DemocratVote); diff --git a/akka-docs/java/code/akka/docs/jrouting/ParentActor.java b/akka-docs/java/code/akka/docs/jrouting/ParentActor.java index cf1e2b9cee..32a33b3a1b 100644 --- a/akka-docs/java/code/akka/docs/jrouting/ParentActor.java +++ b/akka-docs/java/code/akka/docs/jrouting/ParentActor.java @@ -18,7 +18,7 @@ import akka.dispatch.Await; //#parentActor public class ParentActor extends UntypedActor { - public void onReceive(Object msg) { + public void onReceive(Object msg) throws Exception { if (msg.equals("rrr")) { //#roundRobinRouter ActorRef roundRobinRouter = getContext().actorOf( diff --git a/akka-docs/java/code/akka/docs/transactor/TransactorDocTest.java b/akka-docs/java/code/akka/docs/transactor/TransactorDocTest.java index f00713a007..bb1d38651b 100644 --- a/akka-docs/java/code/akka/docs/transactor/TransactorDocTest.java +++ b/akka-docs/java/code/akka/docs/transactor/TransactorDocTest.java @@ -20,7 +20,7 @@ import static java.util.concurrent.TimeUnit.SECONDS; public class TransactorDocTest { @Test - public void coordinatedExample() { + public void coordinatedExample() throws Exception { //#coordinated-example ActorSystem system = ActorSystem.create("CoordinatedExample"); @@ -63,7 +63,7 @@ public class TransactorDocTest { } @Test - public void counterTransactor() { + public void counterTransactor() throws Exception { ActorSystem system = ActorSystem.create("CounterTransactor"); ActorRef counter = system.actorOf(new Props(Counter.class)); @@ -79,7 +79,7 @@ public class TransactorDocTest { } @Test - public void friendlyCounterTransactor() { + public void friendlyCounterTransactor() throws Exception { ActorSystem system = ActorSystem.create("FriendlyCounterTransactor"); ActorRef friend = system.actorOf(new Props(Counter.class)); ActorRef friendlyCounter = system.actorOf(new Props(FriendlyCounter.class)); diff --git a/akka-testkit/src/main/scala/akka/testkit/TestLatch.scala b/akka-testkit/src/main/scala/akka/testkit/TestLatch.scala index d57ed76877..f9e426e20e 100644 --- a/akka-testkit/src/main/scala/akka/testkit/TestLatch.scala +++ b/akka-testkit/src/main/scala/akka/testkit/TestLatch.scala @@ -30,13 +30,14 @@ class TestLatch(count: Int = 1)(implicit system: ActorSystem) extends Awaitable[ def open() = while (!isOpen) countDown() def reset() = latch = new CountDownLatch(count) + @throws(classOf[TimeoutException]) def ready(atMost: Duration)(implicit permit: CanAwait) = { val opened = latch.await(atMost.dilated.toNanos, TimeUnit.NANOSECONDS) if (!opened) throw new TimeoutException( "Timeout of %s with time factor of %s" format (atMost.toString, TestKitExtension(system).TestTimeFactor)) this } - + @throws(classOf[Exception]) def result(atMost: Duration)(implicit permit: CanAwait): Unit = { ready(atMost) } diff --git a/akka-transactor/src/test/java/akka/transactor/UntypedCoordinatedIncrementTest.java b/akka-transactor/src/test/java/akka/transactor/UntypedCoordinatedIncrementTest.java index 66d666dfd3..60a887f554 100644 --- a/akka-transactor/src/test/java/akka/transactor/UntypedCoordinatedIncrementTest.java +++ b/akka-transactor/src/test/java/akka/transactor/UntypedCoordinatedIncrementTest.java @@ -72,7 +72,7 @@ public class UntypedCoordinatedIncrementTest { } @Test - public void incrementAllCountersWithSuccessfulTransaction() { + public void incrementAllCountersWithSuccessfulTransaction() throws Exception { CountDownLatch incrementLatch = new CountDownLatch(numCounters); Increment message = new Increment(counters.subList(1, counters.size()), incrementLatch); counters.get(0).tell(new Coordinated(message, timeout)); @@ -88,7 +88,7 @@ public class UntypedCoordinatedIncrementTest { } @Test - public void incrementNoCountersWithFailingTransaction() { + public void incrementNoCountersWithFailingTransaction() throws Exception { EventFilter expectedFailureFilter = (EventFilter) new ErrorFilter(ExpectedFailureException.class); EventFilter coordinatedFilter = (EventFilter) new ErrorFilter(CoordinatedTransactionException.class); Seq ignoreExceptions = seq(expectedFailureFilter, coordinatedFilter); diff --git a/akka-transactor/src/test/java/akka/transactor/UntypedTransactorTest.java b/akka-transactor/src/test/java/akka/transactor/UntypedTransactorTest.java index 5820c82573..cadc4828b1 100644 --- a/akka-transactor/src/test/java/akka/transactor/UntypedTransactorTest.java +++ b/akka-transactor/src/test/java/akka/transactor/UntypedTransactorTest.java @@ -73,7 +73,7 @@ public class UntypedTransactorTest { } @Test - public void incrementAllCountersWithSuccessfulTransaction() { + public void incrementAllCountersWithSuccessfulTransaction() throws Exception { CountDownLatch incrementLatch = new CountDownLatch(numCounters); Increment message = new Increment(counters.subList(1, counters.size()), incrementLatch); counters.get(0).tell(message); @@ -89,7 +89,7 @@ public class UntypedTransactorTest { } @Test - public void incrementNoCountersWithFailingTransaction() { + public void incrementNoCountersWithFailingTransaction() throws Exception { EventFilter expectedFailureFilter = (EventFilter) new ErrorFilter(ExpectedFailureException.class); EventFilter coordinatedFilter = (EventFilter) new ErrorFilter(CoordinatedTransactionException.class); Seq ignoreExceptions = seq(expectedFailureFilter, coordinatedFilter);