Skip to content

Commit

Permalink
Catch PeerDiscoveryException during getPeers call. avoids stack trace…
Browse files Browse the repository at this point in the history
… when all DNS lookups timeout
  • Loading branch information
oscarguindzberg committed Feb 12, 2019
1 parent 011fe40 commit 834f57a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/src/main/java/org/bitcoinj/core/PeerGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -1049,8 +1049,14 @@ protected int discoverPeers() throws PeerDiscoveryException {
final List<PeerAddress> addressList = Lists.newLinkedList();
for (PeerDiscovery peerDiscovery : peerDiscoverers /* COW */) {
InetSocketAddress[] addresses;
addresses = peerDiscovery.getPeers(requiredServices, peerDiscoveryTimeoutMillis, TimeUnit.MILLISECONDS);
for (InetSocketAddress address : addresses) addressList.add(new PeerAddress(params, address));
try {
addresses = peerDiscovery.getPeers(requiredServices, peerDiscoveryTimeoutMillis, TimeUnit.MILLISECONDS);
}catch(PeerDiscoveryException e) {
log.warn(e.getMessage());
continue;
}

for (InetSocketAddress address : addresses) addressList.add(new PeerAddress(address));
if (addressList.size() >= maxPeersToDiscoverCount) break;
}
if (!addressList.isEmpty()) {
Expand Down

0 comments on commit 834f57a

Please sign in to comment.