Fixed NullPointerException case on malformed crawl queue folder name

pull/218/head
luccioman 6 years ago
parent 21ad9435ec
commit 4ee14ff3c5

@ -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

@ -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();
}
}

@ -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();
}
}

Loading…
Cancel
Save