more bugfixes as recommendet by findbugs

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5619 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 6b450d09ca
commit 62505bb3cb

@ -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);
}
}

@ -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);

@ -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)));
}

@ -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() :

@ -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

@ -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);
}

@ -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]);
}

@ -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;

@ -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;

@ -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();
}

@ -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);

@ -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) {

@ -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;
}

@ -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

@ -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 += "_";

@ -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);
}
}

@ -335,6 +335,7 @@ dc_rights
}
private synchronized void resortLinks() {
if (this.resorted) return;
// extract hyperlinks, medialinks and emaillinks from anchorlinks
yacyURL url;

@ -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
}

@ -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();

@ -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);
}
}

@ -122,6 +122,7 @@ public class yacyNewsDB {
}
public void remove() {
throw new UnsupportedOperationException();
}
}

@ -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)

Loading…
Cancel
Save