From 87396a8b3a2464b7e5b334f9592bf2100830846c Mon Sep 17 00:00:00 2001 From: Heiko Seeberger Date: Thu, 11 May 2017 10:40:38 +0200 Subject: [PATCH] Avoid overflow of index --- src/main/scala/blog/typed/scaladsl/ImmutableRoundRobin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/blog/typed/scaladsl/ImmutableRoundRobin.scala b/src/main/scala/blog/typed/scaladsl/ImmutableRoundRobin.scala index fe1f73c..48a343a 100644 --- a/src/main/scala/blog/typed/scaladsl/ImmutableRoundRobin.scala +++ b/src/main/scala/blog/typed/scaladsl/ImmutableRoundRobin.scala @@ -19,7 +19,7 @@ object ImmutableRoundRobin { private def activeRoutingBehavior[T](index: Long, workers: Vector[ActorRef[T]]): Behavior[T] = Actor.immutable[T] { (ctx, msg) => - workers((index % workers.size).toInt) ! msg + workers(abs(index % workers.size).toInt) ! msg activeRoutingBehavior(index + 1, workers) } }