Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

bugfix for a NPE

Michael Peter Christen1f41d9c6f5a2
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 = "