Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- changed default browser from netscape to firefox - fixed "Inefficient use of keySet iterator instead of entrySet iterator" [WMI_WRONG_MAP_ITERATOR, FindBugs] - fixed some possible null pointer accesses
danielr753a1ae43056
diff --git a/defaults/yacy.init b/defaults/yacy.initindex 0731e86aa..4a28d0362 100644--- a/defaults/yacy.init+++ b/defaults/yacy.init@@ -452,7 +452,7 @@ staticIP=# the browser type is optional and works only under certain conditionsbrowserPopUpTrigger=truebrowserPopUpPage=ConfigBasic.html-browserPopUpApplication=netscape+browserPopUpApplication=firefox# defines if the YaCy icon appears in the system tray on supported platformstrayIcon=truediff --git a/htroot/BlacklistCleaner_p.java b/htroot/BlacklistCleaner_p.javaindex d8aced78d..7af740b6e 100644--- a/htroot/BlacklistCleaner_p.java+++ b/htroot/BlacklistCleaner_p.java@@ -39,6 +39,7 @@ import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.Map;+import java.util.Map.Entry;import java.util.regex.Pattern;import java.util.regex.PatternSyntaxException;@@ -114,12 +115,11 @@ public class BlacklistCleaner_p {prop.put(RESULTS + "disabled", (ies.size() == 0) ? "1" : "0");if (ies.size() > 0) {prop.put(RESULTS + DISABLED + "entries", ies.size());- final Iterator<String> it = ies.keySet().iterator();int i = 0;String s;- while (it.hasNext()) {- s = it.next();- prop.put(RESULTS + DISABLED + ENTRIES + i + "_error", ies.get(s).longValue());+ for (Entry<String, Integer> entry: ies.entrySet()) {+ s = entry.getKey();+ prop.put(RESULTS + DISABLED + ENTRIES + i + "_error", entry.getValue().longValue());prop.putHTML(RESULTS + DISABLED + ENTRIES + i + "_entry", s);i++;}diff --git a/htroot/IndexShare_p.java b/htroot/IndexShare_p.javaindex a5851e9a7..f5aab120c 100644--- a/htroot/IndexShare_p.java+++ b/htroot/IndexShare_p.java@@ -39,9 +39,18 @@ public class IndexShare_p {public static serverObjects respond(final httpHeader header, final serverObjects post, final serverSwitch<?> env) {// return variable that accumulates replacementsfinal plasmaSwitchboard switchboard = (plasmaSwitchboard) env;- final serverObjects prop = new serverObjects();+ final serverObjects prop = new serverObjects();- if ((post == null) || (env == null)) {+ if(switchboard == null) {+ prop.put("linkfreq", "30");+ prop.put("wordfreq", "10");+ prop.put("dtable", "");+ prop.put("rtable", "");+ prop.putNum("wcount", 0);+ prop.putNum("ucount", 0);+ return prop; // be save+ }+ if (post == null) {prop.put("linkfreq", switchboard.getConfig("defaultLinkReceiveFrequency","30"));prop.put("wordfreq", switchboard.getConfig("defaultWordReceiveFrequency","10"));prop.put("dtable", "");diff --git a/htroot/News.java b/htroot/News.javaindex cad27b034..ac73fe3ea 100644--- a/htroot/News.java+++ b/htroot/News.java@@ -27,6 +27,7 @@import java.io.IOException;import java.util.Iterator;import java.util.Map;+import java.util.Map.Entry;import de.anomic.http.HttpClient;import de.anomic.http.httpHeader;@@ -125,12 +126,9 @@ public class News {prop.putHTML("table_list_" + i + "_att", attributeMap.toString());int j = 0;if (attributeMap.size() > 0) {- final Iterator<String> attributeKeys = attributeMap.keySet().iterator();- while (attributeKeys.hasNext()) {- final String key = attributeKeys.next();- final String value = attributeMap.get(key);- prop.put("table_list_" + i + "_attributes_" + j + "_name",key);- prop.putHTML("table_list_" + i + "_attributes_" + j + "_value",value);+ for (Entry<String, String> attribute: attributeMap.entrySet()) {+ prop.put("table_list_" + i + "_attributes_" + j + "_name", attribute.getKey());+ prop.putHTML("table_list_" + i + "_attributes_" + j + "_value", attribute.getValue());j++;}}diff --git a/htroot/Ranking_p.java b/htroot/Ranking_p.javaindex feddb7a07..3b271fe5e 100644--- a/htroot/Ranking_p.java+++ b/htroot/Ranking_p.java@@ -26,8 +26,8 @@// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USAimport java.util.HashMap;-import java.util.Iterator;import java.util.Map;+import java.util.Map.Entry;import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaSearchEvent;@@ -104,11 +104,10 @@ public class Ranking_p {private static void putRanking(final serverObjects prop, final Map<String, String> map, final String prefix, final String attrExtension) {prop.put("attr" + attrExtension, map.size());- final Iterator<String> it = map.keySet().iterator();String key;int i, j = 0;- while (it.hasNext()) {- key = it.next();+ for (final Entry<String, String> entry: map.entrySet()) {+ key = entry.getKey();prop.put("attr" + attrExtension + "_" + j + "_name", rankingParameters.get(key.substring(prefix.length())));prop.put("attr" + attrExtension + "_" + j + "_nameorg", key);prop.put("attr" + attrExtension + "_" + j + "_select", maxRankingRange);@@ -117,7 +116,7 @@ public class Ranking_p {prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_value", i);try {prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_checked",- (i == Integer.valueOf(map.get(key)).intValue()) ? "1" : "0");+ (i == Integer.valueOf(entry.getValue()).intValue()) ? "1" : "0");} catch (final NumberFormatException e) {prop.put("attr" + attrExtension + "_" + j + "_select_" + i + "_checked", "0");}@@ -135,10 +134,12 @@ public class Ranking_p {plasmaSearchEvent.cleanupEvents(true);// case if no values are requested- if ((post == null) || (env == null)) {+ if ((post == null) || (sb == null)) {// we create empty entries for template stringsfinal serverObjects prop = defaultValues();- final plasmaSearchRankingProfile ranking = sb.getRanking();+ final plasmaSearchRankingProfile ranking;+ if(sb == null) ranking = new plasmaSearchRankingProfile(plasmaSearchQuery.CONTENTDOM_TEXT);+ else ranking = sb.getRanking();putRanking(prop, ranking, "local");return prop;}diff --git a/htroot/Threaddump_p.java b/htroot/Threaddump_p.javaindex 80dd1e8e4..26bec3b17 100644--- a/htroot/Threaddump_p.java+++ b/htroot/Threaddump_p.java@@ -33,6 +33,7 @@ import java.io.File;import java.io.IOException;import java.util.Date;import java.util.Map;+import java.util.Map.Entry;import de.anomic.data.htmlTools;import de.anomic.http.httpHeader;@@ -95,8 +96,10 @@ public class Threaddump_p {final File classPath = new File(rootPath, "source");- for (final Thread thread: stackTraces.keySet()) {- final StackTraceElement[] stackTraceElements = stackTraces.get(thread);+ Thread thread;+ for (final Entry<Thread, StackTraceElement[]> entry: stackTraces.entrySet()) {+ thread = entry.getKey();+ final StackTraceElement[] stackTraceElements = entry.getValue();StackTraceElement ste;String line;String tracename = "";diff --git a/htroot/yacy/hello.java b/htroot/yacy/hello.javaindex cb3a5214c..518425795 100644--- a/htroot/yacy/hello.java+++ b/htroot/yacy/hello.java@@ -178,7 +178,7 @@ public final class hello {serverCore.checkInterruption();final StringBuffer seeds = new StringBuffer(768);// attach some more seeds, as requested- if ((sb.webIndex.seedDB != null) && (sb.webIndex.seedDB.sizeConnected() > 0)) {+ if (sb.webIndex.seedDB.sizeConnected() > 0) {if (count > sb.webIndex.seedDB.sizeConnected()) { count = sb.webIndex.seedDB.sizeConnected(); }if (count > 100) { count = 100; }diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.javaindex 705920be0..5850e320d 100644--- a/source/de/anomic/data/bookmarksDB.java+++ b/source/de/anomic/data/bookmarksDB.java@@ -48,6 +48,7 @@ import java.util.Iterator;import java.util.Map;import java.util.Set;import java.util.TreeSet;+import java.util.Map.Entry;import java.util.regex.Pattern;import javax.xml.parsers.DocumentBuilder;@@ -772,10 +773,9 @@ public class bookmarksDB {writer.close();links = scraper.getAnchors();} catch (final IOException e) { serverLog.logWarning("BOOKMARKS", "error during load of links: "+ e.getClass() +" "+ e.getMessage());}- final Iterator<yacyURL> it = links.keySet().iterator();- while (it.hasNext()) {- url= it.next();- title=links.get(url);+ for (Entry<yacyURL, String> link: links.entrySet()) {+ url= link.getKey();+ title=link.getValue();serverLog.logInfo("BOOKMARKS", "links.get(url)");if(title.equals("")){//cannot be displayedtitle=url.toString();diff --git a/source/de/anomic/data/userDB.java b/source/de/anomic/data/userDB.javaindex f49809376..8724aab75 100644--- a/source/de/anomic/data/userDB.java+++ b/source/de/anomic/data/userDB.java@@ -432,13 +432,12 @@ public final class userDB {if (timeStamp < 0) throw new IllegalArgumentException();final Long lastAccess = this.getLastAccess();- long oldTimeUsed = getTimeUsed();- long newTimeUsed = oldTimeUsed;+ long newTimeUsed = getTimeUsed();if (incrementTimeUsed) {if ((lastAccess == null)||((lastAccess != null)&&(timeStamp-lastAccess.longValue()>=1000*60))) { //1 minute//this.mem.put(TIME_USED,Long.toString(newTimeUsed = ++oldTimeUsed));- newTimeUsed = ++oldTimeUsed;+ newTimeUsed++;if(lastAccess != null){this.oldDate.setTime(new Date(lastAccess.longValue()));this.newDate.setTime(new Date(System.currentTimeMillis()));diff --git a/source/de/anomic/http/httpHeader.java b/source/de/anomic/http/httpHeader.javaindex e65507441..47b2ee9b0 100644--- a/source/de/anomic/http/httpHeader.java+++ b/source/de/anomic/http/httpHeader.java@@ -343,12 +343,8 @@ public final class httpHeader extends TreeMap<String, String> implements Map<StrFileOutputStream fos = null;try {fos = new FileOutputStream(f);- final Iterator<String> i = keySet().iterator();- String key, value;- while (i.hasNext()) {- key = i.next();- value = get(key);- fos.write((key + "=" + value + "\r\n").getBytes());+ for (java.util.Map.Entry<String, String> entry: entrySet()) {+ fos.write((entry.getKey() + "=" + entry.getValue() + "\r\n").getBytes());}fos.flush();} finally {diff --git a/source/de/anomic/index/indexDefaultReferenceBlacklist.java b/source/de/anomic/index/indexDefaultReferenceBlacklist.javaindex bad842090..5bc15bae5 100644--- a/source/de/anomic/index/indexDefaultReferenceBlacklist.java+++ b/source/de/anomic/index/indexDefaultReferenceBlacklist.java@@ -29,6 +29,7 @@ package de.anomic.index;import java.io.File;import java.util.ArrayList;import java.util.HashMap;+import java.util.Map.Entry;import java.util.regex.Pattern;import java.util.regex.PatternSyntaxException;@@ -99,11 +100,12 @@ public class indexDefaultReferenceBlacklist extends indexAbstractReferenceBlackl// loop over all Regexentrysif(!matched) {final HashMap<String, ArrayList<String>> blacklistMapNotMatched = super.getBlacklistMap(blacklistType,false);- for(final String key: blacklistMapNotMatched.keySet()) {+ String key;+ for(final Entry<String, ArrayList<String>> entry: blacklistMapNotMatched.entrySet()) {+ key = entry.getKey();try {-if(Pattern.matches(key, hostlow)) {- app = blacklistMapNotMatched.get(key);+ app = entry.getValue();for (int i=0; i<app.size(); i++) {if(Pattern.matches(app.get(i), path))return true;diff --git a/source/de/anomic/kelondro/kelondroMSetTools.java b/source/de/anomic/kelondro/kelondroMSetTools.javaindex b5478d982..234cfde23 100644--- a/source/de/anomic/kelondro/kelondroMSetTools.java+++ b/source/de/anomic/kelondro/kelondroMSetTools.java@@ -34,6 +34,7 @@ import java.util.Map;import java.util.Set;import java.util.TreeMap;import java.util.TreeSet;+import java.util.Map.Entry;public class kelondroMSetTools {@@ -300,12 +301,11 @@ public class kelondroMSetTools {}private static <A, B> TreeMap<A, B> excludeConstructiveByTestMapInSet(final TreeMap<A, B> map, final TreeSet<A> set) {- final Iterator<A> mi = map.keySet().iterator();final TreeMap<A, B> result = new TreeMap<A, B>(map.comparator());A o;- while (mi.hasNext()) {- o = mi.next();- if (!(set.contains(o))) result.put(o, map.get(o));+ for (Entry<A, B> entry: map.entrySet()) {+ o = entry.getKey();+ if (!(set.contains(o))) result.put(o, entry.getValue());}return result;}diff --git a/source/de/anomic/plasma/plasmaParser.java b/source/de/anomic/plasma/plasmaParser.javaindex 1775967c5..b3212e0f6 100644--- a/source/de/anomic/plasma/plasmaParser.java+++ b/source/de/anomic/plasma/plasmaParser.java@@ -48,6 +48,7 @@ import java.util.List;import java.util.Map;import java.util.Properties;import java.util.Set;+import java.util.Map.Entry;import java.util.regex.Matcher;import java.util.regex.Pattern;@@ -946,10 +947,9 @@ public final class plasmaParser {// found linksint anchorNr = 0;final Map<yacyURL, String> anchors = document.getAnchors();- final Iterator<yacyURL> anchorIter = anchors.keySet().iterator();- while (anchorIter.hasNext()) {- final yacyURL key = anchorIter.next();- System.out.println("URL " + anchorNr + ":\t" + key.toString() + " | " + anchors.get(key));+ for (Entry<yacyURL, String> anchor: anchors.entrySet()) {+ final yacyURL key = anchor.getKey();+ System.out.println("URL " + anchorNr + ":\t" + key.toString() + " | " + anchor.getValue());anchorNr++;}document.close();diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex 6a2f8716d..832069b46 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -723,8 +723,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// clean search events which have cached relations to the old indexplasmaSearchEvent.cleanupEvents(true);// switch the networks- synchronized (this.webIndex) {- this.webIndex.close();+ synchronized (this) {+ synchronized (this.webIndex) {+ this.webIndex.close();+ }setConfig("network.unit.definition", networkDefinition);overwriteNetworkDefinition(this);final File indexPrimaryPath = getConfigPath(plasmaSwitchboardConstants.INDEX_PRIMARY_PATH, plasmaSwitchboardConstants.INDEX_PATH_DEFAULT);@@ -1685,7 +1687,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.if (System.currentTimeMillis() - lastPPMUpdate > 30000) {// we don't want to do this too oftenupdateMySeed();- serverProfiling.update("ppm", new Long(currentPPM()));+ serverProfiling.update("ppm", Long.valueOf(currentPPM()));lastPPMUpdate = System.currentTimeMillis();}serverProfiling.update("indexed", queueEntry.url().toNormalform(true, false));@@ -1870,7 +1872,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.final long timeInterval = 1000 * 60 * 60;final TreeSet<Long> accessSet = tracker.get(host);if (accessSet == null) return 0;- return accessSet.tailSet(new Long(System.currentTimeMillis() - timeInterval)).size();+ return accessSet.tailSet(Long.valueOf(System.currentTimeMillis() - timeInterval)).size();}public void startTransferWholeIndex(final yacySeed seed, final boolean delete) {@@ -2197,7 +2199,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.while (enu.hasNext()) {ys = yacySeed.genRemoteSeed(enu.next(), null, false);if ((ys != null) &&- ((!webIndex.seedDB.mySeedIsDefined()) || (webIndex.seedDB.mySeed().hash != ys.hash))) {+ ((!webIndex.seedDB.mySeedIsDefined()) || !webIndex.seedDB.mySeed().hash.equals(ys.hash))) {if (webIndex.peerActions.connectPeer(ys, false)) lc++;//seedDB.writeMap(ys.hash, ys.getMap(), "init");//System.out.println("BOOTSTRAP: received peer " + ys.get(yacySeed.NAME, "anonymous") + "/" + ys.getAddress());diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.javaindex 22e728e42..3f2885338 100644--- a/source/de/anomic/plasma/plasmaWordIndex.java+++ b/source/de/anomic/plasma/plasmaWordIndex.java@@ -96,7 +96,7 @@ public final class plasmaWordIndex implements indexRI {private final indexCollectionRI collections; // new database structure to replace AssortmentCluster and FileClusterprivate final serverLog log;indexRepositoryReference referenceURL;- public yacySeedDB seedDB;+ public final yacySeedDB seedDB;public yacyNewsPool newsPool;private final File primaryRoot, secondaryRoot;public IndexingStack queuePreStack;diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.javaindex 41ec6a690..ae7c03bc7 100644--- a/source/de/anomic/server/serverCore.java+++ b/source/de/anomic/server/serverCore.java@@ -131,7 +131,7 @@ public final class serverCore extends serverAbstractBusyThread implements serverHashMap<String, String> denyHost;int commandMaxLength;private int maxBusySessions;- ConcurrentHashMap<Session, Object> busySessions;+ final ConcurrentHashMap<Session, Object> busySessions;/*private static ServerSocketFactory getServerSocketFactory(boolean dflt, File keyfile, String passphrase) {@@ -400,7 +400,7 @@ public final class serverCore extends serverAbstractBusyThread implements serverThread.interrupted();// shut down all busySessions- if (this.busySessions != null) for (final Session session: this.busySessions.keySet()) {+ for (final Session session: this.busySessions.keySet()) {try {session.interrupt();} catch (final SecurityException e ) {@@ -420,7 +420,7 @@ public final class serverCore extends serverAbstractBusyThread implements server// close all sessionsthis.log.logInfo("Closing server sessions ...");- if (this.busySessions != null) for (final Session s: this.busySessions.keySet()) {+ for (final Session s: this.busySessions.keySet()) {s.interrupt();s.close();}diff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.javaindex 24368b44d..0e7b3f262 100644--- a/source/de/anomic/server/serverObjects.java+++ b/source/de/anomic/server/serverObjects.java@@ -50,7 +50,6 @@ import java.io.UnsupportedEncodingException;import java.net.InetAddress;import java.util.ArrayList;import java.util.HashMap;-import java.util.Iterator;import java.util.Map;import de.anomic.data.htmlTools;@@ -271,11 +270,10 @@ public class serverObjects extends HashMap<String, String> implements Cloneable// the keyMapper may contain regular expressions as defined in String.matches// this method is particulary useful when parsing the result of checkbox formsfinal ArrayList<String> v = new ArrayList<String>();- final Iterator<String> e = keySet().iterator();String key;- while (e.hasNext()) {- key = e.next();- if (key.matches(keyMapper)) v.add(get(key));+ for (Map.Entry<String, String> entry: entrySet()) {+ key = entry.getKey();+ if (key.matches(keyMapper)) v.add(entry.getValue());}// make a String[]final String[] result = new String[v.size()];@@ -285,11 +283,8 @@ public class serverObjects extends HashMap<String, String> implements Cloneable// put all elements of another hashtable into the own tablepublic void putAll(final serverObjects add) {- final Iterator<String> e = add.keySet().iterator();- String k;- while (e.hasNext()) {- k = e.next();- put(k, add.get(k));+ for (Map.Entry<String, String> entry: add.entrySet()) {+ put(entry.getKey(), entry.getValue());}}@@ -298,11 +293,10 @@ public class serverObjects extends HashMap<String, String> implements CloneableBufferedOutputStream fos = null;try {fos = new BufferedOutputStream(new FileOutputStream(f));- final Iterator<String> e = keySet().iterator();String key, value;- while (e.hasNext()) {- key = e.next();- value = get(key).replaceAll("\n", "\\\\n");+ for (Map.Entry<String, String> entry: entrySet()) {+ key = entry.getKey();+ value = entry.getValue().replaceAll("\n", "\\\\n");fos.write((key + "=" + value + "\r\n").getBytes());}} finally {diff --git a/source/de/anomic/server/serverSystem.java b/source/de/anomic/server/serverSystem.javaindex e408fc717..b69fa5f84 100644--- a/source/de/anomic/server/serverSystem.java+++ b/source/de/anomic/server/serverSystem.java@@ -318,7 +318,8 @@ public final class serverSystem {}} catch (final Exception e) {System.err.println("ERROR "+ e.getClass() +" in openBrowser(): "+ e.getMessage());- System.out.println("please start your browser and open the following location: " + url);+ // browser could not be started automatically, tell user to do it+ System.out.println("please start your browser and open the following location: " + url);}}diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.javaindex d258fe385..3f31fca7a 100644--- a/source/de/anomic/yacy/yacyPeerActions.java+++ b/source/de/anomic/yacy/yacyPeerActions.java@@ -54,7 +54,6 @@ public class yacyPeerActions {if (userAgents != null) userAgents.clear();userAgents = null;if (dhtAction != null) dhtAction.close();- dhtAction.close();}public synchronized boolean connectPeer(final yacySeed seed, final boolean direct) {diff --git a/source/yacy.java b/source/yacy.javaindex 56183f0ee..45256036a 100644--- a/source/yacy.java+++ b/source/yacy.java@@ -346,7 +346,7 @@ public final class yacy {final String browserPopUpPage = sb.getConfig("browserPopUpPage", "ConfigBasic.html");//boolean properPW = (sb.getConfig("adminAccount", "").length() == 0) && (sb.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").length() > 0);//if (!properPW) browserPopUpPage = "ConfigBasic.html";- final String browserPopUpApplication = sb.getConfig("browserPopUpApplication", "netscape");+ final String browserPopUpApplication = sb.getConfig("browserPopUpApplication", "firefox");serverSystem.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage, browserPopUpApplication);}