Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Rewrote filesize() to (hopefully) avoid a NPE, rewrote Blacklist class to concurrent classes to avoid a CME
Roland 'Quix0r' Haeder6d4e08ed06c5
diff --git a/source/net/yacy/kelondro/io/Records.java b/source/net/yacy/kelondro/io/Records.javaindex ad5abc60c..a22256891 100644--- a/source/net/yacy/kelondro/io/Records.java+++ b/source/net/yacy/kelondro/io/Records.java@@ -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;}/**diff --git a/source/net/yacy/repository/Blacklist.java b/source/net/yacy/repository/Blacklist.javaindex f8162b653..7e4b6b9f6 100644--- a/source/net/yacy/repository/Blacklist.java+++ b/source/net/yacy/repository/Blacklist.java@@ -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 '/' herepublic 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));}}