Review: Don't double log exception

This commit is contained in:
Christopher Batey 2018-09-20 16:37:26 +01:00
parent a7d778ad50
commit 5ad6f2c568
2 changed files with 5 additions and 4 deletions

View file

@ -685,7 +685,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit(
) {
EventFilter[ActorInitializationException](occurrences = 1).intercept {
EventFilter[TE](occurrences = 2).intercept {
EventFilter[TE](occurrences = 1).intercept {
spawn(behv)
// restarted 2 times before it gave up

View file

@ -38,8 +38,8 @@ import scala.util.control.NonFatal
}
/**
* INTERNAL API
*/
* INTERNAL API
*/
@InternalApi
private abstract class AbstractSupervisor[O, I, Thr <: Throwable](strategy: SupervisorStrategy)(implicit ev: ClassTag[Thr]) extends BehaviorInterceptor[O, I] {
@ -132,10 +132,11 @@ private class RestartSupervisor[T, Thr <: Throwable](initial: Behavior[T], strat
} catch {
case NonFatal(t: Thr)
// if unlimited restarts then don't restart if starting fails as it would likely be an infinite restart loop
log(ctx, t)
if (strategy.unlimitedRestarts() || ((restarts + 1) >= strategy.maxNrOfRetries && deadlineHasTimeLeft)) {
// don't log here as it'll be logged as ActorInitializationException
throw t
} else {
log(ctx, t)
restart(ctx, t)
aroundStart(ctx, target)
}