Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

more bugfixes as recommendet by findbugs

orbiter62505bb3cb0a
diff --git a/htroot/Threaddump_p.java b/htroot/Threaddump_p.java
index 28d8c54cc..553fc509e 100644
--- a/htroot/Threaddump_p.java
+++ b/htroot/Threaddump_p.java
@@ -159,9 +159,9 @@ public class Threaddump_p {
for (final Entry<String, ArrayList<String>> e: x.entrySet()) {
Integer c = result.get(e.getKey());
count = e.getValue().size();
- if (c == null) result.put(e.getKey(), new Integer(count));
+ if (c == null) result.put(e.getKey(), Integer.valueOf(count));
else {
- c = new Integer(c.intValue() + count);
+ c = Integer.valueOf(c.intValue() + count);
result.put(e.getKey(), c);
}
}
diff --git a/htroot/api/util/ynetSearch.java b/htroot/api/util/ynetSearch.java
index e391560e5..95d49aeeb 100755
--- a/htroot/api/util/ynetSearch.java
+++ b/htroot/api/util/ynetSearch.java
@@ -4,6 +4,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
+import java.util.Map;
import java.util.Scanner;
import de.anomic.http.httpRequestHeader;
@@ -35,12 +36,12 @@ public class ynetSearch {
}
post.remove("url");
post.remove("login");
- final Iterator <String> it = post.keySet().iterator();
+ final Iterator <Map.Entry<String, String>> it = post.entrySet().iterator();
String s = searchaddress;
- String k = "";
+ Map.Entry<String, String> k;
while(it.hasNext()) {
k = it.next();
- s = s + "&"+k+"="+post.get(k);
+ s = s + "&" + k.getKey() + "=" + k.getValue();
}
// final String s = searchaddress+"&search="+post.get("search")+"&maximumRecords="+post.get("maximumRecords")+"&startRecord="+post.get("startRecord");
final URL url = new URL(s);
diff --git a/source/dbtest.java b/source/dbtest.java
index d0b0ef3d0..292401a8d 100644
--- a/source/dbtest.java
+++ b/source/dbtest.java
@@ -71,7 +71,7 @@ public class dbtest {
public boolean isValid() {
final String s = new String(this.value).trim();
if (s.length() == 0) return false;
- final long source = new Long(s).longValue();
+ final long source = Long.valueOf(s).longValue();
return new String(this.key).equals(new String(randomHash(source, source)));
}
diff --git a/source/de/anomic/crawler/Balancer.java b/source/de/anomic/crawler/Balancer.java
index b1e6cd87c..54c3044fb 100644
--- a/source/de/anomic/crawler/Balancer.java
+++ b/source/de/anomic/crawler/Balancer.java
@@ -234,17 +234,17 @@ public class Balancer {
return removedCounter;
}
- public boolean has(final String urlhash) {
+ public synchronized boolean has(final String urlhash) {
return urlFileIndex.has(urlhash.getBytes());
}
- public boolean notEmpty() {
+ public synchronized boolean notEmpty() {
// alternative method to the property size() > 0
// this is better because it may avoid synchronized access to domain stack summarization
return urlRAMStack.size() > 0 || urlFileStack.size() > 0 || domainStacksNotEmpty();
}
- public int size() {
+ public synchronized int size() {
final int componentsize = urlFileIndex.size();
/*
assert componentsize == urlFileStack.size() + urlRAMStack.size() + sizeDomainStacks() :
diff --git a/source/de/anomic/crawler/CrawlQueues.java b/source/de/anomic/crawler/CrawlQueues.java
index 737d28567..f4caad1f6 100644
--- a/source/de/anomic/crawler/CrawlQueues.java
+++ b/source/de/anomic/crawler/CrawlQueues.java
@@ -248,7 +248,7 @@ public class CrawlQueues {
}
/**
- * if crawling was paused we have to wait until we wer notified to continue
+ * if crawling was paused we have to wait until we were notified to continue
* blocks until pause is ended
* @param crawljob
* @return
diff --git a/source/de/anomic/crawler/RobotsTxt.java b/source/de/anomic/crawler/RobotsTxt.java
index d020d5f54..b8fac7771 100644
--- a/source/de/anomic/crawler/RobotsTxt.java
+++ b/source/de/anomic/crawler/RobotsTxt.java
@@ -61,9 +61,13 @@ public class RobotsTxt {
MapView robotsTable;
private final File robotsTableFile;
- private final ConcurrentHashMap<String, Long> syncObjects;
+ private final ConcurrentHashMap<String, DomSync> syncObjects;
//private static final HashSet<String> loadedRobots = new HashSet<String>(); // only for debugging
+ private static class DomSync {
+ public DomSync() {}
+ }
+
public RobotsTxt(final File robotsTableFile) {
this.robotsTableFile = robotsTableFile;
robotsTableFile.getParentFile().mkdirs();
@@ -74,7 +78,7 @@ public class RobotsTxt {
e.printStackTrace();
}
robotsTable = new MapView(blob, 100);
- syncObjects = new ConcurrentHashMap<String, Long>();
+ syncObjects = new ConcurrentHashMap<String, DomSync>();
}
private void resetDatabase() {
@@ -123,9 +127,9 @@ public class RobotsTxt {
)) {
// make or get a synchronization object
- Long syncObj = this.syncObjects.get(urlHostPort);
+ DomSync syncObj = this.syncObjects.get(urlHostPort);
if (syncObj == null) {
- syncObj = new Long(System.currentTimeMillis());
+ syncObj = new DomSync();
this.syncObjects.put(urlHostPort, syncObj);
}
diff --git a/source/de/anomic/htmlFilter/htmlFilterCharacterCoding.java b/source/de/anomic/htmlFilter/htmlFilterCharacterCoding.java
index 6957521c9..e8fb12f12 100644
--- a/source/de/anomic/htmlFilter/htmlFilterCharacterCoding.java
+++ b/source/de/anomic/htmlFilter/htmlFilterCharacterCoding.java
@@ -177,12 +177,12 @@ public class htmlFilterCharacterCoding {
static {
Character c;
for (int i = 0; i < mapping4html.length; i += 2) {
- c = new Character(mapping4html[i].charAt(0));
+ c = Character.valueOf(mapping4html[i].charAt(0));
html2unicode4html.put(mapping4html[i + 1], c);
unicode2html4html.put(c, mapping4html[i + 1]);
}
for (int i = 0; i < mapping4xml.length; i += 2) {
- c = new Character(mapping4xml[i].charAt(0));
+ c = Character.valueOf(mapping4xml[i].charAt(0));
html2unicode4xml.put(mapping4xml[i + 1], c);
unicode2html4xml.put(c, mapping4xml[i + 1]);
}
diff --git a/source/de/anomic/index/indexCell.java b/source/de/anomic/index/indexCell.java
index 23e4803d7..dde274c70 100644
--- a/source/de/anomic/index/indexCell.java
+++ b/source/de/anomic/index/indexCell.java
@@ -202,7 +202,7 @@ public final class indexCell implements indexRI {
true);
}
- public class RemoveRewriter implements indexContainerBLOBArray.ContainerRewriter {
+ private static class RemoveRewriter implements indexContainerBLOBArray.ContainerRewriter {
Set<String> urlHashes;
diff --git a/source/de/anomic/index/indexRepositoryReference.java b/source/de/anomic/index/indexRepositoryReference.java
index 2f0756360..7a50c5c1e 100644
--- a/source/de/anomic/index/indexRepositoryReference.java
+++ b/source/de/anomic/index/indexRepositoryReference.java
@@ -574,7 +574,7 @@ public final class indexRepositoryReference {
return (statsDump == null) ? new ArrayList<hostStat>().iterator() : statsDump.iterator();
}
- public class hashStat {
+ private static class hashStat {
public String urlhash;
public int count;
public hashStat(String urlhash) {
@@ -583,7 +583,7 @@ public final class indexRepositoryReference {
}
}
- public class hostStat {
+ public static class hostStat {
public String hostname, hosthash;
public int port;
public int count;
diff --git a/source/de/anomic/kelondro/blob/BLOBCompressor.java b/source/de/anomic/kelondro/blob/BLOBCompressor.java
index 39076a559..a201f1d2b 100644
--- a/source/de/anomic/kelondro/blob/BLOBCompressor.java
+++ b/source/de/anomic/kelondro/blob/BLOBCompressor.java
@@ -239,7 +239,7 @@ public class BLOBCompressor extends Thread implements BLOB {
if (rx > 0) this.bufferlength -= rx;
}
- public int size() {
+ public synchronized int size() {
return this.backend.size() + this.buffer.size();
}
diff --git a/source/de/anomic/kelondro/blob/BLOBTree.java b/source/de/anomic/kelondro/blob/BLOBTree.java
index 523908cc4..c65c6cb2a 100644
--- a/source/de/anomic/kelondro/blob/BLOBTree.java
+++ b/source/de/anomic/kelondro/blob/BLOBTree.java
@@ -152,7 +152,7 @@ public class BLOBTree implements BLOB {
}
}
- public void clear() throws IOException {
+ public synchronized void clear() throws IOException {
final String name = this.index.filename();
this.index.clear();
this.buffer = new ObjectBuffer(name);
diff --git a/source/de/anomic/kelondro/blob/Cache.java b/source/de/anomic/kelondro/blob/Cache.java
index 70e731d73..302a54941 100644
--- a/source/de/anomic/kelondro/blob/Cache.java
+++ b/source/de/anomic/kelondro/blob/Cache.java
@@ -203,7 +203,7 @@ public class Cache implements ObjectIndex {
readMissCache = null;
}
- public boolean has(final byte[] key) {
+ public synchronized boolean has(final byte[] key) {
// first look into the miss cache
if (readMissCache != null) {
if (readMissCache.get(key) == null) {
diff --git a/source/de/anomic/kelondro/blob/Gap.java b/source/de/anomic/kelondro/blob/Gap.java
index d1169d2a4..a9fa489ac 100644
--- a/source/de/anomic/kelondro/blob/Gap.java
+++ b/source/de/anomic/kelondro/blob/Gap.java
@@ -68,7 +68,7 @@ public class Gap extends TreeMap<Long, Integer> {
try {
p = is.readLong();
l = is.readInt();
- this.put(new Long(p), new Integer(l));
+ this.put(Long.valueOf(p), Integer.valueOf(l));
} catch (IOException e) {
break;
}
diff --git a/source/de/anomic/kelondro/blob/HeapReader.java b/source/de/anomic/kelondro/blob/HeapReader.java
index 4f44740a8..c3548fffc 100644
--- a/source/de/anomic/kelondro/blob/HeapReader.java
+++ b/source/de/anomic/kelondro/blob/HeapReader.java
@@ -44,12 +44,12 @@ import de.anomic.kelondro.util.Log;
public class HeapReader {
- protected int keylength; // the length of the primary key
- protected BytesLongMap index; // key/seek relation for used records
- protected Gap free; // set of {seek, size} pairs denoting space and position of free records
- protected final File heapFile; // the file of the heap
- protected final ByteOrder ordering; // the ordering on keys
- protected CachedRandomAccess file; // a random access to the file
+ protected int keylength; // the length of the primary key
+ protected BytesLongMap index; // key/seek relation for used records
+ protected Gap free; // set of {seek, size} pairs denoting space and position of free records
+ protected final File heapFile; // the file of the heap
+ protected final ByteOrder ordering; // the ordering on keys
+ protected CachedRandomAccess file; // a random access to the file
public HeapReader(
final File heapFile,
@@ -266,7 +266,7 @@ public class HeapReader {
* @return the size of the BLOB or -1 if the BLOB does not exist
* @throws IOException
*/
- public long length(byte[] key) throws IOException {
+ public synchronized long length(byte[] key) throws IOException {
assert index.row().primaryKeyLength == key.length : index.row().primaryKeyLength + "!=" + key.length;
// check if the index contains the key
diff --git a/source/de/anomic/kelondro/blob/MapView.java b/source/de/anomic/kelondro/blob/MapView.java
index bef0cc422..f0eb86db6 100644
--- a/source/de/anomic/kelondro/blob/MapView.java
+++ b/source/de/anomic/kelondro/blob/MapView.java
@@ -95,7 +95,7 @@ public class MapView {
* clears the content of the database
* @throws IOException
*/
- public void clear() throws IOException {
+ public synchronized void clear() throws IOException {
this.blob.clear();
this.cache = new HashMap<String, Map<String, String>>();
this.cacheScore = new ScoreCluster<String>();
@@ -180,7 +180,7 @@ public class MapView {
* @return
* @throws IOException
*/
- public boolean has(String key) throws IOException {
+ public synchronized boolean has(String key) throws IOException {
assert key != null;
if (cache == null) return false; // case may appear during shutdown
while (key.length() < blob.keylength()) key += "_";
diff --git a/source/de/anomic/kelondro/table/ChunkIterator.java b/source/de/anomic/kelondro/table/ChunkIterator.java
index eef081094..99d3f4585 100644
--- a/source/de/anomic/kelondro/table/ChunkIterator.java
+++ b/source/de/anomic/kelondro/table/ChunkIterator.java
@@ -214,7 +214,7 @@ public class ChunkIterator implements Iterator<byte[]> {
e.printStackTrace();
}
- return new Integer(0);
+ return Integer.valueOf(0);
}
}
@@ -290,7 +290,7 @@ public class ChunkIterator implements Iterator<byte[]> {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
- return new Integer(0);
+ return Integer.valueOf(0);
}
}
diff --git a/source/de/anomic/plasma/plasmaParserDocument.java b/source/de/anomic/plasma/plasmaParserDocument.java
index 54878d402..4db737a1c 100644
--- a/source/de/anomic/plasma/plasmaParserDocument.java
+++ b/source/de/anomic/plasma/plasmaParserDocument.java
@@ -335,6 +335,7 @@ dc_rights
}
private synchronized void resortLinks() {
+ if (this.resorted) return;
// extract hyperlinks, medialinks and emaillinks from anchorlinks
yacyURL url;
diff --git a/source/de/anomic/server/serverProfiling.java b/source/de/anomic/server/serverProfiling.java
index 50113fa9a..f6b951061 100644
--- a/source/de/anomic/server/serverProfiling.java
+++ b/source/de/anomic/server/serverProfiling.java
@@ -71,10 +71,10 @@ public class serverProfiling extends Thread {
// get event history container
Long lastAcc = eventAccess.get(eventName);
if (lastAcc == null) {
- eventAccess.put(eventName, new Long(System.currentTimeMillis()));
+ eventAccess.put(eventName, Long.valueOf(System.currentTimeMillis()));
} else {
if (System.currentTimeMillis() - lastAcc.longValue() > 1000) {
- eventAccess.put(eventName, new Long(System.currentTimeMillis()));
+ eventAccess.put(eventName, Long.valueOf(System.currentTimeMillis()));
} else {
return; // protect against too heavy load
}
diff --git a/source/de/anomic/tools/diskUsage.java b/source/de/anomic/tools/diskUsage.java
index cf1996f4d..39411f5e0 100644
--- a/source/de/anomic/tools/diskUsage.java
+++ b/source/de/anomic/tools/diskUsage.java
@@ -161,8 +161,8 @@ public class diskUsage {
for (int i = 0; i < yacyUsedVolumes.size(); i++){
if (yacyUsedVolumes.get(i).equals(tokens[0])) {
final long[] vals = new long[2];
- try { vals[0] = new Long(tokens[1]); } catch (final NumberFormatException e) { continue nextLine; }
- try { vals[1] = new Long(tokens[3]); } catch (final NumberFormatException e) { continue nextLine; }
+ try { vals[0] = Long.valueOf(tokens[1]); } catch (final NumberFormatException e) { continue nextLine; }
+ try { vals[1] = Long.valueOf(tokens[3]); } catch (final NumberFormatException e) { continue nextLine; }
vals[0] *= 1024;
vals[1] *= 1024;
diskUsages.put(yacyUsedMountPoints.get(i), vals);
@@ -331,7 +331,7 @@ public class diskUsage {
final String[] tokens = line.trim().split(" ++");
final long[] vals = new long[2];
vals[0] = -1;
- try { vals[1] = new Long(tokens[2].replaceAll("[.,]", "")); } catch (final NumberFormatException e) {continue;}
+ try { vals[1] = Long.valueOf(tokens[2].replaceAll("[.,]", "")); } catch (final NumberFormatException e) {continue;}
diskUsages.put (yacyUsedVolumes.get(i), vals);
} catch (final IOException e) {
usageError = "dfWindows: " + e.getMessage();
diff --git a/source/de/anomic/tools/mediawikiIndex.java b/source/de/anomic/tools/mediawikiIndex.java
index 22440c74e..d9b41f6b2 100644
--- a/source/de/anomic/tools/mediawikiIndex.java
+++ b/source/de/anomic/tools/mediawikiIndex.java
@@ -169,7 +169,7 @@ public class mediawikiIndex {
entries.clear();
out.println("</index>");
out.close();
- return new Integer(count);
+ return Integer.valueOf(count);
}
}
@@ -216,7 +216,7 @@ public class mediawikiIndex {
e.printStackTrace();
}
entries.clear();
- return new Integer(count);
+ return Integer.valueOf(count);
}
}
diff --git a/source/de/anomic/yacy/yacyNewsDB.java b/source/de/anomic/yacy/yacyNewsDB.java
index 771d35a3d..5eb069269 100644
--- a/source/de/anomic/yacy/yacyNewsDB.java
+++ b/source/de/anomic/yacy/yacyNewsDB.java
@@ -122,6 +122,7 @@ public class yacyNewsDB {
}
public void remove() {
+ throw new UnsupportedOperationException();
}
}
diff --git a/source/de/anomic/yacy/yacyTray.java b/source/de/anomic/yacy/yacyTray.java
index 67371d170..3718c6c02 100644
--- a/source/de/anomic/yacy/yacyTray.java
+++ b/source/de/anomic/yacy/yacyTray.java
@@ -207,7 +207,7 @@ class nativeTrayIcon {
Method setImageAutoSizeMethod = TrayIconClass.getMethod("setImageAutoSize", partypes2);
Object arglist2[] = new Object[1];
- arglist2[0] = new Boolean(true);
+ arglist2[0] = Boolean.valueOf(true);
setImageAutoSizeMethod.invoke(this.TrayIcon, arglist2);
// with reflections: this.TrayIcon.addActionListener(al)