Skip to content

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

Fixed NullPointerException case on malformed crawl queue folder name

luccioman4ee14ff3c590
diff --git a/source/net/yacy/cora/protocol/Domains.java b/source/net/yacy/cora/protocol/Domains.java
index 230771478..de60724e7 100644
--- a/source/net/yacy/cora/protocol/Domains.java
+++ b/source/net/yacy/cora/protocol/Domains.java
@@ -840,7 +840,7 @@ public class Domains {
* strip off any parts of an url, address string (containing host/ip:port) or raw IPs/Hosts,
* considering that the host may also be an (IPv4) IP or a IPv6 IP in brackets.
* @param target
- * @return a host name or IP string
+ * @return a domain name or IP string (without square brackets when IPV6)
*/
public static String stripToHostName(String target) {
// normalize
diff --git a/source/net/yacy/crawler/HostBalancer.java b/source/net/yacy/crawler/HostBalancer.java
index ab1179b22..6eaa377b8 100644
--- a/source/net/yacy/crawler/HostBalancer.java
+++ b/source/net/yacy/crawler/HostBalancer.java
@@ -25,6 +25,7 @@ import java.io.IOException;
import java.lang.reflect.Array;
import java.net.MalformedURLException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.HashSet;
import java.util.Iterator;
@@ -543,14 +544,16 @@ public class HostBalancer implements Balancer {
*/
@Override
public List<Request> getDomainStackReferences(String host, int maxcount, long maxtime) {
- if (host == null) return new ArrayList<Request>(0);
+ if (host == null) {
+ return Collections.emptyList();
+ }
try {
HostQueue hq = this.queues.get(DigestURL.hosthash(host, host.startsWith("ftp.") ? 21 : 80));
if (hq == null) hq = this.queues.get(DigestURL.hosthash(host, 443));
return hq == null ? new ArrayList<Request>(0) : hq.getDomainStackReferences(host, maxcount, maxtime);
- } catch (MalformedURLException e) {
+ } catch (final MalformedURLException e) {
ConcurrentLog.logException(e);
- return null;
+ return Collections.emptyList();
}
}
diff --git a/source/net/yacy/crawler/data/NoticedURL.java b/source/net/yacy/crawler/data/NoticedURL.java
index c29e9b28b..35a1b5c15 100644
--- a/source/net/yacy/crawler/data/NoticedURL.java
+++ b/source/net/yacy/crawler/data/NoticedURL.java
@@ -29,6 +29,7 @@ package net.yacy.crawler.data;
import java.io.File;
import java.io.IOException;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -271,9 +272,9 @@ public class NoticedURL {
switch (stackType) {
case LOCAL: return this.coreStack.getDomainStackReferences(host, maxcount, maxtime);
case GLOBAL: return this.limitStack.getDomainStackReferences(host, maxcount, maxtime);
- case REMOTE: return (this.remoteStack != null) ? this.remoteStack.getDomainStackReferences(host, maxcount, maxtime) : null;
+ case REMOTE: return (this.remoteStack != null) ? this.remoteStack.getDomainStackReferences(host, maxcount, maxtime) : Collections.emptyList();
case NOLOAD: return this.noloadStack.getDomainStackReferences(host, maxcount, maxtime);
- default: return null;
+ default: return Collections.emptyList();
}
}