Avoid ArithmeticException: / by zero in routers, see #2443
* Route to deadletters when no routees
This commit is contained in:
parent
f6079de381
commit
fa0ec4bd01
1 changed files with 4 additions and 2 deletions
|
|
@ -518,7 +518,8 @@ trait RoundRobinLike { this: RouterConfig ⇒
|
|||
|
||||
def getNext(): ActorRef = {
|
||||
val _routees = routeeProvider.routees
|
||||
_routees((next.getAndIncrement % _routees.size).asInstanceOf[Int])
|
||||
if (_routees.isEmpty) routeeProvider.context.system.deadLetters
|
||||
else _routees((next.getAndIncrement % _routees.size).asInstanceOf[Int])
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -634,7 +635,8 @@ trait RandomLike { this: RouterConfig ⇒
|
|||
|
||||
def getNext(): ActorRef = {
|
||||
val _routees = routeeProvider.routees
|
||||
_routees(ThreadLocalRandom.current.nextInt(_routees.size))
|
||||
if (_routees.isEmpty) routeeProvider.context.system.deadLetters
|
||||
else _routees(ThreadLocalRandom.current.nextInt(_routees.size))
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue