Skip to content
Permalink
Browse files

Fixed NullPointerException case on malformed crawl queue folder name

  • Loading branch information...
luccioman committed Aug 13, 2018
1 parent 21ad943 commit 4ee14ff3c590c4cdd699d6a70b4f54144c8901fa
@@ -840,7 +840,7 @@ public static void setHostName(final InetAddress i, final String host) {
* 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.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 void remove() {
*/
@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 @@

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 int removeByHostHash(final Set<String> hosthashes) {
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();
}
}

0 comments on commit 4ee14ff

Please sign in to comment.
You can’t perform that action at this time.