mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
Rewrote filesize() to (hopefully) avoid a NPE, rewrote Blacklist class to concurrent classes to avoid a CME
This commit is contained in:
parent
901f37d608
commit
6d4e08ed06
|
@ -157,7 +157,16 @@ public final class Records {
|
|||
* @throws IOException
|
||||
*/
|
||||
private final long filesize() throws IOException {
|
||||
return raf.length() / recordsize;
|
||||
long records = 0;
|
||||
|
||||
try {
|
||||
records = raf.length() / recordsize;
|
||||
} catch (NullPointerException e) {
|
||||
// This may happen on shutdown while still something is moving on
|
||||
Log.logException(e);
|
||||
}
|
||||
|
||||
return records;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,6 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -94,8 +93,8 @@ public class Blacklist {
|
|||
public static final String BLACKLIST_TYPES_STRING = "proxy,crawler,dht,search,surftips,news";
|
||||
private File blacklistRootPath = null;
|
||||
private final ConcurrentMap<String, HandleSet> cachedUrlHashs;
|
||||
private final ConcurrentMap<String, Map<String, List<String>>> hostpaths_matchable; // key=host, value=path; mapped url is http://host/path; path does not start with '/' here
|
||||
private final ConcurrentMap<String, Map<String, List<String>>> hostpaths_notmatchable; // key=host, value=path; mapped url is http://host/path; path does not start with '/' here
|
||||
private final ConcurrentMap<String, ConcurrentMap<String, List<String>>> hostpaths_matchable; // key=host, value=path; mapped url is http://host/path; path does not start with '/' here
|
||||
private final ConcurrentMap<String, ConcurrentMap<String, List<String>>> hostpaths_notmatchable; // key=host, value=path; mapped url is http://host/path; path does not start with '/' here
|
||||
|
||||
public Blacklist(final File rootPath) {
|
||||
|
||||
|
@ -107,8 +106,8 @@ public class Blacklist {
|
|||
this.cachedUrlHashs = new ConcurrentHashMap<String, HandleSet>();
|
||||
|
||||
for (final String blacklistType : BLACKLIST_TYPES) {
|
||||
this.hostpaths_matchable.put(blacklistType, new HashMap<String, List<String>>());
|
||||
this.hostpaths_notmatchable.put(blacklistType, new HashMap<String, List<String>>());
|
||||
this.hostpaths_matchable.put(blacklistType, new ConcurrentHashMap<String, List<String>>());
|
||||
this.hostpaths_notmatchable.put(blacklistType, new ConcurrentHashMap<String, List<String>>());
|
||||
this.cachedUrlHashs.put(blacklistType, new HandleSet(URIMetadataRow.rowdef.primaryKeyLength, URIMetadataRow.rowdef.objectOrder, 0));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user