prevent infinite loop if we don't know of any unconnected hosts

This commit is contained in:
Zlatin Balevsky
2018-07-25 19:27:59 +01:00
parent 53fde470ee
commit 074b2e51fb

View File

@@ -56,7 +56,7 @@ class ConnectionEstablisher {
if (inProgress.size() >= CONCURRENT)
return
def toTry
def toTry = null
for (int i = 0; i < 5; i++) {
toTry = hostCache.getHosts(1)
if (toTry.isEmpty())
@@ -67,7 +67,8 @@ class ConnectionEstablisher {
break
}
}
if (toTry == null)
return
inProgress.add(toTry)
executor.execute({connect(toTry)} as Runnable)
}