PeerGroup: Fix IndexOutOfBoundsException if no peer fits the criteria when selecting the download peer.

This commit is contained in:
Andreas Schildbach 2019-01-31 15:38:07 +01:00
parent efaae76fa9
commit 5d6ae4082b

View file

@ -2212,6 +2212,8 @@ public class PeerGroup implements TransactionBroadcaster {
candidates2.add(peer);
}
}
if (candidates2.isEmpty())
return null;
int index = (int) (Math.random() * candidates2.size());
return candidates2.get(index);
}