From 518b7edcbd2ccf9a05346433e1dbbaaa197c0281 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 7 Jun 2013 12:45:46 +0200 Subject: [PATCH] Handle null hostNames in DnsDiscovery (some NP have that). --- .../main/java/com/google/bitcoin/discovery/DnsDiscovery.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/java/com/google/bitcoin/discovery/DnsDiscovery.java b/core/src/main/java/com/google/bitcoin/discovery/DnsDiscovery.java index f9e33a2d..56636ad1 100644 --- a/core/src/main/java/com/google/bitcoin/discovery/DnsDiscovery.java +++ b/core/src/main/java/com/google/bitcoin/discovery/DnsDiscovery.java @@ -67,6 +67,9 @@ public class DnsDiscovery implements PeerDiscovery { } public InetSocketAddress[] getPeers(long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException { + if (hostNames == null) + throw new PeerDiscoveryException("Unable to find any peers via DNS"); + // Java doesn't have an async DNS API so we have to do all lookups in a thread pool, as sometimes seeds go // hard down and it takes ages to give up and move on. ExecutorService threadPool = Executors.newFixedThreadPool(hostNames.length);