Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,18 @@ public Server choose(ILoadBalancer lb, Object key) {
List<Server> upList = lb.getReachableServers();
List<Server> allList = lb.getAllServers();

int upCount = upList.size();
int serverCount = allList.size();
if (serverCount == 0) {
if (serverCount == 0 || upCount == 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check upCount isn't sufficient ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the server that is reachable is down, then the upCount is 0

/*
* No servers. End regardless of pass, because subsequent passes
* No servers or No servers available. End regardless of pass, because subsequent passes
* only get more restrictive.
*/
return null;
}

int index = chooseRandomInt(serverCount);
server = upList.get(index);
server = allList.get(index);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Server should not be selected on upList ?

int index = chooseRandomInt(upCount);
server = upList.get(index);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, server should be selected on upList, but the index should not be chosen from serverCount, it may be greater than upList.size()


if (server == null) {
/*
Expand Down