PeerGroup.triggerConnectionsJob: Fix NullPointerException if inactives contains only IPv6 addresses.

This commit is contained in:
Matthew Leon 2019-03-26 21:51:48 -04:00 committed by Andreas Schildbach
parent 9125c1f94a
commit 57de578707

View file

@ -490,11 +490,16 @@ public class PeerGroup implements TransactionBroadcaster {
do {
addrToTry = inactives.poll();
} while (ipv6Unreachable && addrToTry.getAddr() instanceof Inet6Address);
if (addrToTry == null) {
// We have exhausted the queue of reachable peers, so just settle down.
// Most likely we were given a fixed set of addresses in some test scenario.
return;
}
long retryTime = backoffMap.get(addrToTry).getRetryTime();
retryTime = Math.max(retryTime, groupBackoff.getRetryTime());
if (retryTime > now) {
long delay = retryTime - now;
log.info("Waiting {} ms before next connect attempt {}", delay, addrToTry == null ? "" : "to " + addrToTry);
log.info("Waiting {} ms before next connect attempt to {}", delay, addrToTry);
inactives.add(addrToTry);
executor.schedule(this, delay, TimeUnit.MILLISECONDS);
return;