补充提交,修复unusedServerAddresses的数量小于1的情况,防止unusedServerAddresses.size为0时,连接巡检线程异常。

This commit is contained in:
wusheng 2016-02-25 10:08:37 +08:00
parent 0f1c27e6cb
commit 60bf7631aa
2 changed files with 10 additions and 2 deletions

View File

@ -134,4 +134,12 @@
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>company-private-nexus-library-snapshots</id>
<name>company-private-nexus-library-snapshots</name>
<url>http://10.1.228.199:18081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>

View File

@ -135,7 +135,7 @@ public class DataSenderFactoryWithBalance {
}
// try to fill up senders. if size is not enough.
while (usingDataSender.size() < maxKeepConnectingSenderSize) {
while (unusedServerAddresses.size() > 0 && usingDataSender.size() < maxKeepConnectingSenderSize) {
if ((newSender = findReadySender()) == null) {
// no available sender. ignore.
break;
@ -145,7 +145,7 @@ public class DataSenderFactoryWithBalance {
}
// try to switch.
if (sleepTime >= SWITCH_SENDER_INTERVAL) {
if (sleepTime >= SWITCH_SENDER_INTERVAL && unusedServerAddresses.size() > 0) {
// if sender is enough, go to switch for balancing.
if (usingDataSender.size() >= maxKeepConnectingSenderSize) {
DataSender toBeSwitchSender;