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[ActorInitializationException](occurrences = 1).intercept {
EventFilter[TE](occurrences = 2).intercept { EventFilter[TE](occurrences = 1).intercept {
spawn(behv) spawn(behv)
// restarted 2 times before it gave up // restarted 2 times before it gave up

View file

@ -132,10 +132,11 @@ private class RestartSupervisor[T, Thr <: Throwable](initial: Behavior[T], strat
} catch { } catch {
case NonFatal(t: Thr) case NonFatal(t: Thr)
// if unlimited restarts then don't restart if starting fails as it would likely be an infinite restart loop // 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)) { if (strategy.unlimitedRestarts() || ((restarts + 1) >= strategy.maxNrOfRetries && deadlineHasTimeLeft)) {
// don't log here as it'll be logged as ActorInitializationException
throw t throw t
} else { } else {
log(ctx, t)
restart(ctx, t) restart(ctx, t)
aroundStart(ctx, target) aroundStart(ctx, target)
} }