提交 2e842511 编写于 作者: A ascrutae

1. 修复unusedServerAddresses的数量小于等于1的情况,使用ThreadLocalRandom会抛出异常

上级 8f01480b
......@@ -197,8 +197,14 @@ public class DataSenderFactoryWithBalance {
private static DataSender findReadySender() {
DataSender result = null;
int index = ThreadLocalRandom.current().nextInt(0,
unusedServerAddresses.size());
int index = 0;
if (unusedServerAddresses.size() > 1){
index = ThreadLocalRandom.current().nextInt(0,
unusedServerAddresses.size());
}
for (int i = 0; i < unusedServerAddresses.size(); i++, index++) {
if (index == unusedServerAddresses.size()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册