From 1f41d9c6f5a271e591748877b2f5d2a986e03077 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Tue, 24 Jul 2012 17:29:32 +0200 Subject: [PATCH] bugfix for a NPE --- source/net/yacy/peers/Protocol.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/net/yacy/peers/Protocol.java b/source/net/yacy/peers/Protocol.java index 41f9aa611..11d195525 100644 --- a/source/net/yacy/peers/Protocol.java +++ b/source/net/yacy/peers/Protocol.java @@ -48,6 +48,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.net.InetAddress; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.HashMap; @@ -241,7 +242,9 @@ public final class Protocol if ( p < 0 ) { return -1; } - final String host = Domains.dnsResolve(address.substring(0, p)).getHostAddress(); + String h = address.substring(0, p); + InetAddress ie = Domains.dnsResolve(h); + final String host = ie == null ? h : ie.getHostAddress(); // hack to prevent NPEs otherPeer = Seed.genRemoteSeed(seed, false, host); if ( !otherPeer.hash.equals(otherHash) ) { Network.log.logInfo("yacyClient.hello: consistency error: otherPeer.hash = "