diff --git a/ribbon-loadbalancer/src/main/java/com/netflix/loadbalancer/RandomRule.java b/ribbon-loadbalancer/src/main/java/com/netflix/loadbalancer/RandomRule.java index 02604b69..5b9261fb 100644 --- a/ribbon-loadbalancer/src/main/java/com/netflix/loadbalancer/RandomRule.java +++ b/ribbon-loadbalancer/src/main/java/com/netflix/loadbalancer/RandomRule.java @@ -48,6 +48,7 @@ public Server choose(ILoadBalancer lb, Object key) { List upList = lb.getReachableServers(); List allList = lb.getAllServers(); + int upCount = upList.size(); int serverCount = allList.size(); if (serverCount == 0) { /* @@ -57,7 +58,7 @@ public Server choose(ILoadBalancer lb, Object key) { return null; } - int index = chooseRandomInt(serverCount); + int index = chooseRandomInt(upCount); server = upList.get(index); if (server == null) {