add @throws annotation to actor life-cycle hooks, see #3188
This commit is contained in:
parent
c77cdeb86b
commit
d9d7d45ac2
3 changed files with 10 additions and 1 deletions
|
|
@ -476,6 +476,7 @@ trait Actor {
|
|||
* Actors are automatically started asynchronously when created.
|
||||
* Empty default implementation.
|
||||
*/
|
||||
@throws(classOf[Exception])
|
||||
def preStart() {}
|
||||
|
||||
/**
|
||||
|
|
@ -484,6 +485,7 @@ trait Actor {
|
|||
* Is called asynchronously after 'actor.stop()' is invoked.
|
||||
* Empty default implementation.
|
||||
*/
|
||||
@throws(classOf[Exception])
|
||||
def postStop() {}
|
||||
|
||||
/**
|
||||
|
|
@ -494,6 +496,7 @@ trait Actor {
|
|||
* Is called on a crashed Actor right BEFORE it is restarted to allow clean
|
||||
* up of resources before Actor is terminated.
|
||||
*/
|
||||
@throws(classOf[Exception])
|
||||
def preRestart(reason: Throwable, message: Option[Any]) {
|
||||
context.children foreach context.stop
|
||||
postStop()
|
||||
|
|
@ -505,6 +508,7 @@ trait Actor {
|
|||
* <p/>
|
||||
* Is called right AFTER restart on the newly created Actor to allow reinitialization after an Actor crash.
|
||||
*/
|
||||
@throws(classOf[Exception])
|
||||
def postRestart(reason: Throwable) { preStart() }
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ abstract class UntypedActor extends Actor {
|
|||
* Actor are automatically started asynchronously when created.
|
||||
* Empty default implementation.
|
||||
*/
|
||||
@throws(classOf[Exception])
|
||||
override def preStart(): Unit = super.preStart()
|
||||
|
||||
/**
|
||||
|
|
@ -139,6 +140,7 @@ abstract class UntypedActor extends Actor {
|
|||
* Is called asynchronously after 'actor.stop()' is invoked.
|
||||
* Empty default implementation.
|
||||
*/
|
||||
@throws(classOf[Exception])
|
||||
override def postStop(): Unit = super.postStop()
|
||||
|
||||
/**
|
||||
|
|
@ -147,6 +149,7 @@ abstract class UntypedActor extends Actor {
|
|||
* Is called on a crashed Actor right BEFORE it is restarted to allow clean
|
||||
* up of resources before Actor is terminated.
|
||||
*/
|
||||
@throws(classOf[Exception])
|
||||
override def preRestart(reason: Throwable, message: Option[Any]): Unit = super.preRestart(reason, message)
|
||||
|
||||
/**
|
||||
|
|
@ -154,6 +157,7 @@ abstract class UntypedActor extends Actor {
|
|||
* <p/>
|
||||
* Is called right AFTER restart on the newly created Actor to allow reinitialization after an Actor crash.
|
||||
*/
|
||||
@throws(classOf[Exception])
|
||||
override def postRestart(reason: Throwable): Unit = super.postRestart(reason)
|
||||
|
||||
final def receive = { case msg ⇒ onReceive(msg) }
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ public class InitializationDocSpecJava {
|
|||
// of the actor. To opt-out from stopping the children, we
|
||||
// have to override preRestart()
|
||||
@Override
|
||||
public void preRestart(Throwable reason, Option<Object> message) {
|
||||
public void preRestart(Throwable reason, Option<Object> message)
|
||||
throws Exception {
|
||||
// Keep the call to postStop(), but no stopping of children
|
||||
postStop();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue