Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
* removed some warnings of findbugs (http://findbugs.sf.net) - removed unnecessary code (unused variables, String.toString) - corrected some calculations (cast int to double or long ;) - improved little performance (using Integer.valueOf() instead of new Integer) - log if some File-actions fail (mkdir(), delete(), ...) and some ignored exceptions - finalized some (more) fields - finally close some streams - made inner classes static if not using environment - generalized some equals (from specificClass to Object) - fixed some potential nullpointer accesses
danielr621b473b188b
diff --git a/htroot/AccessTracker_p.java b/htroot/AccessTracker_p.javaindex 286660674..fa2ac84c3 100644--- a/htroot/AccessTracker_p.java+++ b/htroot/AccessTracker_p.java@@ -75,10 +75,10 @@ public class AccessTracker_p {host = i.next();access = sb.accessTrack(host);prop.putHTML("page_list_" + entCount + "_host", host);- prop.putNum("page_list_" + entCount + "_countSecond", access.tailMap(new Long(System.currentTimeMillis() - 1000)).size());- prop.putNum("page_list_" + entCount + "_countMinute", access.tailMap(new Long(System.currentTimeMillis() - 1000 * 60)).size());- prop.putNum("page_list_" + entCount + "_count10Minutes", access.tailMap(new Long(System.currentTimeMillis() - 1000 * 60 * 10)).size());- prop.putNum("page_list_" + entCount + "_countHour", access.tailMap(new Long(System.currentTimeMillis() - 1000 * 60 * 60)).size());+ prop.putNum("page_list_" + entCount + "_countSecond", access.tailMap(Long.valueOf(System.currentTimeMillis() - 1000)).size());+ prop.putNum("page_list_" + entCount + "_countMinute", access.tailMap(Long.valueOf(System.currentTimeMillis() - 1000 * 60)).size());+ prop.putNum("page_list_" + entCount + "_count10Minutes", access.tailMap(Long.valueOf(System.currentTimeMillis() - 1000 * 60 * 10)).size());+ prop.putNum("page_list_" + entCount + "_countHour", access.tailMap(Long.valueOf(System.currentTimeMillis() - 1000 * 60 * 60)).size());entCount++;}} catch (final ConcurrentModificationException e) {} // we don't want to synchronize this@@ -207,7 +207,7 @@ public class AccessTracker_p {dateCount++;}prop.put("page_list_" + entCount + "_dates", dateCount);- final int qph = handles.tailSet(new Long(System.currentTimeMillis() - 1000 * 60 * 60)).size();+ final int qph = handles.tailSet(Long.valueOf(System.currentTimeMillis() - 1000 * 60 * 60)).size();qphSum += qph;prop.put("page_list_" + entCount + "_qph", qph);diff --git a/htroot/BlacklistCleaner_p.java b/htroot/BlacklistCleaner_p.javaindex 5a367a34f..d8aced78d 100644--- a/htroot/BlacklistCleaner_p.java+++ b/htroot/BlacklistCleaner_p.java@@ -200,7 +200,7 @@ public class BlacklistCleaner_p {// check for double-occuranceif (ok.contains(s)) {- r.put(s, new Integer(ERR_DOUBLE_OCCURANCE));+ r.put(s, Integer.valueOf(ERR_DOUBLE_OCCURANCE));continue;}ok.add(s);@@ -218,29 +218,29 @@ public class BlacklistCleaner_p {// check whether host begins illegallyif (!host.matches("([A-Za-z0-9_-]+|\\*)(\\.([A-Za-z0-9_-]+|\\*))*")) {if (i == 0 && host.length() > 1 && host.charAt(1) != '.') {- r.put(s, new Integer(ERR_SUBDOMAIN_XOR_WILDCARD));+ r.put(s, Integer.valueOf(ERR_SUBDOMAIN_XOR_WILDCARD));continue;}- r.put(s, new Integer(ERR_HOST_WRONG_CHARS));+ r.put(s, Integer.valueOf(ERR_HOST_WRONG_CHARS));continue;}// in host-part only full sub-domains may be wildcardsif (host.length() > 0 && i > -1) {if (!(i == 0 || i == host.length() - 1)) {- r.put(s, new Integer(ERR_WILDCARD_BEGIN_OR_END));+ r.put(s, Integer.valueOf(ERR_WILDCARD_BEGIN_OR_END));continue;}if (i == host.length() - 1 && host.length() > 1 && host.charAt(i - 1) != '.') {- r.put(s, new Integer(ERR_SUBDOMAIN_XOR_WILDCARD));+ r.put(s, Integer.valueOf(ERR_SUBDOMAIN_XOR_WILDCARD));continue;}}// check for double-occurences of "*" in hostif (host.indexOf("*", i + 1) > -1) {- r.put(s, new Integer(ERR_TWO_WILDCARDS_IN_HOST));+ r.put(s, Integer.valueOf(ERR_TWO_WILDCARDS_IN_HOST));continue;}@@ -248,7 +248,7 @@ public class BlacklistCleaner_p {try {Pattern.compile(path);} catch (final PatternSyntaxException e) {- r.put(s, new Integer(ERR_PATH_REGEX));+ r.put(s, Integer.valueOf(ERR_PATH_REGEX));continue;}}diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.javaindex d088cb505..1a0e28e65 100644--- a/htroot/Bookmarks.java+++ b/htroot/Bookmarks.java@@ -382,7 +382,7 @@ public class Bookmarks {String fn="";bookmarksDB.Bookmark bookmark;- if (next) fn = it.next().toString();+ if (next) fn = it.next();else fn = prev;if(fn.equals("\uffff")) {diff --git a/htroot/CacheAdmin_p.java b/htroot/CacheAdmin_p.javaindex 0390cc1d1..b3acc898e 100644--- a/htroot/CacheAdmin_p.java+++ b/htroot/CacheAdmin_p.java@@ -216,7 +216,7 @@ public class CacheAdmin_p {prop.put("info_treeFolders", dList.size());while (iter.hasNext()) {prop.put("info_treeFolders_" + i + "_path", pathString);- prop.put("info_treeFolders_" + i + "_name", iter.next().toString());+ prop.put("info_treeFolders_" + i + "_name", iter.next());i++;}@@ -225,7 +225,7 @@ public class CacheAdmin_p {prop.put("info_treeFiles", fList.size());while (iter.hasNext()) {prop.put("info_treeFiles_" + i + "_path", pathString);- prop.put("info_treeFiles_" + i + "_name", iter.next().toString());+ prop.put("info_treeFiles_" + i + "_name", iter.next());i++;}}@@ -291,7 +291,7 @@ public class CacheAdmin_p {prop.put("info_type_use." + extension + "_" + extension + "_" + i + "_name",de.anomic.data.htmlTools.encodeUnicode2html(descr.replaceAll("\n", "").trim(), true));prop.put("info_type_use." + extension + "_" + extension + "_" + i + "_link",- de.anomic.data.htmlTools.encodeUnicode2html(entry.getKey().toString(), true));+ de.anomic.data.htmlTools.encodeUnicode2html(entry.getKey(), true));i++;}prop.put("info_type_use." + extension, (i == 0) ? 0 : 1);diff --git a/htroot/CookieTest_p.java b/htroot/CookieTest_p.javaindex 0329be0a1..5ee686a83 100644--- a/htroot/CookieTest_p.java+++ b/htroot/CookieTest_p.java@@ -56,7 +56,7 @@ public class CookieTest_p {while (it.hasNext()) {e = it.next();if (e.getKey().equals("Cookie")) {- final String coockie[]=e.getValue().toString().split(";");+ final String coockie[]=e.getValue().split(";");for(int i=0;i<coockie.length;i++){final String nameValue[]=coockie[i].split("=");@@ -75,8 +75,8 @@ public class CookieTest_p {}else if(post.containsKey("act")&&post.get("act").equals("set_cookie")){- final String cookieName = post.get("cookie_name").toString().trim();- final String cookieValue = post.get("cookie_value").toString().trim();+ final String cookieName = post.get("cookie_name").trim();+ final String cookieValue = post.get("cookie_value").trim();final httpHeader outgoingHeader=new httpHeader();outgoingHeader.setCookie(cookieName,cookieValue);diff --git a/htroot/IndexImport_p.java b/htroot/IndexImport_p.javaindex 7bba8af40..694cb6719 100644--- a/htroot/IndexImport_p.java+++ b/htroot/IndexImport_p.java@@ -122,7 +122,7 @@ public final class IndexImport_p {prop.put("running.jobs_" + i + "_type", currThread.getJobType());// root path of the source db- final String fullName = currThread.getJobName().toString();+ final String fullName = currThread.getJobName();final String shortName = (fullName.length()>30)?fullName.substring(0,12) + "..." + fullName.substring(fullName.length()-22,fullName.length()):fullName;prop.put("running.jobs_" + i + "_fullName",fullName);prop.put("running.jobs_" + i + "_shortName",shortName);@@ -154,7 +154,7 @@ public final class IndexImport_p {for (int i=0; i<finishedJobs.length; i++) {final Importer currThread = finishedJobs[i];final String error = currThread.getError();- final String fullName = currThread.getJobName().toString();+ final String fullName = currThread.getJobName();final String shortName = (fullName.length()>30)?fullName.substring(0,12) + "..." + fullName.substring(fullName.length()-22,fullName.length()):fullName;prop.put("finished.jobs_" + i + "_type", currThread.getJobType());prop.put("finished.jobs_" + i + "_fullName", fullName);diff --git a/htroot/Settings_ProxyAccess.inc b/htroot/Settings_ProxyAccess.incindex 43c4d2d44..358cfc5fd 100644--- a/htroot/Settings_ProxyAccess.inc+++ b/htroot/Settings_ProxyAccess.inc@@ -52,7 +52,7 @@<td><label for="accounts">Accounts</label>:</td><td><input name="use_proxyaccounts" id="accounts" type="checkbox" size="16" maxlength="16" value="on"#(use_proxyAccounts)#:: checked="checked"#(/use_proxyAccounts)# />- Use <a href="User_p.html">Proxy Accounts</a>+ Use <a href="ConfigAccounts_p.html">Proxy Accounts</a></td></tr><tr valign="top">@@ -60,4 +60,4 @@</tr></table></fieldset>-</form><br />\ No newline at end of file+</form><br />diff --git a/htroot/Supporter.java b/htroot/Supporter.javaindex a9b659d58..2d82e4799 100644--- a/htroot/Supporter.java+++ b/htroot/Supporter.java@@ -182,13 +182,13 @@ public class Supporter {final int factor = ((dbtype == yacyNewsPool.OUTGOING_DB) || (dbtype == yacyNewsPool.PUBLISHED_DB)) ? 2 : 1;if (vote.equals("negative")) {final Integer i = negativeHashes.get(urlhash);- if (i == null) negativeHashes.put(urlhash, new Integer(factor));- else negativeHashes.put(urlhash, new Integer(i.intValue() + factor));+ if (i == null) negativeHashes.put(urlhash, Integer.valueOf(factor));+ else negativeHashes.put(urlhash, Integer.valueOf(i.intValue() + factor));}if (vote.equals("positive")) {final Integer i = positiveHashes.get(urlhash);- if (i == null) positiveHashes.put(urlhash, new Integer(factor));- else positiveHashes.put(urlhash, new Integer(i.intValue() + factor));+ if (i == null) positiveHashes.put(urlhash, Integer.valueOf(factor));+ else positiveHashes.put(urlhash, Integer.valueOf(i.intValue() + factor));}}}diff --git a/htroot/Surftips.java b/htroot/Surftips.javaindex 3edd53b96..29d284849 100644--- a/htroot/Surftips.java+++ b/htroot/Surftips.java@@ -191,13 +191,13 @@ public class Surftips {final int factor = ((dbtype == yacyNewsPool.OUTGOING_DB) || (dbtype == yacyNewsPool.PUBLISHED_DB)) ? 2 : 1;if (vote.equals("negative")) {final Integer i = negativeHashes.get(urlhash);- if (i == null) negativeHashes.put(urlhash, new Integer(factor));- else negativeHashes.put(urlhash, new Integer(i.intValue() + factor));+ if (i == null) negativeHashes.put(urlhash, Integer.valueOf(factor));+ else negativeHashes.put(urlhash, Integer.valueOf(i.intValue() + factor));}if (vote.equals("positive")) {final Integer i = positiveHashes.get(urlhash);- if (i == null) positiveHashes.put(urlhash, new Integer(factor));- else positiveHashes.put(urlhash, new Integer(i.intValue() + factor));+ if (i == null) positiveHashes.put(urlhash, Integer.valueOf(factor));+ else positiveHashes.put(urlhash, Integer.valueOf(i.intValue() + factor));}}}diff --git a/htroot/ViewImage.java b/htroot/ViewImage.javaindex d70c4d13a..fd479c221 100644--- a/htroot/ViewImage.java+++ b/htroot/ViewImage.java@@ -109,7 +109,7 @@ public class ViewImage {}// read image- final Image image = ymageImageParser.parse(urlString.toString(), imgb);+ final Image image = ymageImageParser.parse(urlString, imgb);if ((auth) && ((width == 0) || (height == 0)) && (maxwidth == 0) && (maxheight == 0)) return image;diff --git a/htroot/ViewProfile.java b/htroot/ViewProfile.javaindex aac0c0f34..2e17fe53c 100644--- a/htroot/ViewProfile.java+++ b/htroot/ViewProfile.java@@ -146,7 +146,7 @@ public class ViewProfile {while (i.hasNext()) {entry = (Map.Entry) i.next();final String key = ((String) entry.getKey());- String value = new String();+ String value;// this prevents broken links ending in <br>value=((String) entry.getValue()).replaceAll("\r", "").replaceAll("\\\\n", "\n");diff --git a/htroot/WebStructurePicture_p.java b/htroot/WebStructurePicture_p.javaindex b5a6c8aa6..2cf61153a 100644--- a/htroot/WebStructurePicture_p.java+++ b/htroot/WebStructurePicture_p.java@@ -117,7 +117,7 @@ public class WebStructurePicture_p {ymageGraph.coordinate center = graph.getPoint(centerhost);int mynodes = 0;if (center == null) {- center = graph.addPoint(centerhost, x, y, nextlayer);+ /*center =*/ graph.addPoint(centerhost, x, y, nextlayer);maxnodes--;mynodes++;}@@ -147,8 +147,8 @@ public class WebStructurePicture_p {// set a new point. It is placed on a circle around the host pointfinal double angle = kelondroBase64Order.enhancedCoder.cardinal((targethash + "____").getBytes()) / maxlongd * 2 * Math.PI;//System.out.println("ANGLE = " + angle);- rr = radius * 0.25 * (1 - targetrefs / maxtargetrefs);- re = radius * 0.5 * (thisrefs / maxthisrefs);+ rr = radius * 0.25 * (1 - targetrefs / (double) maxtargetrefs);+ re = radius * 0.5 * (thisrefs / (double) maxthisrefs);graph.addPoint(targethost, x + (radius - rr - re) * Math.cos(angle), y + (radius - rr - re) * Math.sin(angle), nextlayer);maxnodes--;mynodes++;diff --git a/htroot/xml/bookmarks/posts/get.java b/htroot/xml/bookmarks/posts/get.javaindex d38777c56..49d011e0b 100644--- a/htroot/xml/bookmarks/posts/get.java+++ b/htroot/xml/bookmarks/posts/get.java@@ -68,7 +68,7 @@ public class get {bookmarksDB.Bookmark bookmark=null;while(it.hasNext()){bookmark=switchboard.bookmarksDB.getBookmark(it.next());- if(serverDate.formatISO8601(new Date(bookmark.getTimeStamp())) == date &&+ if(serverDate.formatISO8601(new Date(bookmark.getTimeStamp())).equals(date) &&tag==null || bookmark.getTags().contains(tag) &&isAdmin || bookmark.getPublic()){prop.put("posts_"+count+"_url", bookmark.getUrl());diff --git a/htroot/xml/bookmarks/xbel/xbel.java b/htroot/xml/bookmarks/xbel/xbel.javaindex 94cf2f25c..a365544eb 100644--- a/htroot/xml/bookmarks/xbel/xbel.java+++ b/htroot/xml/bookmarks/xbel/xbel.java@@ -53,7 +53,7 @@ public class xbel {private static int recurseFolders(final Iterator<String> it, String root, int count, final boolean next, final String prev){String fn="";- if(next) fn = it.next().toString();+ if(next) fn = it.next();else fn = prev;if(fn.equals("\uffff")) {diff --git a/htroot/yacy/search.java b/htroot/yacy/search.javaindex 8693a1028..47570f1d6 100644--- a/htroot/yacy/search.java+++ b/htroot/yacy/search.java@@ -125,15 +125,15 @@ public final class search {TreeSet<Long> trackerHandles = sb.remoteSearchTracker.get(client);if (trackerHandles == null) trackerHandles = new TreeSet<Long>();boolean block = false;- if (trackerHandles.tailSet(new Long(System.currentTimeMillis() - 6000)).size() > 1) try {+ if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 6000)).size() > 1) try {Thread.sleep(3000);block = true;} catch (final InterruptedException e) { e.printStackTrace(); }- if (trackerHandles.tailSet(new Long(System.currentTimeMillis() - 60000)).size() > 12) try {+ if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 60000)).size() > 12) try {Thread.sleep(10000);block = true;} catch (final InterruptedException e) { e.printStackTrace(); }- if (trackerHandles.tailSet(new Long(System.currentTimeMillis() - 600000)).size() > 36) try {+ if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 600000)).size() > 36) try {Thread.sleep(30000);block = true;} catch (final InterruptedException e) { e.printStackTrace(); }diff --git a/htroot/yacy/transfer.java b/htroot/yacy/transfer.javaindex 6270f55cf..2c91db4b5 100644--- a/htroot/yacy/transfer.java+++ b/htroot/yacy/transfer.java@@ -116,7 +116,7 @@ public final class transfer {path.mkdirs();final File file = new File(path, filename);try {- if (file.getCanonicalPath().toString().startsWith(path.getCanonicalPath().toString())){+ if (file.getCanonicalPath().startsWith(path.getCanonicalPath())){serverFileUtils.copy(fileString.getBytes(), file);final String md5t = serverCodings.encodeMD5Hex(file);if (md5t.equals(md5)) {diff --git a/htroot/yacy/ui/ymarks.java b/htroot/yacy/ui/ymarks.javaindex df3092355..5600b03aa 100644--- a/htroot/yacy/ui/ymarks.java+++ b/htroot/yacy/ui/ymarks.java@@ -381,7 +381,7 @@ public class ymarks {String fn="";bookmarksDB.Bookmark bookmark;- if (next) fn = it.next().toString();+ if (next) fn = it.next();else fn = prev;if(fn.equals("\uffff")) {diff --git a/htroot/yacy/user/ysearch.java b/htroot/yacy/user/ysearch.javaindex daf381cf8..ccff5e5ee 100644--- a/htroot/yacy/user/ysearch.java+++ b/htroot/yacy/user/ysearch.java@@ -152,15 +152,15 @@ public class ysearch {TreeSet<Long> trackerHandles = sb.localSearchTracker.get(client);if (trackerHandles == null) trackerHandles = new TreeSet<Long>();boolean block = false;- if (trackerHandles.tailSet(new Long(System.currentTimeMillis() - 3000)).size() > 1) try {+ if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 3000)).size() > 1) try {Thread.sleep(3000);block = true;} catch (final InterruptedException e) { e.printStackTrace(); }- if (trackerHandles.tailSet(new Long(System.currentTimeMillis() - 60000)).size() > 12) try {+ if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 60000)).size() > 12) try {Thread.sleep(10000);block = true;} catch (final InterruptedException e) { e.printStackTrace(); }- if (trackerHandles.tailSet(new Long(System.currentTimeMillis() - 600000)).size() > 36) try {+ if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 600000)).size() > 36) try {Thread.sleep(30000);block = true;} catch (final InterruptedException e) { e.printStackTrace(); }diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex 21c5f25c0..a3883cb0c 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -166,15 +166,15 @@ public class yacysearch {boolean block = false;if (global || fetchSnippets) {// in case that we do a global search or we want to fetch snippets, we check for DoS cases- if (trackerHandles.tailSet(new Long(System.currentTimeMillis() - 3000)).size() > 1) try {+ if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 3000)).size() > 1) try {Thread.sleep(3000);block = true;} catch (final InterruptedException e) { e.printStackTrace(); }- if (trackerHandles.tailSet(new Long(System.currentTimeMillis() - 60000)).size() > 12) try {+ if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 60000)).size() > 12) try {Thread.sleep(10000);block = true;} catch (final InterruptedException e) { e.printStackTrace(); }- if (trackerHandles.tailSet(new Long(System.currentTimeMillis() - 600000)).size() > 36) try {+ if (trackerHandles.tailSet(Long.valueOf(System.currentTimeMillis() - 600000)).size() > 36) try {Thread.sleep(30000);block = true;} catch (final InterruptedException e) { e.printStackTrace(); }diff --git a/source/dbtest.java b/source/dbtest.javaindex a6e6b844a..45b6f5049 100644--- a/source/dbtest.java+++ b/source/dbtest.java@@ -34,7 +34,7 @@ public class dbtest {public final static int keylength = 12;public final static int valuelength = 223; // sum of all data length as defined in plasmaURL- public static byte[] dummyvalue2 = new byte[valuelength];+ private static final byte[] dummyvalue2 = new byte[valuelength];static {// fill the dummy valuefor (int i = 0; i < valuelength; i++) dummyvalue2[i] = '-';@@ -449,10 +449,10 @@ public class dbtest {final kelondroIntBytesMap kcontrol = new kelondroIntBytesMap(1, 0);for (int i = 0; i < writeCount; i++) {r = Math.abs(random.nextLong() % 1000);- jcontrol.add(new Long(r));+ jcontrol.add(Long.valueOf(r));kcontrol.putb((int) r, "x".getBytes());serverInstantBusyThread.oneTimeJob(new WriteJob(table_test, table_reference, r), 0, 50);- if (random.nextLong() % 5 == 0) ra.add(new Long(r));+ if (random.nextLong() % 5 == 0) ra.add(Long.valueOf(r));for (int j = 0; j < readCount; j++) {serverInstantBusyThread.oneTimeJob(new ReadJob(table_test, table_reference, random.nextLong() % writeCount), random.nextLong() % 1000, 20);}@@ -490,10 +490,10 @@ public class dbtest {for (int i = 0; i < writeCount; i++) {//if (i == 30) random = new Random(randomstart);r = Math.abs(random.nextLong() % 1000);- jcontrol.add(new Long(r));+ jcontrol.add(Long.valueOf(r));kcontrol.putb((int) r, "x".getBytes());new WriteJob(table_test, table_reference, r).run();- if (random.nextLong() % 5 == 0) ra.add(new Long(r));+ if (random.nextLong() % 5 == 0) ra.add(Long.valueOf(r));for (int j = 0; j < readCount; j++) {new ReadJob(table_test, table_reference, random.nextLong() % writeCount).run();}diff --git a/source/de/anomic/crawler/Balancer.java b/source/de/anomic/crawler/Balancer.javaindex 788a3d518..52c7b0f67 100644--- a/source/de/anomic/crawler/Balancer.java+++ b/source/de/anomic/crawler/Balancer.java@@ -127,7 +127,7 @@ public class Balancer {}}- public void finalize() {+ protected void finalize() {if (urlFileStack != null) {serverLog.logWarning("Balancer", "crawl stack " + stackname + " closed by finalizer");close();@@ -315,7 +315,7 @@ public class Balancer {urlFileStack.push(urlFileStack.row().newEntry(new byte[][]{(urlRAMStack.get(i)).getBytes()}));urlFileStack.push(urlFileStack.row().newEntry(new byte[][]{(urlRAMStack.get(urlRAMStack.size() - i - 1)).getBytes()}));}- if (urlRAMStack.size() % 2 == 1)+ if (urlRAMStack.size() % 2 != 0)urlFileStack.push(urlFileStack.row().newEntry(new byte[][]{(urlRAMStack.get(urlRAMStack.size() / 2)).getBytes()}));}@@ -417,7 +417,7 @@ public class Balancer {entry = i.next();domhash = entry.getKey();domlist = entry.getValue();- hitlist.put(new Integer(domlist.size() * 100 + count++), domhash);+ hitlist.put(Integer.valueOf(domlist.size() * 100 + count++), domhash);}// now iterate in descending order and fetch that one,diff --git a/source/de/anomic/crawler/CrawlQueues.java b/source/de/anomic/crawler/CrawlQueues.javaindex cd0101506..0bdae76cc 100644--- a/source/de/anomic/crawler/CrawlQueues.java+++ b/source/de/anomic/crawler/CrawlQueues.java@@ -498,7 +498,7 @@ public class CrawlQueues {return workers.size();}- protected class crawlWorker extends Thread {+ protected final class crawlWorker extends Thread {public CrawlEntry entry;private final Integer code;@@ -506,7 +506,7 @@ public class CrawlQueues {public crawlWorker(final CrawlEntry entry) {this.entry = entry;this.entry.setStatus("worker-initialized");- this.code = new Integer(entry.hashCode());+ this.code = Integer.valueOf(entry.hashCode());if (!workers.containsKey(code)) {workers.put(code, this);this.start();diff --git a/source/de/anomic/crawler/IndexingStack.java b/source/de/anomic/crawler/IndexingStack.javaindex f34501ff7..2460f7d1e 100644--- a/source/de/anomic/crawler/IndexingStack.java+++ b/source/de/anomic/crawler/IndexingStack.java@@ -291,7 +291,7 @@ public class IndexingStack {queueInProcess.remove(this.url.hash());}- public void finalize() {+ protected void finalize() {this.close();}diff --git a/source/de/anomic/crawler/NoticedURL.java b/source/de/anomic/crawler/NoticedURL.javaindex 99825746e..893855050 100755--- a/source/de/anomic/crawler/NoticedURL.java+++ b/source/de/anomic/crawler/NoticedURL.java@@ -104,7 +104,7 @@ public class NoticedURL {}}- public void finalize() {+ protected void finalize() {if ((coreStack != null) || (limitStack != null) || (remoteStack != null)) {serverLog.logWarning("plasmaCrawlNURL", "NURL stack closed by finalizer");close();diff --git a/source/de/anomic/crawler/ResourceObserver.java b/source/de/anomic/crawler/ResourceObserver.javaindex 8ef7f0d7f..6378980be 100644--- a/source/de/anomic/crawler/ResourceObserver.java+++ b/source/de/anomic/crawler/ResourceObserver.java@@ -39,9 +39,9 @@ public final class ResourceObserver {//private final static long MIN_FREE_MEMORY = 0;// We are called with the cleanup job every five minutes;// the disk usage should be checked with every run- private final int CHECK_DISK_USAGE_FREQ = 1;+ private static final int CHECK_DISK_USAGE_FREQ = 1;// The memory usage should be checked on every run- private final int CHECK_MEMORY_USAGE_FREQ = 1;+ private static final int CHECK_MEMORY_USAGE_FREQ = 1;private final serverLog log = new serverLog("RESOURCE OBSERVER");private final plasmaSwitchboard sb;@@ -67,7 +67,7 @@ public final class ResourceObserver {String path;for (final String element : pathes) {try {- path = sb.getConfigPath(element, "").getCanonicalPath().toString();+ path = sb.getConfigPath(element, "").getCanonicalPath();if (path.length() > 0) pathsToCheck.add(path);} catch (final IOException e) {}}diff --git a/source/de/anomic/crawler/RobotsTxt.java b/source/de/anomic/crawler/RobotsTxt.javaindex 7b3effc6c..e3ce528ba 100644--- a/source/de/anomic/crawler/RobotsTxt.java+++ b/source/de/anomic/crawler/RobotsTxt.java@@ -184,7 +184,7 @@ public class RobotsTxt {new Date(),null,null,- new Integer(0));+ Integer.valueOf(0));} else {robotsTxt4Host.setLoadedDate(new Date());}@@ -249,7 +249,7 @@ public class RobotsTxt {}}- public class Entry {+ public static class Entry {public static final String ALLOW_PATH_LIST = "allow";public static final String DISALLOW_PATH_LIST = "disallow";public static final String LOADED_DATE = "date";@@ -587,6 +587,6 @@ public class RobotsTxt {res.closeStream();}}- return new Object[]{new Boolean(accessCompletelyRestricted),robotsTxt,eTag,lastMod};+ return new Object[]{Boolean.valueOf(accessCompletelyRestricted),robotsTxt,eTag,lastMod};}}diff --git a/source/de/anomic/data/URLFetcherStack.java b/source/de/anomic/data/URLFetcherStack.javaindex c75d3857c..28303531e 100644--- a/source/de/anomic/data/URLFetcherStack.java+++ b/source/de/anomic/data/URLFetcherStack.java@@ -60,7 +60,7 @@ public class URLFetcherStack {public int getPushed() { return this.pushed; }public void clearStat() { this.popped = 0; this.pushed = 0; }- public void finalize() throws Throwable {+ protected void finalize() throws Throwable {this.db.close();}diff --git a/source/de/anomic/data/blogBoard.java b/source/de/anomic/data/blogBoard.javaindex 6e9e190c3..1ec927d8d 100644--- a/source/de/anomic/data/blogBoard.java+++ b/source/de/anomic/data/blogBoard.java@@ -268,10 +268,10 @@ public class blogBoard {*/public class BlogIterator implements Iterator<BlogEntry> {Iterator<byte[]> blogIter;- blogBoard.BlogEntry nextEntry;+ //blogBoard.BlogEntry nextEntry;public BlogIterator(final boolean up) throws IOException {this.blogIter = blogBoard.this.database.keys(up, false);- this.nextEntry = null;+ //this.nextEntry = null;}public boolean hasNext() {@@ -293,14 +293,14 @@ public class blogBoard {}public void remove() {- if (this.nextEntry != null) {- try {- final Object blogKey = this.nextEntry.getKey();- if (blogKey != null) deleteBlogEntry((String) blogKey);- } catch (final kelondroException e) {- //resetDatabase();- }- }+// if (this.nextEntry != null) {+// try {+// final Object blogKey = this.nextEntry.getKey();+// if (blogKey != null) deleteBlogEntry((String) blogKey);+// } catch (final kelondroException e) {+// //resetDatabase();+// }+// }}}diff --git a/source/de/anomic/data/blogBoardComments.java b/source/de/anomic/data/blogBoardComments.javaindex d16041790..4678cd045 100644--- a/source/de/anomic/data/blogBoardComments.java+++ b/source/de/anomic/data/blogBoardComments.java@@ -208,7 +208,7 @@ public class blogBoardComments {return database.keys(up, false);}- public class CommentEntry {+ public static class CommentEntry {String key;HashMap<String, String> record;diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.javaindex d8aac5ffc..705920be0 100644--- a/source/de/anomic/data/bookmarksDB.java+++ b/source/de/anomic/data/bookmarksDB.java@@ -33,6 +33,7 @@ import java.io.FileWriter;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;+import java.io.Serializable;import java.io.UnsupportedEncodingException;import java.io.Writer;import java.net.MalformedURLException;@@ -718,7 +719,7 @@ public class bookmarksDB {removeTag(oldHash);final Iterator<String> it = urlHashes.iterator();Bookmark bookmark;- Set<String> tags = new HashSet<String>();+ Set<String> tags;String tagsString;while (it.hasNext()) { // looping through all bookmarks which were tagged with oldNamebookmark = getBookmark(it.next());@@ -770,7 +771,7 @@ public class bookmarksDB {serverFileUtils.copy(input,writer);writer.close();links = scraper.getAnchors();- } catch (final IOException e) {}+ } 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();@@ -1269,12 +1270,12 @@ public class bookmarksDB {*/public class tagIterator implements Iterator<Tag> {kelondroCloneableIterator<byte[]> tagIter;- bookmarksDB.Tag nextEntry;+ //bookmarksDB.Tag nextEntry;public tagIterator(final boolean up) throws IOException {flushTagCache(); //XXX: This costs performace :-((this.tagIter = bookmarksDB.this.tagsTable.keys(up, false);- this.nextEntry = null;+ //this.nextEntry = null;}public boolean hasNext() {@@ -1296,14 +1297,14 @@ public class bookmarksDB {}public void remove() {- if (this.nextEntry != null) {- try {- final String tagHash = this.nextEntry.getTagHash();- if (tagHash != null) removeTag(tagHash);- } catch (final kelondroException e) {- //resetDatabase();- }- }+// if (this.nextEntry != null) {+// try {+// final String tagHash = this.nextEntry.getTagHash();+// if (tagHash != null) removeTag(tagHash);+// } catch (final kelondroException e) {+// //resetDatabase();+// }+// }}}@@ -1312,11 +1313,11 @@ public class bookmarksDB {*/public class bookmarkIterator implements Iterator<Bookmark> {Iterator<byte[]> bookmarkIter;- bookmarksDB.Bookmark nextEntry;+ //bookmarksDB.Bookmark nextEntry;public bookmarkIterator(final boolean up) throws IOException {//flushBookmarkCache(); //XXX: this will cost performancethis.bookmarkIter = bookmarksDB.this.bookmarksTable.keys(up, false);- this.nextEntry = null;+ //this.nextEntry = null;}public boolean hasNext() {@@ -1338,14 +1339,14 @@ public class bookmarksDB {}public void remove() {- if (this.nextEntry != null) {- try {- final Object bookmarkName = this.nextEntry.getUrlHash();- if (bookmarkName != null) removeBookmark((String) bookmarkName);- } catch (final kelondroException e) {- //resetDatabase();- }- }+// if (this.nextEntry != null) {+// try {+// final Object bookmarkName = this.nextEntry.getUrlHash();+// if (bookmarkName != null) removeBookmark((String) bookmarkName);+// } catch (final kelondroException e) {+// //resetDatabase();+// }+// }}}@@ -1380,17 +1381,27 @@ public class bookmarksDB {/*** Comparator to sort objects of type Tag according to their names*/- public class tagComparator implements Comparator<Tag> {+ public static class tagComparator implements Comparator<Tag>, Serializable {- public int compare(final Tag obj1, final Tag obj2){+ /**+ * generated serial+ */+ private static final long serialVersionUID = 3105057490088903930L;++ public int compare(final Tag obj1, final Tag obj2){return obj1.getTagName().compareTo(obj2.getTagName());}}- public class tagSizeComparator implements Comparator<Tag> {+ public static class tagSizeComparator implements Comparator<Tag>, Serializable {- public int compare(final Tag obj1, final Tag obj2) {+ /**+ * generated serial+ */+ private static final long serialVersionUID = 4149185397646373251L;++ public int compare(final Tag obj1, final Tag obj2) {if (obj1.size() < obj2.size()) return 1;else if (obj1.getTagName().equals(obj2.getTagName())) return 0;else return -1;diff --git a/source/de/anomic/data/diff.java b/source/de/anomic/data/diff.javaindex cca137b4e..3f98805e5 100644--- a/source/de/anomic/data/diff.java+++ b/source/de/anomic/data/diff.java@@ -61,10 +61,10 @@ public class diff {if (o == null || n == null) throw new NullPointerException("neither o nor n must be null");this.o = new Comparable[o.length()];for (int i=0; i<o.length(); i++)- this.o[i] = new Character(o.charAt(i));+ this.o[i] = Character.valueOf(o.charAt(i));this.n = new Comparable[n.length()];for (int i=0; i<n.length(); i++)- this.n[i] = new Character(n.charAt(i));+ this.n[i] = Character.valueOf(n.charAt(i));parse((minConsecutive > 0) ? minConsecutive : 1);}diff --git a/source/de/anomic/data/userDB.java b/source/de/anomic/data/userDB.javaindex 562cb9616..f49809376 100644--- a/source/de/anomic/data/userDB.java+++ b/source/de/anomic/data/userDB.java@@ -582,11 +582,11 @@ public final class userDB {public class userIterator implements Iterator<Entry> {// the iterator iterates all userNameskelondroCloneableIterator<byte[]> userIter;- userDB.Entry nextEntry;+ //userDB.Entry nextEntry;public userIterator(final boolean up) throws IOException {this.userIter = userDB.this.userTable.keys(up, false);- this.nextEntry = null;+ //this.nextEntry = null;}public boolean hasNext() {try {@@ -605,14 +605,14 @@ public final class userDB {}}public void remove() {- if (this.nextEntry != null) {- try {- final Object userName = this.nextEntry.getUserName();- if (userName != null) removeEntry((String) userName);- } catch (final kelondroException e) {- resetDatabase();- }- }+// if (this.nextEntry != null) {+// try {+// final Object userName = this.nextEntry.getUserName();+// if (userName != null) removeEntry((String) userName);+// } catch (final kelondroException e) {+// resetDatabase();+// }+// }}}diff --git a/source/de/anomic/data/wikiCode.java b/source/de/anomic/data/wikiCode.javaindex d8f82a384..a96e237f3 100644--- a/source/de/anomic/data/wikiCode.java+++ b/source/de/anomic/data/wikiCode.java@@ -636,11 +636,11 @@ public class wikiCode extends abstractWikiParser implements wikiParser {String anchorext = "";if((s=dirElements.size())>2){for(int i=0;i<s;i++){- element = dirElements.get(i).toString();+ element = dirElements.get(i);//counting double headlinesdoubles = 0;for(int j=0;j<i;j++){- if(dirElements.get(j).toString().substring(1).replaceAll(" ","_").replaceAll("[^a-zA-Z0-9_]","").equals(element.substring(1).replaceAll(" ","_").replaceAll("[^a-zA-Z0-9_]",""))){+ if(dirElements.get(j).substring(1).replaceAll(" ","_").replaceAll("[^a-zA-Z0-9_]","").equals(element.substring(1).replaceAll(" ","_").replaceAll("[^a-zA-Z0-9_]",""))){doubles++;}}@@ -719,7 +719,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {//counting double headlinesint doubles = 0;for(int i=0;i<headlines;i++){- if(dirElements.get(i).toString().substring(1).equals(direlem)){+ if(dirElements.get(i).substring(1).equals(direlem)){doubles++;}}@@ -738,7 +738,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {}else{input = input.substring(0, p0) + repl1 +- (direlem = input.substring(p0 + l, p1)) + repl2 ++ (/*direlem =*/ input.substring(p0 + l, p1)) + repl2 +input.substring(p1 + l);}}diff --git a/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java b/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.javaindex 61630cb54..a01f66527 100644--- a/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java+++ b/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java@@ -434,7 +434,6 @@ public abstract class htmlFilterAbstractScraper implements htmlFilterScraper {bb = new serverCharBuffer(bb.getChars(0, p0), bb.length()).append(bb.getChars(p0 + 1));}}- t = null;return bb;}@@ -462,7 +461,7 @@ public abstract class htmlFilterAbstractScraper implements htmlFilterScraper {tags1 = null;}- public void finalize() {+ protected void finalize() {close();}diff --git a/source/de/anomic/htmlFilter/htmlFilterAbstractTransformer.java b/source/de/anomic/htmlFilter/htmlFilterAbstractTransformer.javaindex fd0fac919..e67e057e2 100644--- a/source/de/anomic/htmlFilter/htmlFilterAbstractTransformer.java+++ b/source/de/anomic/htmlFilter/htmlFilterAbstractTransformer.java@@ -65,7 +65,7 @@ public abstract class htmlFilterAbstractTransformer implements htmlFilterTransfotags1 = null;}- public void finalize() {+ protected void finalize() {close();}diff --git a/source/de/anomic/htmlFilter/htmlFilterContentTransformer.java b/source/de/anomic/htmlFilter/htmlFilterContentTransformer.javaindex a20874cc0..b5e83db8b 100644--- a/source/de/anomic/htmlFilter/htmlFilterContentTransformer.java+++ b/source/de/anomic/htmlFilter/htmlFilterContentTransformer.java@@ -27,6 +27,7 @@ package de.anomic.htmlFilter;import java.io.BufferedReader;import java.io.File;import java.io.FileReader;+import java.io.IOException;import java.text.Collator;import java.util.ArrayList;import java.util.Locale;@@ -75,7 +76,7 @@ public class htmlFilterContentTransformer extends htmlFilterAbstractTransformerif (!s.startsWith("#") && s.length() > 0) bluelist.add(s.toLowerCase());}r.close();- } catch (final Exception e) {+ } catch (final IOException e) {}// if (bluelist.size() == 0) System.out.println("BLUELIST is empty");}@@ -94,7 +95,13 @@ public class htmlFilterContentTransformer extends htmlFilterAbstractTransformerbb.append((int)'X');}bb.append("</FONT> ");- return bb.getChars();+ final char[] result = bb.getChars();+ try {+ bb.close();+ } catch (IOException e) {+ e.printStackTrace();+ }+ return result;}private boolean bluelistHit(final char[] text) {diff --git a/source/de/anomic/htmlFilter/htmlFilterInputStream.java b/source/de/anomic/htmlFilter/htmlFilterInputStream.javaindex 9c0fa60dd..e832be6f4 100644--- a/source/de/anomic/htmlFilter/htmlFilterInputStream.java+++ b/source/de/anomic/htmlFilter/htmlFilterInputStream.java@@ -44,7 +44,7 @@ public class htmlFilterInputStream extends InputStream implements htmlFilterEvenprivate static final int MODE_PRESCAN_FINISHED = 1;private int mode = 1;- private final long preBufferSize = 2048;+ private static final long preBufferSize = 2048;private long preRead = 0;private final BufferedInputStream bufferedIn;diff --git a/source/de/anomic/htmlFilter/htmlFilterWriter.java b/source/de/anomic/htmlFilter/htmlFilterWriter.javaindex 866f61604..b8c058440 100644--- a/source/de/anomic/htmlFilter/htmlFilterWriter.java+++ b/source/de/anomic/htmlFilter/htmlFilterWriter.java@@ -110,7 +110,13 @@ public final class htmlFilterWriter extends Writer {// else bb.append((byte) 32).append(tagopts);}bb.append((int)'>');- return bb.getChars();+ final char[] result = bb.getChars();+ try {+ bb.close();+ } catch (IOException e) {+ e.printStackTrace();+ }+ return result;}public static char[] genTag1raw(final String tagname, final char[] tagopts, final char[] text) {@@ -124,7 +130,13 @@ public final class htmlFilterWriter extends Writer {bb.append((int)'>');bb.append(text);bb.append((int)'<').append((int)'/').append(tagname).append((int)'>');- return bb.getChars();+ final char[] result = bb.getChars();+ try {+ bb.close();+ } catch (IOException e) {+ e.printStackTrace();+ }+ return result;}public static char[] genTag0(final String tagname, final Properties tagopts, final char quotechar) {@@ -136,14 +148,26 @@ public final class htmlFilterWriter extends Writer {bb.append(tagoptsx);}bb.append((int)'>');- return bb.getChars();+ final char[] result = bb.getChars();+ try {+ bb.close();+ } catch (IOException e) {+ e.printStackTrace();+ }+ return result;}public static char[] genTag1(final String tagname, final Properties tagopts, final char[] text, final char quotechar) {final char[] gt0 = genTag0(tagname, tagopts, quotechar);final serverCharBuffer cb = new serverCharBuffer(gt0, gt0.length + text.length + tagname.length() + 3);cb.append(text).append((int)'<').append((int)'/').append(tagname).append((int)'>');- return cb.getChars();+ final char[] result = cb.getChars();+ try {+ cb.close();+ } catch (IOException e) {+ e.printStackTrace();+ }+ return result;}// a helper method for pretty-printing of properties for html tags@@ -157,8 +181,17 @@ public final class htmlFilterWriter extends Writer {bb.append(prop.getProperty(key));bb.append((int)quotechar);}- if (bb.length() > 0) return bb.getChars(1);- return bb.getChars();+ final char[] result;+ if (bb.length() > 0)+ result = bb.getChars(1);+ else+ result = bb.getChars();+ try {+ bb.close();+ } catch (IOException ex) {+ ex.printStackTrace();+ }+ return result;}private char[] filterTag(final String tag, final boolean opening, final char[] content, final char quotechar) {@@ -176,16 +209,38 @@ public final class htmlFilterWriter extends Writer {if (opening) {if ((scraper != null) && (scraper.isTag0(tag))) {// this single tag is collected at once here- scraper.scrapeTag0(tag, new serverCharBuffer(content).propParser());+ final serverCharBuffer charBuffer = new serverCharBuffer(content);+ scraper.scrapeTag0(tag, charBuffer.propParser());+ try {+ charBuffer.close();+ } catch (IOException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ }}if ((transformer != null) && (transformer.isTag0(tag))) {// this single tag is collected at once here- return transformer.transformTag0(tag, new serverCharBuffer(content).propParser(), quotechar);+ final serverCharBuffer scb = new serverCharBuffer(content);+ try {+ return transformer.transformTag0(tag, scb.propParser(), quotechar);+ } finally {+ try {+ scb.close();+ } catch (IOException e) {+ e.printStackTrace();+ }+ }} else if (((scraper != null) && (scraper.isTag1(tag))) ||((transformer != null) && (transformer.isTag1(tag)))) {// ok, start collectingfilterTag = tag;- filterOpts = new serverCharBuffer(content).propParser();+ final serverCharBuffer scb = new serverCharBuffer(content);+ filterOpts = scb.propParser();+ try {+ scb.close();+ } catch (IOException e) {+ e.printStackTrace();+ }filterCont = new serverCharBuffer();return new char[0];} else {@@ -298,7 +353,7 @@ public final class htmlFilterWriter extends Writer {// System.out.println((char) c);if ((binaryUnsuspect) && (binaryHint((char)c))) {binaryUnsuspect = false;- if (passbyIfBinarySuspect) finalize();+ if (passbyIfBinarySuspect) close();}if (binaryUnsuspect || !passbyIfBinarySuspect) {@@ -442,7 +497,7 @@ public final class htmlFilterWriter extends Writer {// if you want to flush all, call close() at end of writing;}- public void finalize() throws IOException {+ protected void finalize() throws IOException {// if we are forced to close, we of course flush the buffer first,// then close the connectionclose();diff --git a/source/de/anomic/http/EasySSLProtocolSocketFactory.java b/source/de/anomic/http/EasySSLProtocolSocketFactory.javaindex 7baf70de3..7dda88ffa 100644--- a/source/de/anomic/http/EasySSLProtocolSocketFactory.java+++ b/source/de/anomic/http/EasySSLProtocolSocketFactory.java@@ -225,7 +225,7 @@ public class EasySSLProtocolSocketFactory implements SecureProtocolSocketFactory}public boolean equals(final Object obj) {- return ((obj != null) && obj.getClass().equals(EasySSLProtocolSocketFactory.class));+ return ((obj != null) && obj.getClass().equals(this.getClass()));}public int hashCode() {diff --git a/source/de/anomic/http/JakartaCommonsHttpClient.java b/source/de/anomic/http/JakartaCommonsHttpClient.javaindex bee8b8e60..3770395be 100644--- a/source/de/anomic/http/JakartaCommonsHttpClient.java+++ b/source/de/anomic/http/JakartaCommonsHttpClient.java@@ -604,7 +604,7 @@ public class JakartaCommonsHttpClient {final JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(1000, null, null);resp = client.POST(url, files);System.out.println("----- Header: -----");- System.out.println(new String(resp.getResponseHeader().toString()));+ System.out.println(resp.getResponseHeader().toString());System.out.println("----- Body: -----");System.out.println(new String(resp.getData()));} else if (args.length > 1 && "head".equals(args[1])) {diff --git a/source/de/anomic/http/JakartaCommonsHttpResponse.java b/source/de/anomic/http/JakartaCommonsHttpResponse.javaindex c9f31d783..0644f8690 100644--- a/source/de/anomic/http/JakartaCommonsHttpResponse.java+++ b/source/de/anomic/http/JakartaCommonsHttpResponse.java@@ -42,133 +42,143 @@ import de.anomic.server.serverFileUtils;* @since 21.03.2008*/public class JakartaCommonsHttpResponse {- private final HttpMethod method;- private String incomingAccountingName = null;-- /**- * cache of body-data- */- private byte[] responseBody;-- /**- * constructor- *- * @param method- * @throws IOException- */- public JakartaCommonsHttpResponse(final HttpMethod method) {- super();-- this.method = method;- }-- /*- * (non-Javadoc)- *- * @see de.anomic.http.HttpResponse#getResponseHeader()- */- public httpHeader getResponseHeader() {- final httpHeader responseHeader = new httpHeader();- for (final Header header : getHeaders()) {- responseHeader.add(header.getName(), header.getValue());- }- return responseHeader;- }-- /**- * @see org.apache.commons.httpclient.HttpMethod#getResponseHeaders()- * @return the headers- */- private Header[] getHeaders() {- return method.getResponseHeaders();- }-- /**- * @see org.apache.commons.httpclient.HttpMethod#getResponseBody()- * @return- * @throws IOException- */- public byte[] getData() throws IOException {- if (responseBody == null) {- InputStream instream = null;- try {- instream = getDataAsStream();- if (instream != null) {- responseBody = serverFileUtils.read(instream);- }- } finally {- if (instream != null) {- closeStream();- }- }- }- return responseBody;- }-- /**- * @see org.apache.commons.httpclient.HttpMethod#getResponseBodyAsStream()- * @return- * @throws IOException- */- public InputStream getDataAsStream() throws IOException {- InputStream inStream = method.getResponseBodyAsStream();- if(inStream == null) {- return null;- }-- if (getResponseHeader().gzip()) {- inStream = new GZIPInputStream(inStream);- }- // count bytes for overall http-statistics- return new httpdByteCountInputStream(inStream, incomingAccountingName);- }-- /*- * (non-Javadoc)- *- * @see de.anomic.http.HttpResponse#closeStream()- */- public void closeStream() {- method.releaseConnection();- // statistics- HttpConnectionInfo.removeConnection(method.hashCode());- }-- /*- * (non-Javadoc)- *- * @see de.anomic.http.HttpResponse#getStatusLine()- */- public String getStatusLine() {- return getStatusCode() + " " + method.getStatusText();- }-- /*- * (non-Javadoc)- *- * @see de.anomic.http.HttpResponse#getStatusCode()- */- public int getStatusCode() {- final int code = method.getStatusCode();- assert code >= 100 && code <= 999 : "postcondition violated: StatusCode (" + code + ") has not 3 digits!";- return code;- }-- /*- * (non-Javadoc)- *- * @see de.anomic.http.HttpResponse#getHttpVer()- */- public String getHttpVer() {- return method.getStatusLine().getHttpVersion();- }-- /**- * sets the name for accounting incoming (loaded) bytes- *- * @param accName- */- public void setAccountingName(final String accName) {- incomingAccountingName = accName;- }+ private final HttpMethod method;+ private String incomingAccountingName = null;++ /**+ * cache of body-data+ */+ private byte[] responseBody;++ /**+ * constructor+ *+ * @param method+ * @throws IOException+ */+ public JakartaCommonsHttpResponse(final HttpMethod method) {+ super();++ this.method = method;+ }++ /*+ * (non-Javadoc)+ *+ * @see de.anomic.http.HttpResponse#getResponseHeader()+ */+ public httpHeader getResponseHeader() {+ final httpHeader responseHeader = new httpHeader();+ for (final Header header : getHeaders()) {+ responseHeader.add(header.getName(), header.getValue());+ }+ return responseHeader;+ }++ /**+ * @see org.apache.commons.httpclient.HttpMethod#getResponseHeaders()+ * @return the headers+ */+ private Header[] getHeaders() {+ return method.getResponseHeaders();+ }++ /**+ * @see org.apache.commons.httpclient.HttpMethod#getResponseBody()+ * @return+ * @throws IOException+ */+ public byte[] getData() throws IOException {+ if (responseBody == null) {+ InputStream instream = null;+ try {+ instream = getDataAsStream();+ if (instream != null) {+ responseBody = serverFileUtils.read(instream);+ }+ } finally {+ if (instream != null) {+ closeStream();+ }+ }+ }+ return responseBody;+ }++ /**+ * @see org.apache.commons.httpclient.HttpMethod#getResponseBodyAsStream()+ * @return+ * @throws IOException+ */+ public InputStream getDataAsStream() throws IOException {+ InputStream inStream = method.getResponseBodyAsStream();+ if (inStream == null) {+ return null;+ }++ if (getResponseHeader().gzip()) {+ inStream = new GZIPInputStream(inStream);+ }+ // count bytes for overall http-statistics+ return new httpdByteCountInputStream(inStream, incomingAccountingName);+ }++ /*+ * (non-Javadoc)+ *+ * @see de.anomic.http.HttpResponse#closeStream()+ */+ public void closeStream() {+ method.releaseConnection();+ // statistics+ HttpConnectionInfo.removeConnection(method.hashCode());+ }++ /*+ * (non-Javadoc)+ *+ * @see de.anomic.http.HttpResponse#getStatusLine()+ */+ public String getStatusLine() {+ return getStatusCode() + " " + method.getStatusText();+ }++ /*+ * (non-Javadoc)+ *+ * @see de.anomic.http.HttpResponse#getStatusCode()+ */+ public int getStatusCode() {+ final int code = method.getStatusCode();+ assert code >= 100 && code <= 999 : "postcondition violated: StatusCode ("+ + code + ") has not 3 digits!";+ return code;+ }++ /*+ * (non-Javadoc)+ *+ * @see de.anomic.http.HttpResponse#getHttpVer()+ */+ public String getHttpVer() {+ return method.getStatusLine().getHttpVersion();+ }++ /**+ * sets the name for accounting incoming (loaded) bytes+ *+ * @param accName+ */+ public void setAccountingName(final String accName) {+ incomingAccountingName = accName;+ }++ /*+ * (non-Javadoc)+ *+ * @see java.lang.Object#finalize()+ */+ protected void finalize() {+ closeStream();+ }}diff --git a/source/de/anomic/http/httpChunkedInputStream.java b/source/de/anomic/http/httpChunkedInputStream.javaindex 6d42be802..0e2cab776 100644--- a/source/de/anomic/http/httpChunkedInputStream.java+++ b/source/de/anomic/http/httpChunkedInputStream.java@@ -204,6 +204,8 @@ public final class httpChunkedInputStream extends InputStream {result = Integer.parseInt(baos.toString().trim(), 16);} catch (final NumberFormatException e) {throw new IOException ("Malformed chunk. Bad chunk size: " + baos.toString());+ } finally {+ baos.close();}return result;}diff --git a/source/de/anomic/http/httpHeader.java b/source/de/anomic/http/httpHeader.javaindex 41ac99cff..da5e50704 100644--- a/source/de/anomic/http/httpHeader.java+++ b/source/de/anomic/http/httpHeader.java@@ -477,12 +477,12 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Strpublic static Object[] parseResponseLine(final String respLine) {if ((respLine == null) || (respLine.length() == 0)) {- return new Object[]{"HTTP/1.0",new Integer(500),"status line parse error"};+ return new Object[]{"HTTP/1.0",Integer.valueOf(500),"status line parse error"};}int p = respLine.indexOf(" ");if (p < 0) {- return new Object[]{"HTTP/1.0",new Integer(500),"status line parse error"};+ return new Object[]{"HTTP/1.0",Integer.valueOf(500),"status line parse error"};}String httpVer, status, statusText;@@ -500,7 +500,7 @@ public final class httpHeader extends TreeMap<String, String> implements Map<StrstatusCode = Integer.valueOf((p < 0) ? status.trim() : status.substring(0,p).trim());statusText = (p < 0) ? "" : status.substring(p+1).trim();} catch (final Exception e) {- statusCode = new Integer(500);+ statusCode = Integer.valueOf(500);statusText = status;}@@ -798,7 +798,7 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str/*** Implementation of Map.Entry. Structure that hold two values - exactly what we need!*/- class Entry implements Map.Entry<String, String> {+ static class Entry implements Map.Entry<String, String> {private final String k;private String v;Entry(final String k, final String v) {@@ -909,7 +909,7 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str//System.out.println(""+e.getKey()+" : "+e.getValue());if(e.getKey().equals("Cookie")){- return e.getValue().toString();+ return e.getValue();}}return "";diff --git a/source/de/anomic/http/httpTemplate.java b/source/de/anomic/http/httpTemplate.javaindex ea12f6b2d..6fba685be 100644--- a/source/de/anomic/http/httpTemplate.java+++ b/source/de/anomic/http/httpTemplate.java@@ -342,7 +342,7 @@ public final class httpTemplate {//TODO: better Error HandlingtransferUntil(pis, keyStream,appendBytes("%%".getBytes("UTF-8"),patternName,null,null));if(pis.available()==0){- serverLog.logSevere("TEMPLATE", "No such Template: %%"+patternName);+ serverLog.logSevere("TEMPLATE", "No such Template: %%"+new String(patternName));return structure.getBytes();}keyStream=new ByteArrayOutputStream();@@ -542,7 +542,13 @@ public final class httpTemplate {newPrefix.append(oldPrefix).append(key).append("_".getBytes());- return newPrefix.getBytes();+ byte[] result = newPrefix.getBytes();+ try {+ newPrefix.close();+ } catch (IOException e) {+ e.printStackTrace();+ }+ return result;}public static byte[] newPrefix(final byte[] oldPrefix, final byte[] multi_key, final int i) {@@ -555,6 +561,13 @@ public final class httpTemplate {.append("_".getBytes());} catch (final UnsupportedEncodingException e) {}+ finally {+ try {+ newPrefix.close();+ } catch (IOException e) {+ e.printStackTrace();+ }+ }return newPrefix.getBytes();}@@ -566,6 +579,12 @@ public final class httpTemplate {return new String(patternKey.getBytes(),"UTF-8");} catch (final UnsupportedEncodingException e) {return null;+ } finally {+ try {+ patternKey.close();+ } catch (IOException e) {+ e.printStackTrace();+ }}}@@ -575,7 +594,13 @@ public final class httpTemplate {.append(b2);if (b3 != null) byteArray.append(b3);if (b4 != null) byteArray.append(b4);- return byteArray.getBytes();+ final byte[] result = byteArray.getBytes();+ try {+ byteArray.close();+ } catch (IOException e) {+ e.printStackTrace();+ }+ return result;}}diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.javaindex 115458201..cab3ad112 100644--- a/source/de/anomic/http/httpd.java+++ b/source/de/anomic/http/httpd.java@@ -354,11 +354,11 @@ public final class httpd implements serverHandler, Cloneable {final String requester = this.prop.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP);if (requester == null) return false;if (lastAccessDelta(YaCyHopAccessRequester, requester) < 10000) return false;- YaCyHopAccessRequester.put(requester, new Long(System.currentTimeMillis()));+ YaCyHopAccessRequester.put(requester, Long.valueOf(System.currentTimeMillis()));// check access target frequecy: protection against DoS from a single peer by several different requestersif (lastAccessDelta(YaCyHopAccessTargets, host) < 3000) return false;- YaCyHopAccessTargets.put(host, new Long(System.currentTimeMillis()));+ YaCyHopAccessTargets.put(host, Long.valueOf(System.currentTimeMillis()));// passed all testsreturn true;@@ -376,7 +376,7 @@ public final class httpd implements serverHandler, Cloneable {// reading the authentication settings from switchboardif (!this.proxyAccounts_init) {- this.use_proxyAccounts = (switchboard.getConfig("use_proxyAccounts", "false").equals("true") ? true : false);+ this.use_proxyAccounts = switchboard.getConfigBool("use_proxyAccounts", false);this.proxyAccounts_init = true; // is initialised}@@ -730,7 +730,8 @@ public final class httpd implements serverHandler, Cloneable {// parsing post request bodies with a given lengthif (length != -1) {buffer = new byte[length];- in.read(buffer);+ int bytesRead = in.read(buffer);+ assert bytesRead == buffer.length;// parsing post request bodies which are gzip content-encoded} else {ByteArrayOutputStream bout = new ByteArrayOutputStream();@@ -906,8 +907,8 @@ public final class httpd implements serverHandler, Cloneable {throw new IOException("boundary not recognized: " + ((line == null) ? "NULL" : new String(line, "UTF-8")) + ", boundary = " + new String(boundary));// we need some constants- final byte[] namec = (new String("name=")).getBytes();- final byte[] filenamec = (new String("filename=")).getBytes();+ final byte[] namec = "name=".getBytes();+ final byte[] filenamec = "filename=".getBytes();//byte[] semicolonc = (new String(";")).getBytes();final byte[] quotec = new byte[] {(byte) '"'};@@ -1535,7 +1536,7 @@ public final class httpd implements serverHandler, Cloneable {try {final int idx = hostName.indexOf(":");final String dstHost = (idx != -1) ? hostName.substring(0,idx).trim() : hostName.trim();- final Integer dstPort = (idx != -1) ? Integer.valueOf(hostName.substring(idx+1).trim()) : new Integer(80);+ final Integer dstPort = (idx != -1) ? Integer.valueOf(hostName.substring(idx+1).trim()) : Integer.valueOf(80);// if the hostname endswith thisPeerName.yacy ...final String alternativeAddress = (alternativeResolver == null) ? null : alternativeResolver.myAlternativeAddress();@@ -1547,7 +1548,7 @@ public final class httpd implements serverHandler, Cloneable {*/} else if (// check if the destination port is equal to the port yacy is listening to- dstPort.equals(new Integer(serverCore.getPortNr(switchboard.getConfig("port", "8080")))) &&+ dstPort.equals(Integer.valueOf(serverCore.getPortNr(switchboard.getConfig("port", "8080")))) &&(// check if the destination host is our local IP addressisThisHostIP(dstHost) ||diff --git a/source/de/anomic/http/httpdByteCountInputStream.java b/source/de/anomic/http/httpdByteCountInputStream.javaindex 7107d1296..db73e226b 100644--- a/source/de/anomic/http/httpdByteCountInputStream.java+++ b/source/de/anomic/http/httpdByteCountInputStream.java@@ -131,7 +131,7 @@ public class httpdByteCountInputStream extends FilterInputStream {lastByteCount = byteCountInfo.get(this.byteCountAccountName).longValue();}lastByteCount += this.byteCount;- byteCountInfo.put(this.byteCountAccountName,new Long(lastByteCount));+ byteCountInfo.put(this.byteCountAccountName, Long.valueOf(lastByteCount));}}diff --git a/source/de/anomic/http/httpdByteCountOutputStream.java b/source/de/anomic/http/httpdByteCountOutputStream.javaindex 2833a0e30..ce47e16de 100644--- a/source/de/anomic/http/httpdByteCountOutputStream.java+++ b/source/de/anomic/http/httpdByteCountOutputStream.java@@ -126,7 +126,7 @@ public class httpdByteCountOutputStream extends BufferedOutputStream {lastByteCount = (byteCountInfo.get(this.byteCountAccountName)).longValue();}lastByteCount += this.byteCount;- byteCountInfo.put(this.byteCountAccountName,new Long(lastByteCount));+ byteCountInfo.put(this.byteCountAccountName, Long.valueOf(lastByteCount));}}diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.javaindex e4fdc72ad..998bf4905 100644--- a/source/de/anomic/http/httpdFileHandler.java+++ b/source/de/anomic/http/httpdFileHandler.java@@ -112,7 +112,7 @@ public final class httpdFileHandler {private static final HashMap<File, SoftReference<byte[]>> templateCache;private static final HashMap<File, SoftReference<Method>> templateMethodCache;- public static boolean useTemplateCache = false;+ public static final boolean useTemplateCache;//private Properties connectionProperties = null;// creating a logger@@ -148,8 +148,8 @@ public final class httpdFileHandler {// create a htRootPath: system pagesif (htRootPath == null) {- htRootPath = new File(theSwitchboard.getRootPath(), theSwitchboard.getConfig("htRootPath","htroot"));- if (!(htRootPath.exists())) htRootPath.mkdir();+ htRootPath = new File(theSwitchboard.getRootPath(), theSwitchboard.getConfig(plasmaSwitchboardConstants.HTROOT_PATH, plasmaSwitchboardConstants.HTROOT_PATH_DEFAULT));+ if (!(htRootPath.exists())) htRootPath.mkdir();}// create a htDocsPath: user defined pages@@ -318,9 +318,9 @@ public final class httpdFileHandler {serverLog.logInfo("HTTPD", "Wrong log-in for account 'admin' in http file handler for path '" + path + "' from host '" + clientIP + "'");final Integer attempts = serverCore.bfHost.get(clientIP);if (attempts == null)- serverCore.bfHost.put(clientIP, new Integer(1));+ serverCore.bfHost.put(clientIP, Integer.valueOf(1));else- serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));+ serverCore.bfHost.put(clientIP, Integer.valueOf(attempts.intValue() + 1));final httpHeader headers = getDefaultHeaders(path);headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");@@ -628,9 +628,9 @@ public final class httpdFileHandler {serverLog.logInfo("HTTPD", "dynamic log-in for account 'admin' in http file handler for path '" + path + "' from host '" + clientIP + "'");final Integer attempts = serverCore.bfHost.get(clientIP);if (attempts == null)- serverCore.bfHost.put(clientIP, new Integer(1));+ serverCore.bfHost.put(clientIP, Integer.valueOf(1));else- serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));+ serverCore.bfHost.put(clientIP, Integer.valueOf(attempts.intValue() + 1));}// send authentication request to browserfinal httpHeader headers = getDefaultHeaders(path);diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.javaindex cf0577bab..2c38b7f48 100644--- a/source/de/anomic/http/httpdProxyHandler.java+++ b/source/de/anomic/http/httpdProxyHandler.java@@ -101,7 +101,7 @@ public final class httpdProxyHandler {// static variables// can only be instantiated upon first instantiation of this class objectprivate static plasmaSwitchboard switchboard = null;- public static HashSet<String> yellowList = null;+ private static final HashSet<String> yellowList;private static int timeout = 30000;private static boolean yacyTrigger = true;public static boolean isTransparentProxy = false;@@ -203,6 +203,8 @@ public final class httpdProxyHandler {System.out.println("redirector not Found");}}+ } else {+ yellowList = null;}}@@ -284,7 +286,7 @@ public final class httpdProxyHandler {final int reqID = requestHeader.hashCode();// remembering the starting time of the requestfinal Date requestDate = new Date(); // remember the time...- conProp.put(httpHeader.CONNECTION_PROP_REQUEST_START,new Long(requestDate.getTime()));+ conProp.put(httpHeader.CONNECTION_PROP_REQUEST_START, Long.valueOf(requestDate.getTime()));if (yacyTrigger) de.anomic.yacy.yacyCore.triggerOnlineAction();switchboard.proxyLastAccess = System.currentTimeMillis();@@ -445,8 +447,8 @@ public final class httpdProxyHandler {try { if(countedRespond != null) countedRespond.flush(); else if(respond != null) respond.flush(); } catch (final Exception e) {}if (countedRespond != null) countedRespond.finish();- conProp.put(httpHeader.CONNECTION_PROP_REQUEST_END,new Long(System.currentTimeMillis()));- conProp.put(httpHeader.CONNECTION_PROP_PROXY_RESPOND_SIZE,(countedRespond != null) ? new Long(countedRespond.getCount()) : -1L);+ conProp.put(httpHeader.CONNECTION_PROP_REQUEST_END, Long.valueOf(System.currentTimeMillis()));+ conProp.put(httpHeader.CONNECTION_PROP_PROXY_RESPOND_SIZE,(countedRespond != null) ? Long.valueOf(countedRespond.getCount()) : -1L);logProxyAccess(conProp);}}@@ -605,7 +607,7 @@ public final class httpdProxyHandler {}theLogger.logFine(reqID +" writeContent of " + url + " produced cacheArray = " + ((cacheArray == null) ? "null" : ("size=" + cacheArray.length)));- if (hfos instanceof htmlFilterWriter) ((htmlFilterWriter) hfos).finalize();+ if (hfos instanceof htmlFilterWriter) ((htmlFilterWriter) hfos).close();if (sizeBeforeDelete == -1) {// totally fresh file@@ -631,7 +633,7 @@ public final class httpdProxyHandler {// write to file right here.cacheFile.getParentFile().mkdirs();writeContent(res, new BufferedWriter(hfos), new FileOutputStream(cacheFile));- if (hfos instanceof htmlFilterWriter) ((htmlFilterWriter) hfos).finalize();+ if (hfos instanceof htmlFilterWriter) ((htmlFilterWriter) hfos).close();theLogger.logFine(reqID +" for write-file of " + url + ": contentLength = " + contentLength + ", sizeBeforeDelete = " + sizeBeforeDelete);plasmaHTCache.writeFileAnnouncement(cacheFile);if (sizeBeforeDelete == -1) {@@ -661,7 +663,7 @@ public final class httpdProxyHandler {" SupportetContent=" + isSupportedContent);writeContent(res, new BufferedWriter(hfos));- if (hfos instanceof htmlFilterWriter) ((htmlFilterWriter) hfos).finalize();+ if (hfos instanceof htmlFilterWriter) ((htmlFilterWriter) hfos).close();/*if (sizeBeforeDelete == -1) {// no old file and no load. just data passing//cacheEntry.status = plasmaHTCache.CACHE_PASSING;@@ -775,7 +777,7 @@ public final class httpdProxyHandler {serverFileUtils.copy(cacheFile,charSet,(Writer)hfos);}- if (hfos instanceof htmlFilterWriter) ((htmlFilterWriter) hfos).finalize();+ if (hfos instanceof htmlFilterWriter) ((htmlFilterWriter) hfos).close();if (gzippedOut != null) gzippedOut.finish();if (chunkedOut != null) chunkedOut.finish();}@@ -826,7 +828,7 @@ public final class httpdProxyHandler {final int reqID = requestHeader.hashCode();// remembering the starting time of the requestfinal Date requestDate = new Date(); // remember the time...- conProp.put(httpHeader.CONNECTION_PROP_REQUEST_START,new Long(requestDate.getTime()));+ conProp.put(httpHeader.CONNECTION_PROP_REQUEST_START, Long.valueOf(requestDate.getTime()));if (yacyTrigger) de.anomic.yacy.yacyCore.triggerOnlineAction();switchboard.proxyLastAccess = System.currentTimeMillis();@@ -926,7 +928,7 @@ public final class httpdProxyHandler {final int reqID = requestHeader.hashCode();// remembering the starting time of the requestfinal Date requestDate = new Date(); // remember the time...- conProp.put(httpHeader.CONNECTION_PROP_REQUEST_START,new Long(requestDate.getTime()));+ conProp.put(httpHeader.CONNECTION_PROP_REQUEST_START, Long.valueOf(requestDate.getTime()));if (yacyTrigger) de.anomic.yacy.yacyCore.triggerOnlineAction();switchboard.proxyLastAccess = System.currentTimeMillis();@@ -1052,8 +1054,8 @@ public final class httpdProxyHandler {respond.flush();}- conProp.put(httpHeader.CONNECTION_PROP_REQUEST_END,new Long(System.currentTimeMillis()));- conProp.put(httpHeader.CONNECTION_PROP_PROXY_RESPOND_SIZE,(countedRespond != null) ? new Long(countedRespond.getCount()) : -1L);+ conProp.put(httpHeader.CONNECTION_PROP_REQUEST_END, Long.valueOf(System.currentTimeMillis()));+ conProp.put(httpHeader.CONNECTION_PROP_PROXY_RESPOND_SIZE,(countedRespond != null) ? Long.valueOf(countedRespond.getCount()) : -1L);logProxyAccess(conProp);}}diff --git a/source/de/anomic/icap/icapd.java b/source/de/anomic/icap/icapd.javaindex e0153e3d6..a632042ec 100644--- a/source/de/anomic/icap/icapd.java+++ b/source/de/anomic/icap/icapd.java@@ -247,7 +247,8 @@ public class icapd implements serverHandler, Cloneable {currLength = Integer.parseInt(encapsulated[i+1].split("=")[1]);final byte[] buffer = new byte[currLength-prevLength];- in.read(buffer, 0, buffer.length);+ final int bytesRead = in.read(buffer, 0, buffer.length);+ assert bytesRead == buffer.length;reqHdrStream = new ByteArrayInputStream(buffer);@@ -257,7 +258,8 @@ public class icapd implements serverHandler, Cloneable {currLength = Integer.parseInt(encapsulated[i+1].split("=")[1]);final byte[] buffer = new byte[currLength-prevLength];- in.read(buffer, 0, buffer.length);+ final int bytesRead = in.read(buffer, 0, buffer.length);+ assert bytesRead == buffer.length;resHdrStream = new ByteArrayInputStream(buffer);@@ -341,7 +343,7 @@ public class icapd implements serverHandler, Cloneable {final Object[] httpRespStatus = httpHeader.parseResponseLine(httpRespStatusLine);- if (!(httpRespStatus[1].equals(new Integer(200)) || httpRespStatus[1].equals(new Integer(203)))) {+ if (!(httpRespStatus[1].equals(Integer.valueOf(200)) || httpRespStatus[1].equals(Integer.valueOf(203)))) {this.log.logInfo("Wrong status code for indexing:" +"\nStatus Code: " + httpRespStatus[1] +"\nRequest Line: " + httpRequestLine +diff --git a/source/de/anomic/index/indexContainer.java b/source/de/anomic/index/indexContainer.javaindex d0f185a4e..71e8b200a 100644--- a/source/de/anomic/index/indexContainer.java+++ b/source/de/anomic/index/indexContainer.java@@ -245,7 +245,7 @@ public class indexContainer extends kelondroRowSet {if ((singleContainer == null) || (singleContainer.size() == 0)) return null; // as this is a cunjunction of searches, we have no result if any word is not known// store result in order of result size- map.put(new Long(singleContainer.size() * 1000 + count), singleContainer);+ map.put(Long.valueOf(singleContainer.size() * 1000 + count), singleContainer);count++;}diff --git a/source/de/anomic/index/indexContainerHeap.java b/source/de/anomic/index/indexContainerHeap.javaindex db720c438..21f711edd 100755--- a/source/de/anomic/index/indexContainerHeap.java+++ b/source/de/anomic/index/indexContainerHeap.java@@ -271,7 +271,7 @@ public final class indexContainerHeap {is = null;}- public void finalize() {+ protected void finalize() {this.close();}}@@ -377,7 +377,8 @@ public final class indexContainerHeap {final byte[] word = new byte[index.row().primaryKeyLength];raf.seek(pos);- raf.read(word);+ final int bytesRead = raf.read(word);+ assert bytesRead == word.length;assert key.equals(new String(word));// read collectiondiff --git a/source/de/anomic/index/indexPhrase.java b/source/de/anomic/index/indexPhrase.javaindex e55e262fc..472913233 100644--- a/source/de/anomic/index/indexPhrase.java+++ b/source/de/anomic/index/indexPhrase.java@@ -54,7 +54,7 @@ public class indexPhrase {}public void check(final int i) {- hash.add(new Integer(i));+ hash.add(Integer.valueOf(i));}diff --git a/source/de/anomic/index/indexRWIEntryOrder.java b/source/de/anomic/index/indexRWIEntryOrder.javaindex 3632871e0..487902faf 100644--- a/source/de/anomic/index/indexRWIEntryOrder.java+++ b/source/de/anomic/index/indexRWIEntryOrder.java@@ -166,7 +166,7 @@ public class indexRWIEntryOrder {this.start = start;this.end = end;this.doms = new HashMap<String, Integer>();- this.int1 = new Integer(1);+ this.int1 = 1;this.decodedEntries = new ArrayList<indexRWIVarEntry>();}@@ -190,7 +190,7 @@ public class indexRWIEntryOrder {if (count == null) {doms.put(dom, int1);} else {- doms.put(dom, new Integer(count.intValue() + 1));+ doms.put(dom, Integer.valueOf(count.intValue() + 1));}}}diff --git a/source/de/anomic/index/indexURLReference.java b/source/de/anomic/index/indexURLReference.javaindex 3f52f8f34..e9a048973 100644--- a/source/de/anomic/index/indexURLReference.java+++ b/source/de/anomic/index/indexURLReference.java@@ -464,7 +464,7 @@ public class indexURLReference {//return "{" + core + "}";}- public class Components {+ public static class Components {private yacyURL url;private final String dc_title, dc_creator, dc_subject, ETag;diff --git a/source/de/anomic/index/indexWord.java b/source/de/anomic/index/indexWord.javaindex d64224bfe..f598c016c 100644--- a/source/de/anomic/index/indexWord.java+++ b/source/de/anomic/index/indexWord.java@@ -65,7 +65,7 @@ public class indexWord {}public void check(final int i) {- phrases.add(new Integer(i));+ phrases.add(Integer.valueOf(i));}public Iterator<Integer> phrases() {diff --git a/source/de/anomic/kelondro/kelondroAbstractRA.java b/source/de/anomic/kelondro/kelondroAbstractRA.javaindex 752a96042..f3289714b 100644--- a/source/de/anomic/kelondro/kelondroAbstractRA.java+++ b/source/de/anomic/kelondro/kelondroAbstractRA.java@@ -197,6 +197,7 @@ abstract class kelondroAbstractRA implements kelondroRA {}bb.append("# EOF\r\n");write(bb.getBytes());+ bb.close();}public HashMap<String, String> readMap() throws IOException {diff --git a/source/de/anomic/kelondro/kelondroAbstractRecords.java b/source/de/anomic/kelondro/kelondroAbstractRecords.javaindex 9a766e013..afb1aee4e 100644--- a/source/de/anomic/kelondro/kelondroAbstractRecords.java+++ b/source/de/anomic/kelondro/kelondroAbstractRecords.java@@ -426,8 +426,8 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {// store dynamic run-time seek pointersPOS_HANDLES = POS_COLWIDTHS + ROW.columns() * 4;- POS_TXTPROPS = POS_HANDLES + FHandles * 4;- POS_NODES = POS_TXTPROPS + txtProps * this.TXTPROPW;+ POS_TXTPROPS = POS_HANDLES + FHandles * 4L;+ POS_NODES = POS_TXTPROPS + txtProps * (long) this.TXTPROPW;//System.out.println("*** DEBUG: POS_NODES = " + POS_NODES + " for " + filename);// store dynamic back-up variables@@ -661,7 +661,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {if (pos >= HANDLES.length) throw new IllegalArgumentException("setHandle: handle array exceeded");if (handle == null) handle = new kelondroHandle(kelondroHandle.NUL);HANDLES[pos] = handle;- entryFile.writeInt(POS_HANDLES + 4 * pos, handle.index);+ entryFile.writeInt(POS_HANDLES + 4L * pos, handle.index);}protected final kelondroHandle getHandle(final int pos) {@@ -675,7 +675,7 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {if (text == null) text = new byte[0];if (text.length > TXTPROPW) throw new IllegalArgumentException("setText: text lemgth exceeded");TXTPROPS[pos] = text;- entryFile.write(POS_TXTPROPS + TXTPROPW * pos, text);+ entryFile.write(POS_TXTPROPS + TXTPROPW * (long) pos, text);}public final byte[] getText(final int pos) {@@ -758,9 +758,8 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {this.entryFile = null;}- public void finalize() {+ protected void finalize() {if (entryFile != null) close();- this.entryFile = null;}protected final static String[] line2args(final String line) {diff --git a/source/de/anomic/kelondro/kelondroAttrSeq.java b/source/de/anomic/kelondro/kelondroAttrSeq.javaindex a36b6d8e3..f19b36ac8 100644--- a/source/de/anomic/kelondro/kelondroAttrSeq.java+++ b/source/de/anomic/kelondro/kelondroAttrSeq.java@@ -234,7 +234,7 @@ public class kelondroAttrSeq {return null;}- public class Structure {+ public static class Structure {protected String pivot_name = null;protected int pivot_len = -1;@@ -351,7 +351,7 @@ public class kelondroAttrSeq {attrs = new HashMap<String, Long>();seq = (tree) ? (Set<String>) new TreeSet<String>() : (Set<String>) new HashSet<String>();for (int i = 0; i < structure.prop_names.length; i++) {- attrs.put(structure.prop_names[i], new Long(kelondroBase64Order.enhancedCoder.decodeLong(attrseq.substring(structure.prop_pos[i], structure.prop_pos[i] + structure.prop_len[i]))));+ attrs.put(structure.prop_names[i], Long.valueOf(kelondroBase64Order.enhancedCoder.decodeLong(attrseq.substring(structure.prop_pos[i], structure.prop_pos[i] + structure.prop_len[i]))));}int p = attrseq.indexOf('|') + 1;@@ -379,7 +379,7 @@ public class kelondroAttrSeq {}public void setAttr(final String key, final long attr) {- attrs.put(key, new Long(attr));+ attrs.put(key, Long.valueOf(attr));}public Set<String> getSeqSet() {diff --git a/source/de/anomic/kelondro/kelondroBLOBHeap.java b/source/de/anomic/kelondro/kelondroBLOBHeap.javaindex 9907871cd..6f3c4aef9 100755--- a/source/de/anomic/kelondro/kelondroBLOBHeap.java+++ b/source/de/anomic/kelondro/kelondroBLOBHeap.java@@ -43,7 +43,7 @@ public final class kelondroBLOBHeap implements kelondroBLOB {private final kelondroByteOrder ordering; // the ordering on keysprivate RandomAccessFile file; // a random access to the file- public class gap {+ public static class gap {public long seek;public int size;public gap(final long seek, final int size) {diff --git a/source/de/anomic/kelondro/kelondroBLOBTree.java b/source/de/anomic/kelondro/kelondroBLOBTree.javaindex 9581f52d3..5d3febcd6 100644--- a/source/de/anomic/kelondro/kelondroBLOBTree.java+++ b/source/de/anomic/kelondro/kelondroBLOBTree.java@@ -312,7 +312,6 @@ public class kelondroBLOBTree implements kelondroBLOB {byte[] buff = new byte[reclen];System.arraycopy(buf, 0, buff, 0, buf.length);buf = buff;- buff = null;}// System.out.println("write:// b.length="+b.length+",off="+off+",len="+(reclen-recpos));@@ -340,7 +339,6 @@ public class kelondroBLOBTree implements kelondroBLOB {byte[] buff = new byte[reclen];System.arraycopy(buf, 0, buff, 0, buf.length);buf = buff;- buff = null;}buf[recpos] = (byte) b;setValueCached(elementKey(key, reccnt), buf);diff --git a/source/de/anomic/kelondro/kelondroBase64Order.java b/source/de/anomic/kelondro/kelondroBase64Order.javaindex f83edf652..7859cc803 100644--- a/source/de/anomic/kelondro/kelondroBase64Order.java+++ b/source/de/anomic/kelondro/kelondroBase64Order.java@@ -32,7 +32,7 @@ import java.util.Comparator;import de.anomic.server.logging.serverLog;-public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implements kelondroByteOrder, kelondroCoding, Comparator<byte[]> {+public class kelondroBase64Order extends kelondroAbstractOrder<byte[]> implements kelondroByteOrder, kelondroCoding, Comparator<byte[]>, Cloneable {protected static final char[] alpha_standard = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();protected static final char[] alpha_enhanced = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".toCharArray();diff --git a/source/de/anomic/kelondro/kelondroBitfield.java b/source/de/anomic/kelondro/kelondroBitfield.javaindex bd0f1f305..5c03914f3 100644--- a/source/de/anomic/kelondro/kelondroBitfield.java+++ b/source/de/anomic/kelondro/kelondroBitfield.java@@ -70,7 +70,6 @@ public class kelondroBitfield implements Cloneable {System.arraycopy(bb, 0, nb, 0, bb.length);for (int i = bb.length; i < nb.length; i++) nb[i] = 0;bb = nb;- nb = null;}if (value) {bb[slot] = (byte) (bb[slot] | (1 << (pos % 8)));@@ -152,17 +151,17 @@ public class kelondroBitfield implements Cloneable {System.out.println("available: " + l);System.out.println("bevore: " + test.toString());for (int i = 0; i < l/2; i++) {- System.out.println(new String(test.exportB64()));+ System.out.println(test.exportB64());test.set(i, true);System.out.println(i + ":" + test.toString());}for (int i = l/2; i < l; i++) {- System.out.println(new String(test.exportB64()));+ System.out.println(test.exportB64());test = new kelondroBitfield(4, test.exportB64());test.set(i, true);System.out.println(i + ":" + test.toString());}- System.out.println(new String(test.exportB64()));+ System.out.println(test.exportB64());for (int i = l - 1; i >= 0; i--) {test.set(i, false);System.out.println(i + ":" + test.toString());diff --git a/source/de/anomic/kelondro/kelondroBufferedEcoFS.java b/source/de/anomic/kelondro/kelondroBufferedEcoFS.javaindex 1f90cb297..a8e359498 100644--- a/source/de/anomic/kelondro/kelondroBufferedEcoFS.java+++ b/source/de/anomic/kelondro/kelondroBufferedEcoFS.java@@ -77,14 +77,14 @@ public class kelondroBufferedEcoFS {efs = null;}- public synchronized void finalize() {+ protected synchronized void finalize() {if (this.efs != null) this.close();}public synchronized void get(final long index, final byte[] b, final int start) throws IOException {assert b.length - start >= efs.recordsize;if (index >= size()) throw new IndexOutOfBoundsException("kelondroBufferedEcoFS.get(" + index + ") outside bounds (" + this.size() + ")");- final byte[] bb = buffer.get(new Long(index));+ final byte[] bb = buffer.get(Long.valueOf(index));if (bb == null) {efs.get(index, b, start);} else {@@ -101,7 +101,7 @@ public class kelondroBufferedEcoFS {} else {final byte[] bb = new byte[efs.recordsize];System.arraycopy(b, start, bb, 0, efs.recordsize);- buffer.put(new Long(index), bb);+ buffer.put(Long.valueOf(index), bb);if (buffer.size() > this.maxEntries) flushBuffer();}}@@ -114,7 +114,7 @@ public class kelondroBufferedEcoFS {public synchronized void cleanLast(final byte[] b, final int start) throws IOException {assert b.length - start >= efs.recordsize;- final byte[] bb = buffer.remove(new Long(size() - 1));+ final byte[] bb = buffer.remove(Long.valueOf(size() - 1));if (bb == null) {efs.cleanLast(b, start);} else {@@ -124,7 +124,7 @@ public class kelondroBufferedEcoFS {}public synchronized void cleanLast() throws IOException {- buffer.remove(new Long(size() - 1));+ buffer.remove(Long.valueOf(size() - 1));efs.cleanLast();}diff --git a/source/de/anomic/kelondro/kelondroBufferedIOChunks.java b/source/de/anomic/kelondro/kelondroBufferedIOChunks.javaindex 3e24c6139..4964d9115 100644--- a/source/de/anomic/kelondro/kelondroBufferedIOChunks.java+++ b/source/de/anomic/kelondro/kelondroBufferedIOChunks.java@@ -72,7 +72,7 @@ public final class kelondroBufferedIOChunks extends kelondroAbstractIOChunks imp// do the readsynchronized (this.buffer) {- final byte[] bb = buffer.get(new Long(pos));+ final byte[] bb = buffer.get(Long.valueOf(pos));if (bb == null) {// entry not known, read directly from IOsynchronized (this.ra) {@@ -101,7 +101,7 @@ public final class kelondroBufferedIOChunks extends kelondroAbstractIOChunks impfinal byte[] bb = kelondroObjectSpace.alloc(len);System.arraycopy(b, off, bb, 0, len);synchronized (buffer) {- buffer.put(new Long(pos + off), bb);+ buffer.put(Long.valueOf(pos + off), bb);bufferCurrSize += overhead + len;}diff --git a/source/de/anomic/kelondro/kelondroByteArray.java b/source/de/anomic/kelondro/kelondroByteArray.javaindex bb0d8648b..2e7bb6f79 100644--- a/source/de/anomic/kelondro/kelondroByteArray.java+++ b/source/de/anomic/kelondro/kelondroByteArray.java@@ -70,7 +70,6 @@ public class kelondroByteArray {System.arraycopy(buffer, offset, newbuffer, 0, length);buffer = newbuffer;offset = 0;- newbuffer = null;}public void trim(final int needed) {@@ -80,7 +79,6 @@ public class kelondroByteArray {System.arraycopy(buffer, offset, newbuffer, 0, length);buffer = newbuffer;offset = 0;- newbuffer = null;}public final void removeShift(final int pos, final int dist, final int upBound) {diff --git a/source/de/anomic/kelondro/kelondroBytesIntMap.java b/source/de/anomic/kelondro/kelondroBytesIntMap.javaindex 20b939010..8ca540fd4 100644--- a/source/de/anomic/kelondro/kelondroBytesIntMap.java+++ b/source/de/anomic/kelondro/kelondroBytesIntMap.java@@ -94,7 +94,7 @@ public class kelondroBytesIntMap {while (ei.hasNext()) {i = (int) ei.next().getColLong(1);assert i < initialSize : "i = " + i + ", initialSize = " + initialSize;- is[c++] = new Integer(i);+ is[c++] = Integer.valueOf(i);}report.add(is);}diff --git a/source/de/anomic/kelondro/kelondroBytesLongMap.java b/source/de/anomic/kelondro/kelondroBytesLongMap.javaindex b6f61e400..6558a5ec0 100644--- a/source/de/anomic/kelondro/kelondroBytesLongMap.java+++ b/source/de/anomic/kelondro/kelondroBytesLongMap.java@@ -91,7 +91,7 @@ public class kelondroBytesLongMap {ei = rowset.rows();c = 0;while (ei.hasNext()) {- is[c++] = new Long(ei.next().getColLong(1));+ is[c++] = Long.valueOf(ei.next().getColLong(1));}report.add(is);}diff --git a/source/de/anomic/kelondro/kelondroCachedRA.java b/source/de/anomic/kelondro/kelondroCachedRA.javaindex b7c26279f..35eb3f7e2 100644--- a/source/de/anomic/kelondro/kelondroCachedRA.java+++ b/source/de/anomic/kelondro/kelondroCachedRA.java@@ -67,7 +67,7 @@ public class kelondroCachedRA extends kelondroAbstractRA implements kelondroRA {}private byte[] readCache(final int cacheNr) throws IOException {- final Integer cacheNrI = new Integer(cacheNr);+ final Integer cacheNrI = Integer.valueOf(cacheNr);byte[] cache = cacheMemory.get(cacheNrI);if (cache == null) {if (cacheMemory.size() >= cacheMaxElements) {@@ -82,7 +82,7 @@ public class kelondroCachedRA extends kelondroAbstractRA implements kelondroRA {// add new elementcache = new byte[cacheElementSize];//System.out.println("buffernr=" + bufferNr + ", elSize=" + bufferElementSize);- ra.seek(cacheNr * cacheElementSize);+ ra.seek(cacheNr * (long) cacheElementSize);ra.read(cache, 0, cacheElementSize);cacheMemory.put(cacheNrI, cache);}@@ -92,8 +92,8 @@ public class kelondroCachedRA extends kelondroAbstractRA implements kelondroRA {private void writeCache(final byte[] cache, final int cacheNr) throws IOException {if (cache == null) return;- final Integer cacheNrI = new Integer(cacheNr);- ra.seek(cacheNr * cacheElementSize);+ final Integer cacheNrI = Integer.valueOf(cacheNr);+ ra.seek(cacheNr * (long) cacheElementSize);ra.write(cache, 0, cacheElementSize);cacheScore.setScore(cacheNrI, (int) (0xFFFFFFFFL & System.currentTimeMillis()));}@@ -175,7 +175,7 @@ public class kelondroCachedRA extends kelondroAbstractRA implements kelondroRA {cacheMemory = null;}- public void finalize() {+ protected void finalize() {try {close();} catch (final IOException e) {}diff --git a/source/de/anomic/kelondro/kelondroCachedRecords.java b/source/de/anomic/kelondro/kelondroCachedRecords.javaindex 9f56b54f9..0f3557de8 100644--- a/source/de/anomic/kelondro/kelondroCachedRecords.java+++ b/source/de/anomic/kelondro/kelondroCachedRecords.java@@ -419,7 +419,6 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements kethis.tailChunk = new byte[tailchunksize];System.arraycopy(chunkbuffer, 0, this.headChunk, 0, headchunksize);System.arraycopy(chunkbuffer, headchunksize, this.tailChunk, 0, tailchunksize);- chunkbuffer = null;} else {// read overhead and keythis.headChunk = new byte[headchunksize];@@ -440,7 +439,6 @@ public class kelondroCachedRecords extends kelondroAbstractRecords implements kethis.tailChunk = new byte[tailchunksize];System.arraycopy(chunkbuffer, 0, this.headChunk, 0, headchunksize);System.arraycopy(chunkbuffer, headchunksize, this.tailChunk, 0, tailchunksize);- chunkbuffer = null;} else {// read overhead and keythis.headChunk = new byte[headchunksize];diff --git a/source/de/anomic/kelondro/kelondroColumn.java b/source/de/anomic/kelondro/kelondroColumn.javaindex de5ba05f1..abd7b48bf 100644--- a/source/de/anomic/kelondro/kelondroColumn.java+++ b/source/de/anomic/kelondro/kelondroColumn.java@@ -180,7 +180,7 @@ public class kelondroColumn {if ((celldef.length() > 0) && (celldef.charAt(0) == '"')) {p = celldef.indexOf('"', 1);this.description = celldef.substring(1, p);- celldef = celldef.substring(p + 1).trim();+ //unused: celldef = celldef.substring(p + 1).trim();} else {this.description = this.nickname;}@@ -241,12 +241,53 @@ public class kelondroColumn {return new String(s);}- public boolean equals(final kelondroColumn otherCol) {- return- (this.celltype == otherCol.celltype) &&- (this.cellwidth == otherCol.cellwidth) &&- (this.encoder == otherCol.encoder) &&- (this.nickname.equals(otherCol.nickname));- }+ /* (non-Javadoc)+ * @see java.lang.Object#hashCode()+ */+ @Override+ public int hashCode() {+ final int prime = 31;+ int result = 1;+ result = prime * result + celltype;+ result = prime * result + cellwidth;+ result = prime * result + encoder;+ result = prime * result+ + ((nickname == null) ? 0 : nickname.hashCode());+ return result;+ }++ /* (non-Javadoc)+ * @see java.lang.Object#equals(java.lang.Object)+ */+ @Override+ public boolean equals(Object obj) {+ if (this == obj)+ return true;+ if (obj == null)+ return false;+ if (!(obj instanceof kelondroColumn))+ return false;+ kelondroColumn other = (kelondroColumn) obj;+ if (celltype != other.celltype)+ return false;+ if (cellwidth != other.cellwidth)+ return false;+ if (encoder != other.encoder)+ return false;+ if (nickname == null) {+ if (other.nickname != null)+ return false;+ } else if (!nickname.equals(other.nickname))+ return false;+ return true;+ }++// public boolean equals(final kelondroColumn otherCol) {+// return+// (this.celltype == otherCol.celltype) &&+// (this.cellwidth == otherCol.cellwidth) &&+// (this.encoder == otherCol.encoder) &&+// (this.nickname.equals(otherCol.nickname));+// }}diff --git a/source/de/anomic/kelondro/kelondroEcoFS.java b/source/de/anomic/kelondro/kelondroEcoFS.javaindex 387a4c9d7..02c738779 100644--- a/source/de/anomic/kelondro/kelondroEcoFS.java+++ b/source/de/anomic/kelondro/kelondroEcoFS.java@@ -202,7 +202,8 @@ public class kelondroEcoFS {// copy records from file to cacheraf.seek(this.recordsize * index);- raf.read(this.cache, 0, this.recordsize * this.cachecount);+ final int bytesRead = raf.read(this.cache, 0, this.recordsize * this.cachecount);+ assert bytesRead == this.recordsize * this.cachecount;}/**diff --git a/source/de/anomic/kelondro/kelondroEcoTable.java b/source/de/anomic/kelondro/kelondroEcoTable.javaindex 2300a82eb..8e386a751 100644--- a/source/de/anomic/kelondro/kelondroEcoTable.java+++ b/source/de/anomic/kelondro/kelondroEcoTable.java@@ -332,7 +332,7 @@ public class kelondroEcoTable implements kelondroIndex {file = null;}- public void finalize() {+ protected void finalize() {if (this.file != null) this.close();}diff --git a/source/de/anomic/kelondro/kelondroFlexTable.java b/source/de/anomic/kelondro/kelondroFlexTable.javaindex b8f4a2e2d..f7f8f06e3 100644--- a/source/de/anomic/kelondro/kelondroFlexTable.java+++ b/source/de/anomic/kelondro/kelondroFlexTable.java@@ -250,7 +250,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrif (pos < 0) {new_rows_sequential.add(row);} else {- old_rows_ordered.put(new Integer(pos), row);+ old_rows_ordered.put(Integer.valueOf(pos), row);}}// overwrite existing entries in indexdiff --git a/source/de/anomic/kelondro/kelondroFlexWidthArray.java b/source/de/anomic/kelondro/kelondroFlexWidthArray.javaindex 16d8196fb..8dfae9f1f 100644--- a/source/de/anomic/kelondro/kelondroFlexWidthArray.java+++ b/source/de/anomic/kelondro/kelondroFlexWidthArray.java@@ -293,10 +293,10 @@ public class kelondroFlexWidthArray implements kelondroArray {while (c < rowdef.columns()) {e = col[c].row().newEntry(reb, rowdef.colstart[c], false);// remember write to column, but do not write directly- colm[c].put(new Integer(index), e); // col[c].set(index,e);+ colm[c].put(Integer.valueOf(index), e); // col[c].set(index,e);c = c + col[c].row().columns();}- indexref.put(new Integer(index), rowentry.getColBytes(0));+ indexref.put(Integer.valueOf(index), rowentry.getColBytes(0));}// write the other columnsfor (int j = 1; j < col.length; j++) {diff --git a/source/de/anomic/kelondro/kelondroHandle.java b/source/de/anomic/kelondro/kelondroHandle.javaindex f5bd87d45..bc380fa6e 100644--- a/source/de/anomic/kelondro/kelondroHandle.java+++ b/source/de/anomic/kelondro/kelondroHandle.java@@ -58,7 +58,7 @@ public class kelondroHandle implements Comparable<kelondroHandle> {public boolean equals(final Object h) {assert (index != NUL);- assert (((kelondroHandle) h).index != NUL);+ assert (h instanceof kelondroHandle && ((kelondroHandle) h).index != NUL);return (h instanceof kelondroHandle && this.index == ((kelondroHandle) h).index);}diff --git a/source/de/anomic/kelondro/kelondroHashtable.java b/source/de/anomic/kelondro/kelondroHashtable.javaindex 285830182..d0f57339c 100644--- a/source/de/anomic/kelondro/kelondroHashtable.java+++ b/source/de/anomic/kelondro/kelondroHashtable.java@@ -205,13 +205,13 @@ public class kelondroHashtable {int rowNumber;do {rowNumber = hash.node();- if (rowNumber >= hashArray.size()) return new Object[]{new Integer(rowNumber), null};+ if (rowNumber >= hashArray.size()) return new Object[]{Integer.valueOf(rowNumber), null};hkrow = hashArray.get(rowNumber);rowKey = (int) hkrow.getColLong(0);- if (rowKey == 0) return new Object[]{new Integer(rowNumber), null};+ if (rowKey == 0) return new Object[]{Integer.valueOf(rowNumber), null};hash.rehash();} while (rowKey != hash.key());- return new Object[]{new Integer(rowNumber), hkrow};+ return new Object[]{Integer.valueOf(rowNumber), hkrow};}diff --git a/source/de/anomic/kelondro/kelondroIntBytesMap.java b/source/de/anomic/kelondro/kelondroIntBytesMap.javaindex 02e900069..a89132de8 100644--- a/source/de/anomic/kelondro/kelondroIntBytesMap.java+++ b/source/de/anomic/kelondro/kelondroIntBytesMap.java@@ -187,17 +187,16 @@ public class kelondroIntBytesMap {index1 = new kelondroRowSet(rowdef, 0);}return index0.rows(true, null);- }- assert (index1 != null);- if (index0 == null) {+ } else {+ assert (index1 != null);return index1.rows(true, null);}- return new kelondroMergeIterator<kelondroRow.Entry>(- index0.rows(true, null),- index1.rows(true, null),- entryOrder,- kelondroMergeIterator.simpleMerge,- true);+// return new kelondroMergeIterator<kelondroRow.Entry>(+// index0.rows(true, null),+// index1.rows(true, null),+// entryOrder,+// kelondroMergeIterator.simpleMerge,+// true);}public void flush() {@@ -233,9 +232,9 @@ public class kelondroIntBytesMap {for (int i = 0; i < 1000000; i++) {r = Math.abs(random.nextLong() % 10000);//System.out.println("add " + r);- jcontrol.add(new Long(r));+ jcontrol.add(Long.valueOf(r));kcontrol.putb((int) r, "x".getBytes());- if (random.nextLong() % 5 == 0) ra.add(new Long(r));+ if (random.nextLong() % 5 == 0) ra.add(Long.valueOf(r));if ((ra.size() > 0) && (random.nextLong() % 7 == 0)) {rc++;p = Math.abs(random.nextInt() % ra.size());diff --git a/source/de/anomic/kelondro/kelondroMHashMap.java b/source/de/anomic/kelondro/kelondroMHashMap.javaindex fb141f2b3..eb331a198 100644--- a/source/de/anomic/kelondro/kelondroMHashMap.java+++ b/source/de/anomic/kelondro/kelondroMHashMap.java@@ -164,7 +164,6 @@ public class kelondroMHashMap {System.arraycopy(value, 0, newmem, mempos + keylen, valuelen);// move newmem to memmem = newmem;- newmem = null;}} else {// there is enough spacediff --git a/source/de/anomic/kelondro/kelondroMScoreCluster.java b/source/de/anomic/kelondro/kelondroMScoreCluster.javaindex 2ace44a3a..dfca15cce 100644--- a/source/de/anomic/kelondro/kelondroMScoreCluster.java+++ b/source/de/anomic/kelondro/kelondroMScoreCluster.java@@ -105,7 +105,6 @@ public final class kelondroMScoreCluster<E> {c += plainByteArray[(byte) s.charAt(i)];}for (int i = len; i < 5; i++) c <<= 6;- if (c > Integer.MAX_VALUE) return Integer.MAX_VALUE;if (c < 0) {System.out.println("string2score: negative score for input " + s);return 0;@@ -158,7 +157,7 @@ public final class kelondroMScoreCluster<E> {if (usk == null) {// set new value- usk = new Long(scoreKey(encnt++, newScore));+ usk = Long.valueOf(scoreKey(encnt++, newScore));// put new value into clusterrefkeyDB.put(obj, usk);@@ -175,7 +174,7 @@ public final class kelondroMScoreCluster<E> {gcount -= oldScore;// set new value- usk = new Long(scoreKey(oldHandle, newScore)); // generates an unique key for a specific score+ usk = Long.valueOf(scoreKey(oldHandle, newScore)); // generates an unique key for a specific scorerefkeyDB.put(obj, usk);keyrefDB.put(usk, obj);}@@ -192,7 +191,7 @@ public final class kelondroMScoreCluster<E> {if (usk == null) {// set new valueif (incrementScore < 0) throw new kelondroOutOfLimitsException(incrementScore);- usk = new Long(scoreKey(encnt++, incrementScore));+ usk = Long.valueOf(scoreKey(encnt++, incrementScore));// put new value into clusterrefkeyDB.put(obj, usk);@@ -210,7 +209,7 @@ public final class kelondroMScoreCluster<E> {// set new valuefinal int newValue = oldScore + incrementScore;if (newValue < 0) throw new kelondroOutOfLimitsException(newValue);- usk = new Long(scoreKey(oldHandle, newValue)); // generates an unique key for a specific score+ usk = Long.valueOf(scoreKey(oldHandle, newValue)); // generates an unique key for a specific scorerefkeyDB.put(obj, usk);keyrefDB.put(usk, obj);@@ -288,7 +287,6 @@ public final class kelondroMScoreCluster<E> {E[] sc = (E[]) new Object[i];System.arraycopy(s, 0, sc, 0, i);s = sc;- sc = null;}return s;}diff --git a/source/de/anomic/kelondro/kelondroMSetTools.java b/source/de/anomic/kelondro/kelondroMSetTools.javaindex c70ec11b2..b5478d982 100644--- a/source/de/anomic/kelondro/kelondroMSetTools.java+++ b/source/de/anomic/kelondro/kelondroMSetTools.java@@ -77,7 +77,7 @@ public class kelondroMSetTools {if ((singleMap == null) || (singleMap.size() == 0)) return new TreeMap<A, B>();// store result in order of result size- orderMap.put(new Long(singleMap.size() * 1000 + count), singleMap);+ orderMap.put(Long.valueOf(singleMap.size() * 1000 + count), singleMap);count++;}diff --git a/source/de/anomic/kelondro/kelondroMapDataMining.java b/source/de/anomic/kelondro/kelondroMapDataMining.javaindex fbfc6dcd8..c661a645e 100644--- a/source/de/anomic/kelondro/kelondroMapDataMining.java+++ b/source/de/anomic/kelondro/kelondroMapDataMining.java@@ -41,7 +41,7 @@ public class kelondroMapDataMining extends kelondroMap {private HashMap<String, Object> accMap; // to store accumulations of specific fieldsprivate int elementCount;- @SuppressWarnings({ "unchecked", "null" })+ @SuppressWarnings("unchecked")public kelondroMapDataMining(final kelondroBLOB dyn, final int cachesize, final String[] sortfields, final String[] longaccfields, final String[] doubleaccfields, final Method externalInitializer, final Object externalHandler) {super(dyn, cachesize);@@ -68,13 +68,13 @@ public class kelondroMapDataMining extends kelondroMap {if (longaccfields != null) {longaccumulator = new Long[longaccfields.length];for (int i = 0; i < longaccfields.length; i++) {- longaccumulator[i] = new Long(0);+ longaccumulator[i] = Long.valueOf(0);}}if (doubleaccfields != null) {doubleaccumulator = new Double[doubleaccfields.length];for (int i = 0; i < doubleaccfields.length; i++) {- doubleaccumulator[i] = new Double(0);+ doubleaccumulator[i] = Double.valueOf(0);}}}@@ -90,25 +90,25 @@ public class kelondroMapDataMining extends kelondroMap {this.elementCount = 0;while (it.hasNext()) {mapname = new String(it.next());- map = super.get(new String(mapname));+ map = super.get(mapname);if (map == null) break;- if (sortfields != null) for (int i = 0; i < sortfields.length; i++) {+ if (sortfields != null && cluster != null) for (int i = 0; i < sortfields.length; i++) {cell = map.get(sortfields[i]);if (cell != null) cluster[i].setScore(mapname, kelondroMScoreCluster.object2score(cell));}- if (longaccfields != null) for (int i = 0; i < longaccfields.length; i++) {+ if (longaccfields != null && longaccumulator != null) for (int i = 0; i < longaccfields.length; i++) {cell = map.get(longaccfields[i]);valuel = 0;if (cell != null) try {if (cell instanceof Long) valuel = ((Long) cell).longValue();if (cell instanceof String) valuel = Long.parseLong((String) cell);- longaccumulator[i] = new Long(longaccumulator[i].longValue() + valuel);+ longaccumulator[i] = Long.valueOf(longaccumulator[i].longValue() + valuel);} catch (final NumberFormatException e) {}}- if (doubleaccfields != null) for (int i = 0; i < doubleaccfields.length; i++) {+ if (doubleaccfields != null && doubleaccumulator != null) for (int i = 0; i < doubleaccfields.length; i++) {cell = map.get(doubleaccfields[i]);valued = 0d;if (cell != null) try {@@ -134,14 +134,14 @@ public class kelondroMapDataMining extends kelondroMap {} catch (final IOException e) {}// fill cluster- if (sortfields != null) for (int i = 0; i < sortfields.length; i++) sortClusterMap.put(sortfields[i], cluster[i]);+ if (sortfields != null && cluster != null) for (int i = 0; i < sortfields.length; i++) sortClusterMap.put(sortfields[i], cluster[i]);// fill acc map- if (longaccfields != null) for (int i = 0; i < longaccfields.length; i++) accMap.put(longaccfields[i], longaccumulator[i]);- if (doubleaccfields != null) for (int i = 0; i < doubleaccfields.length; i++) accMap.put(doubleaccfields[i], doubleaccumulator[i]);+ if (longaccfields != null && longaccumulator != null) for (int i = 0; i < longaccfields.length; i++) accMap.put(longaccfields[i], longaccumulator[i]);+ if (doubleaccfields != null && doubleaccumulator != null) for (int i = 0; i < doubleaccfields.length; i++) accMap.put(doubleaccfields[i], doubleaccumulator[i]);}- public void clear() throws IOException {+ public synchronized void clear() throws IOException {super.clear();if (sortfields == null) sortClusterMap = null; else {sortClusterMap = new HashMap<String, kelondroMScoreCluster<String>>();@@ -156,7 +156,7 @@ public class kelondroMapDataMining extends kelondroMap {accMap = new HashMap<String, Object>();if (longaccfields != null) {for (int i = 0; i < longaccfields.length; i++) {- accMap.put(longaccfields[i], new Long(0));+ accMap.put(longaccfields[i], Long.valueOf(0));}}if (doubleaccfields != null) {@@ -207,9 +207,9 @@ public class kelondroMapDataMining extends kelondroMap {valuel = Long.parseLong(value);longaccumulator = (Long) accMap.get(longaccfields[i]);if (add) {- accMap.put(longaccfields[i], new Long(longaccumulator.longValue() + valuel));+ accMap.put(longaccfields[i], Long.valueOf(longaccumulator.longValue() + valuel));} else {- accMap.put(longaccfields[i], new Long(longaccumulator.longValue() - valuel));+ accMap.put(longaccfields[i], Long.valueOf(longaccumulator.longValue() - valuel));}} catch (final NumberFormatException e) {}}@@ -282,7 +282,7 @@ public class kelondroMapDataMining extends kelondroMap {return new string2bytearrayIterator(cluster.scores(up));}- public class string2bytearrayIterator implements Iterator<byte[]> {+ public static class string2bytearrayIterator implements Iterator<byte[]> {Iterator<String> s;diff --git a/source/de/anomic/kelondro/kelondroObjectSpace.java b/source/de/anomic/kelondro/kelondroObjectSpace.javaindex d00443c92..0e4c0a695 100644--- a/source/de/anomic/kelondro/kelondroObjectSpace.java+++ b/source/de/anomic/kelondro/kelondroObjectSpace.java@@ -38,18 +38,18 @@ public class kelondroObjectSpace {//private static TreeMap aliveMax = new TreeMap();private static void incAlive(final int size) {- final Integer s = new Integer(size);+ final Integer s = Integer.valueOf(size);synchronized (aliveNow) {final Integer x = aliveNow.get(s);- if (x == null) aliveNow.put(s, new Integer(1)); else aliveNow.put(s, new Integer(x.intValue() + 1));+ if (x == null) aliveNow.put(s, Integer.valueOf(1)); else aliveNow.put(s, Integer.valueOf(x.intValue() + 1));}}private static void decAlive(final int size) {- final Integer s = new Integer(size);+ final Integer s = Integer.valueOf(size);synchronized (aliveNow) {final Integer x = aliveNow.get(s);- if (x == null) aliveNow.put(s, new Integer(-1)); else aliveNow.put(s, new Integer(x.intValue() - 1));+ if (x == null) aliveNow.put(s, Integer.valueOf(-1)); else aliveNow.put(s, Integer.valueOf(x.intValue() - 1));}}@@ -57,7 +57,7 @@ public class kelondroObjectSpace {if ((len < minSize) || (len > maxSize)) return new byte[len];incAlive(len);synchronized (objHeap) {- final ArrayList<byte[]> buf = objHeap.get(new Integer(len));+ final ArrayList<byte[]> buf = objHeap.get(Integer.valueOf(len));if ((buf == null) || (buf.size() == 0)) return new byte[len];return buf.remove(buf.size() - 1);}@@ -69,7 +69,7 @@ public class kelondroObjectSpace {}decAlive(b.length);synchronized (objHeap) {- final Integer i = new Integer(b.length);+ final Integer i = Integer.valueOf(b.length);ArrayList<byte[]> buf = objHeap.get(i);if (buf == null) {buf = new ArrayList<byte[]>();@@ -95,7 +95,7 @@ public class kelondroObjectSpace {Map.Entry<Integer, ArrayList<byte[]>> entry;while (i.hasNext()) {entry = i.next();- result.put(entry.getKey(), new Integer(entry.getValue().size()));+ result.put(entry.getKey(), Integer.valueOf(entry.getValue().size()));}}return result;diff --git a/source/de/anomic/kelondro/kelondroRow.java b/source/de/anomic/kelondro/kelondroRow.javaindex 9ae003db4..dee5201d2 100644--- a/source/de/anomic/kelondro/kelondroRow.java+++ b/source/de/anomic/kelondro/kelondroRow.java@@ -69,7 +69,8 @@ public final class kelondroRow {//# Structure=<pivot-12>,'=',<UDate-3>,<VDate-3>,<LCount-2>,<GCount-2>,<ICount-2>,<DCount-2>,<TLength-3>,<WACount-3>,<WUCount-3>,<Flags-1>// parse pivot definition:- structure.replace('=', ',');+ //does not work with 'String idx-26 "id = created + originator",String cat-8,String rec-14,short dis-2 {b64e},String att-462'+ //structure = structure.replace('=', ',');// parse property part definition:int p = structure.indexOf('|');@@ -108,7 +109,7 @@ public final class kelondroRow {protected final void genNickRef() {if (nickref != null) return;nickref = new HashMap<String, Object[]>(row.length);- for (int i = 0; i < row.length; i++) nickref.put(row[i].nickname, new Object[]{row[i], new Integer(colstart[i])});+ for (int i = 0; i < row.length; i++) nickref.put(row[i].nickname, new Object[]{row[i], Integer.valueOf(colstart[i])});}public final int columns() {@@ -191,7 +192,7 @@ public final class kelondroRow {return new EntryIndex(rowinstance, index);}- public static class EntryComparator extends kelondroAbstractOrder<Entry> implements kelondroOrder<Entry>, Comparator<Entry> {+ public static class EntryComparator extends kelondroAbstractOrder<Entry> implements kelondroOrder<Entry>, Comparator<Entry>, Cloneable {kelondroByteOrder base;public EntryComparator(final kelondroByteOrder baseOrder) {diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.javaindex 48ff0dad2..4c93f696a 100644--- a/source/de/anomic/kelondro/kelondroRowCollection.java+++ b/source/de/anomic/kelondro/kelondroRowCollection.java@@ -49,7 +49,7 @@ public class kelondroRowCollection {public static final double growfactor = 1.4;private static final int isortlimit = 20;- static final Integer dummy = new Integer(0);+ static final Integer dummy = 0;public static final ExecutorService sortingthreadexecutor = (serverProcessor.useCPU > 1) ? Executors.newCachedThreadPool(new NamePrefixThreadFactory("sorting")) : null;public static final ExecutorService partitionthreadexecutor = (serverProcessor.useCPU > 1) ? Executors.newCachedThreadPool(new NamePrefixThreadFactory("partition")) : null;@@ -185,16 +185,23 @@ public class kelondroRowCollection {public static kelondroRowCollection importCollection(final InputStream is, final kelondroRow rowdef) throws IOException {final byte[] byte2 = new byte[2];final byte[] byte4 = new byte[4];- is.read(byte4); final int size = (int) kelondroNaturalOrder.decodeLong(byte4);- is.read(byte2); //short lastread = (short) kelondroNaturalOrder.decodeLong(byte2);- is.read(byte2); //short lastwrote = (short) kelondroNaturalOrder.decodeLong(byte2);- is.read(byte2); //String orderkey = new String(byte2);- is.read(byte2); final short ordercol = (short) kelondroNaturalOrder.decodeLong(byte2);- is.read(byte2); final short orderbound = (short) kelondroNaturalOrder.decodeLong(byte2);+ int bytesRead;+ bytesRead = is.read(byte4); final int size = (int) kelondroNaturalOrder.decodeLong(byte4);+ assert bytesRead == byte4.length;+ bytesRead = is.read(byte2); //short lastread = (short) kelondroNaturalOrder.decodeLong(byte2);+ assert bytesRead == byte2.length;+ bytesRead = is.read(byte2); //short lastwrote = (short) kelondroNaturalOrder.decodeLong(byte2);+ assert bytesRead == byte2.length;+ bytesRead = is.read(byte2); //String orderkey = new String(byte2);+ assert bytesRead == byte2.length;+ bytesRead = is.read(byte2); final short ordercol = (short) kelondroNaturalOrder.decodeLong(byte2);+ assert bytesRead == byte2.length;+ bytesRead = is.read(byte2); final short orderbound = (short) kelondroNaturalOrder.decodeLong(byte2);+ assert bytesRead == byte2.length;assert rowdef.primaryKeyIndex == ordercol;final byte[] chunkcache = new byte[size * rowdef.objectsize];- final int c = is.read(chunkcache);- assert c == chunkcache.length;+ bytesRead = is.read(chunkcache);+ assert bytesRead == chunkcache.length;return new kelondroRowCollection(rowdef, size, chunkcache, orderbound);}@@ -212,7 +219,6 @@ public class kelondroRowCollection {byte[] newChunkcache = new byte[(int) (needed * growfactor)]; // increase spaceSystem.arraycopy(chunkcache, 0, newChunkcache, 0, chunkcache.length);chunkcache = newChunkcache;- newChunkcache = null;}public final long memoryNeededForGrow() {@@ -234,7 +240,6 @@ public class kelondroRowCollection {System.arraycopy(chunkcache, 0, newChunkcache, 0, Math.min(chunkcache.length, newChunkcache.length));chunkcache = newChunkcache;- newChunkcache = null;}public final long lastRead() {@@ -317,7 +322,7 @@ public class kelondroRowCollection {private final boolean addUnique(final byte[] a, final int astart, final int alength) {assert (a != null);- assert (astart >= 0) && (astart < a.length) : " astart = " + a;+ assert (astart >= 0) && (astart < a.length) : " astart = " + astart;assert (!(serverLog.allZero(a, astart, alength))) : "a = " + serverLog.arrayList(a, astart, alength);assert (alength > 0);assert (astart + alength <= a.length);@@ -601,7 +606,7 @@ public class kelondroRowCollection {}public Integer call() throws Exception {- return new Integer(rc.partition(L, R, S, new byte[rc.rowdef.objectsize]));+ return Integer.valueOf(rc.partition(L, R, S, new byte[rc.rowdef.objectsize]));}}@@ -701,7 +706,7 @@ public class kelondroRowCollection {}private final int picMiddle(final int[] list, int len) {- assert len % 2 == 1;+ assert len % 2 != 0;assert len <= list.length;final int cut = list.length / 2;for (int i = 0; i < cut; i++) {remove(list, len, min(list, len)); len--;}diff --git a/source/de/anomic/kelondro/kelondroSQLTable.java b/source/de/anomic/kelondro/kelondroSQLTable.javaindex 48850bed7..b42ee4595 100644--- a/source/de/anomic/kelondro/kelondroSQLTable.java+++ b/source/de/anomic/kelondro/kelondroSQLTable.java@@ -50,14 +50,14 @@ import java.util.List;public class kelondroSQLTable implements kelondroIndex {- private final String db_driver_str_mysql = "org.gjt.mm.mysql.Driver";- private final String db_driver_str_pgsql = "org.postgresql.Driver";+ private static final String db_driver_str_mysql = "org.gjt.mm.mysql.Driver";+ private static final String db_driver_str_pgsql = "org.postgresql.Driver";- private final String db_conn_str_mysql = "jdbc:mysql://192.168.0.2:3306/yacy";- private final String db_conn_str_pgsql = "jdbc:postgresql://192.168.0.2:5432";+ private static final String db_conn_str_mysql = "jdbc:mysql://192.168.0.2:3306/yacy";+ private static final String db_conn_str_pgsql = "jdbc:postgresql://192.168.0.2:5432";- private final String db_usr_str = "yacy";- private final String db_pwd_str = "yacy";+ private static final String db_usr_str = "yacy";+ private static final String db_pwd_str = "yacy";private Connection theDBConnection = null;private final kelondroByteOrder order = new kelondroNaturalOrder(true);@@ -109,10 +109,7 @@ public class kelondroSQLTable implements kelondroIndex {public int size() {int size = -1;try {- final String sqlQuery = new String- (- "SELECT count(value) from test"- );+ final String sqlQuery = "SELECT count(value) from test";final PreparedStatement sqlStatement = this.theDBConnection.prepareStatement(sqlQuery);final ResultSet result = sqlStatement.executeQuery();@@ -149,10 +146,7 @@ public class kelondroSQLTable implements kelondroIndex {public kelondroRow.Entry get(final byte[] key) throws IOException {try {- final String sqlQuery = new String- (- "SELECT value from test where hash = ?"- );+ final String sqlQuery = "SELECT value from test where hash = ?";final PreparedStatement sqlStatement = this.theDBConnection.prepareStatement(sqlQuery);sqlStatement.setString(1, new String(key));@@ -188,18 +182,15 @@ public class kelondroSQLTable implements kelondroIndex {final kelondroRow.Entry oldEntry = remove(row.getColBytes(0));- final String sqlQuery = new String- (- "INSERT INTO test (" ++ final String sqlQuery = "INSERT INTO test (" +"hash, " +"value) " +- "VALUES (?,?)"- );+ "VALUES (?,?)";final PreparedStatement sqlStatement = this.theDBConnection.prepareStatement(sqlQuery);- sqlStatement.setString(1, new String(row.getColString(0, null)));+ sqlStatement.setString(1, row.getColString(0, null));sqlStatement.setBytes(2, row.bytes());sqlStatement.execute();@@ -224,24 +215,30 @@ public class kelondroSQLTable implements kelondroIndex {}public kelondroRow.Entry remove(final byte[] key) throws IOException {+ PreparedStatement sqlStatement = null;try {final kelondroRow.Entry entry = this.get(key);- if (entry == null) return entry;+ if (entry == null) return null;- final String sqlQuery = new String- (- "DELETE FROM test WHERE hash = ?"- );+ final String sqlQuery = "DELETE FROM test WHERE hash = ?";- final PreparedStatement sqlStatement = this.theDBConnection.prepareStatement(sqlQuery);+ sqlStatement = this.theDBConnection.prepareStatement(sqlQuery);sqlStatement.setString(1, new String(key));sqlStatement.execute();return entry;} catch (final Exception e) {throw new IOException(e.getMessage());+ } finally {+ if(sqlStatement != null) {+ try {+ sqlStatement.close();+ } catch (SQLException e) {+ e.printStackTrace();+ }+ }}}diff --git a/source/de/anomic/kelondro/kelondroSortStack.java b/source/de/anomic/kelondro/kelondroSortStack.javaindex d8beec6bb..181c5563f 100644--- a/source/de/anomic/kelondro/kelondroSortStack.java+++ b/source/de/anomic/kelondro/kelondroSortStack.java@@ -61,13 +61,13 @@ public class kelondroSortStack<E> {if (exists(element)) return;// manipulate weight in such a way that it has no conflicts- while (this.onstack.containsKey(weight)) weight = new Long(weight.longValue() + 1);+ while (this.onstack.containsKey(weight)) weight = Long.valueOf(weight.longValue() + 1);// put the element on the stackthis.onstack.put(weight, element);// register it for double-check- this.instack.add(new Integer(element.hashCode()));+ this.instack.add(Integer.valueOf(element.hashCode()));// check maximum size of the stack an remove elements if the stack gets too largeif (this.maxsize <= 0) return;@@ -97,12 +97,12 @@ public class kelondroSortStack<E> {public boolean exists(final E element) {// uses the hashCode of the element to find out of the element had been on the list or the stack- return this.instack.contains(new Integer(element.hashCode()));+ return this.instack.contains(Integer.valueOf(element.hashCode()));}public boolean exists(final int hashcode) {// uses the hashCode of the element to find out of the element had been on the list or the stack- return this.instack.contains(new Integer(hashcode));+ return this.instack.contains(Integer.valueOf(hashcode));}public stackElement get(final int hashcode) {diff --git a/source/de/anomic/kelondro/kelondroSplitTable.java b/source/de/anomic/kelondro/kelondroSplitTable.javaindex 7d7a11490..682f79cd4 100644--- a/source/de/anomic/kelondro/kelondroSplitTable.java+++ b/source/de/anomic/kelondro/kelondroSplitTable.java@@ -105,7 +105,7 @@ public class kelondroSplitTable implements kelondroIndex {ram = kelondroEcoTable.staticRAMIndexNeed(f, rowdef);}if (ram > 0) {- t.put(tablefile[i], new Long(ram));+ t.put(tablefile[i], Long.valueOf(ram));sum += ram;}}diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.javaindex 9db2079b6..929da4af7 100644--- a/source/de/anomic/kelondro/kelondroTree.java+++ b/source/de/anomic/kelondro/kelondroTree.java@@ -880,7 +880,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexwhile ((c = row().objectOrder.compare(startKey, searchNode.getKey())) != 0) {// the current 'thisNode' is not the start node, put it on the stackct = (c < 0) ? leftchild : rightchild;- nodeStack.addLast(new Object[]{searchNode, new Integer(ct)});+ nodeStack.addLast(new Object[]{searchNode, Integer.valueOf(ct)});// go to next nodesearchHandle = searchNode.getOHHandle(ct);@@ -914,7 +914,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex//System.out.println("go to other leg, stack size=" + nodeStack.size());// we have walked one leg of the tree; now go to the other one: step down to next childfinal HashSet<kelondroHandle> visitedNodeHandles = new HashSet<kelondroHandle>(); // to detect loops- nodeStack.addLast(new Object[]{nextNode, new Integer(childtype)});+ nodeStack.addLast(new Object[]{nextNode, Integer.valueOf(childtype)});nextNode = new CacheNode(childHandle, nextNode, childtype, false);childtype = (up) ? leftchild : rightchild;while ((childHandle = nextNode.getOHHandle(childtype)) != null) {@@ -927,7 +927,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex}visitedNodeHandles.add(childHandle);try {- nodeStack.addLast(new Object[]{nextNode, new Integer(childtype)});+ nodeStack.addLast(new Object[]{nextNode, Integer.valueOf(childtype)});nextNode = new CacheNode(childHandle, nextNode, childtype, false);} catch (final IllegalArgumentException e) {// return what we havediff --git a/source/de/anomic/kelondro/kelondroXMLTables.java b/source/de/anomic/kelondro/kelondroXMLTables.javaindex d2651d363..37a46522b 100644--- a/source/de/anomic/kelondro/kelondroXMLTables.java+++ b/source/de/anomic/kelondro/kelondroXMLTables.java@@ -160,13 +160,13 @@ public class kelondroXMLTables {}public void close() throws IOException {- finalize();+ commit(true);}// we finalize the operation by saving everything throug the scheduler// this method is called by the java GC bevore it destroys the objectprotected void finalize() throws IOException {- commit(true);+ close();}}diff --git a/source/de/anomic/language/identification/LanguageFilenameFilter.java b/source/de/anomic/language/identification/LanguageFilenameFilter.javaindex 053cc39b9..394c7c0a1 100644--- a/source/de/anomic/language/identification/LanguageFilenameFilter.java+++ b/source/de/anomic/language/identification/LanguageFilenameFilter.java@@ -29,7 +29,7 @@ import java.io.FilenameFilter;class LanguageFilenameFilter implements FilenameFilter {- private final String fileExtension = "lng";+ private static final String fileExtension = "lng";public boolean accept(final File dir, final String name) {if (name.matches(".+\\."+fileExtension)) {diff --git a/source/de/anomic/language/identification/LanguageStatistics.java b/source/de/anomic/language/identification/LanguageStatistics.javaindex 961a8f109..544cd97ea 100644--- a/source/de/anomic/language/identification/LanguageStatistics.java+++ b/source/de/anomic/language/identification/LanguageStatistics.java@@ -108,11 +108,16 @@ public class LanguageStatistics {boolean ret = true;BufferedReader reader = null;String line;- String splitLine[] = new String[2];+ String splitLine[];try {reader = new BufferedReader(new FileReader(file));while(reader.ready()) {- line = reader.readLine().trim();+ line = reader.readLine();+ if(line == null) {+ // end of file+ break;+ }+ line = line.trim();if (line.matches("^\\p{L}\\p{Z}+\\p{N}*\\p{P}{0,1}\\p{N}+$")) {splitLine = line.split("\\p{Z}+");this.put(splitLine[0].charAt(0), Float.parseFloat(splitLine[1]));diff --git a/source/de/anomic/language/identification/LanguageStatisticsHolder.java b/source/de/anomic/language/identification/LanguageStatisticsHolder.javaindex 073982c8c..5d8a0c6c5 100644--- a/source/de/anomic/language/identification/LanguageStatisticsHolder.java+++ b/source/de/anomic/language/identification/LanguageStatisticsHolder.java@@ -37,7 +37,7 @@ public class LanguageStatisticsHolder extends Vector<LanguageStatistics> {private static final long serialVersionUID = -887517724227204705L;- private final String languageDir = "langstats"; // directory that contains language files+ private static final String languageDir = "langstats"; // directory that contains language filesprivate static LanguageStatisticsHolder instance;diff --git a/source/de/anomic/net/ftpc.java b/source/de/anomic/net/ftpc.javaindex be30edc47..fd4552efa 100644--- a/source/de/anomic/net/ftpc.java+++ b/source/de/anomic/net/ftpc.java@@ -90,13 +90,13 @@ public class ftpc {private Socket ControlSocket = null;// socket timeout- private final int ControlSocketTimeout = 300000;+ private static final int ControlSocketTimeout = 300000;// data socket timeoutprivate int DataSocketTimeout = 0; // in seconds (default infinite)// minimal data rate (to calculate timeout with max. filesize)- private final int DataSocketRate = 100;// Byte/s+ private static final int DataSocketRate = 100;// Byte/s// socket for data transactionsprivate ServerSocket DataSocketActive = null;@@ -298,7 +298,7 @@ public class ftpc {return line1.split("\\|");}- class cl extends ClassLoader {+ static class cl extends ClassLoader {public cl() {super();@@ -372,7 +372,7 @@ public class ftpc {// invoke object.main()final Object result = m.invoke(null, argList);- parameterType = null;+ //parameterType = null;m = null;// handle result@@ -710,7 +710,7 @@ public class ftpc {}// return to last foldersend("CWD " + currentFolder);- reply = receive();+ /*reply =*/ receive();return true;} catch (final IOException e) {return false;@@ -1143,7 +1143,9 @@ public class ftpc {Date date;final String dateString = tokens.group(3) + " " + tokens.group(4) + " " + year + " " + time;try {- date = lsDateFormat.parse(dateString);+ synchronized(lsDateFormat) {+ date = lsDateFormat.parse(dateString);+ }} catch (final ParseException e) {errPrintln(logPrefix + "---- Error: not ls date-format '" + dateString + "': " + e.getMessage());date = new Date();@@ -1159,7 +1161,7 @@ public class ftpc {* @author danielr* @since 2008-03-13 r4558*/- private class entryInfo {+ private static class entryInfo {/*** is this a directory?*/@@ -1424,7 +1426,7 @@ public class ftpc {}// after stream is empty we should get control completion echo- reply = receive();+ /*reply =*/ receive();// boolean success = !isNotPositiveCompletion(reply);@@ -1485,7 +1487,8 @@ public class ftpc {local = new File(currentLocalPath, remote);if (local.exists()) {errPrintln("Warning: local file " + local.toString() + " overwritten.");- local.delete();+ if(!local.delete())+ errPrintln("Warning: local file " + local.toString() + " could not be deleted.");}retrieveFilesRecursively(remote, remove);}@@ -2282,7 +2285,7 @@ public class ftpc {}// after stream is empty we should get control completion echo- reply = receive();+ /*reply =*/ receive();// boolean success = !isNotPositiveCompletion(reply);} finally {// shutdown connection@@ -2696,7 +2699,7 @@ public class ftpc {}c.exec("open " + host, false);c.exec("user " + account + " " + password, false);- c.exec("lcd " + localPath.getAbsolutePath().toString(), false);+ c.exec("lcd " + localPath.getAbsolutePath(), false);c.exec("binary", false);c.exec("get " + remoteFile + " " + localPath.getAbsoluteFile().toString(), false);c.exec("close", false);diff --git a/source/de/anomic/net/whois.java b/source/de/anomic/net/whois.javaindex 5928c56d6..a2bceb0ee 100644--- a/source/de/anomic/net/whois.java+++ b/source/de/anomic/net/whois.java@@ -45,6 +45,7 @@ public class whois {result.setProperty(key, (oldValue == null) ? value : (oldValue + "; " + value));}}+ br.close();return result;} catch (final IOException e) {//e.printStackTrace();diff --git a/source/de/anomic/plasma/parser/mimeType/mimeTypeParser.java b/source/de/anomic/plasma/parser/mimeType/mimeTypeParser.javaindex 18843c41b..764f90f7e 100644--- a/source/de/anomic/plasma/parser/mimeType/mimeTypeParser.java+++ b/source/de/anomic/plasma/parser/mimeType/mimeTypeParser.java@@ -119,10 +119,10 @@ public class mimeTypeParser extends AbstractParser implements Parser {if (threadLoopDetection.containsKey(Thread.currentThread())) {loopDepth = threadLoopDetection.get(Thread.currentThread());} else {- loopDepth = new Integer(0);+ loopDepth = 0;}if (loopDepth.intValue() > 5) return null;- threadLoopDetection.put(Thread.currentThread(),new Integer(loopDepth.intValue()+1));+ threadLoopDetection.put(Thread.currentThread(),Integer.valueOf(loopDepth.intValue()+1));// deactivating the logging for jMimeMagicfinal Logger jmimeMagicLogger = Logger.getLogger("net.sf.jmimemagic");@@ -164,7 +164,7 @@ public class mimeTypeParser extends AbstractParser implements Parser {if (loopDepth.intValue() <= 1) {threadLoopDetection.remove(Thread.currentThread());} else {- threadLoopDetection.put(Thread.currentThread(), new Integer(loopDepth.intValue()-1));+ threadLoopDetection.put(Thread.currentThread(), Integer.valueOf(loopDepth.intValue()-1));}}}diff --git a/source/de/anomic/plasma/parser/ps/psParser.java b/source/de/anomic/plasma/parser/ps/psParser.javaindex a8c9d6fef..e078d8372 100644--- a/source/de/anomic/plasma/parser/ps/psParser.java+++ b/source/de/anomic/plasma/parser/ps/psParser.java@@ -86,6 +86,7 @@ public class psParser extends AbstractParser implements Parser {while ((procOutputLine = stdOut.readLine()) != null) {procOutput.append(procOutputLine).append(", ");}+ stdOut.close();final int returnCode = ps2asciiProc.waitFor();return (returnCode == 0);} catch (final Exception e) {@@ -145,7 +146,7 @@ public class psParser extends AbstractParser implements Parser {writer = new BufferedWriter(new FileWriter(outputFile));final String versionInfoLine = reader.readLine();- final String version = versionInfoLine.substring(versionInfoLine.length()-3);+ final String version = (versionInfoLine == null) ? "" : versionInfoLine.substring(versionInfoLine.length()-3);int ichar = 0;boolean isComment = false;@@ -244,9 +245,11 @@ public class psParser extends AbstractParser implements Parser {while ((procOutputLine = stdOut.readLine()) != null) {procOut.append(procOutputLine);}+ stdOut.close();while ((procOutputLine = stdErr.readLine()) != null) {procErr.append(procOutputLine);}+ stdErr.close();execCode = ps2asciiProc.waitFor();} catch (final Exception e) {final String errorMsg = "Unable to convert ps to ascii. " + e.getMessage();diff --git a/source/de/anomic/plasma/parser/rss/rssParser.java b/source/de/anomic/plasma/parser/rss/rssParser.javaindex a32ac8ef1..31b4da5c9 100644--- a/source/de/anomic/plasma/parser/rss/rssParser.java+++ b/source/de/anomic/plasma/parser/rss/rssParser.java@@ -25,6 +25,7 @@package de.anomic.plasma.parser.rss;import java.io.ByteArrayInputStream;+import java.io.IOException;import java.io.InputStream;import java.io.Writer;import java.util.HashMap;@@ -114,7 +115,9 @@ public class rssParser extends AbstractParser implements Parser {anchors.put(itemURL, itemTitle);if ((text.length() != 0) && (text.byteAt(text.length() - 1) != 32)) text.append((byte) 32);- text.append(new serverCharBuffer(htmlFilterAbstractScraper.stripAll(new serverCharBuffer(itemDescr.toCharArray()))).trim().toString()).append(' ');+ serverCharBuffer scb = new serverCharBuffer(htmlFilterAbstractScraper.stripAll(new serverCharBuffer(itemDescr.toCharArray())));+ text.append(scb.trim().toString()).append(' ');+ scb.close();final String itemContent = item.getDescription();if ((itemContent != null) && (itemContent.length() > 0)) {@@ -159,13 +162,16 @@ public class rssParser extends AbstractParser implements Parser {text.getBytes(),anchors,images);+ // close streams+ text.close();+ authors.close();- return theDoc;- } catch (final Exception e) {- if (e instanceof InterruptedException) throw (InterruptedException) e;- if (e instanceof ParserException) throw (ParserException) e;+ return theDoc;+ } catch (final InterruptedException e) {+ throw e;+ } catch (final IOException e) {throw new ParserException("Unexpected error while parsing rss file." + e.getMessage(),location);}}diff --git a/source/de/anomic/plasma/parser/sevenzip/ByteArrayIInStream.java b/source/de/anomic/plasma/parser/sevenzip/ByteArrayIInStream.javaindex 21502c98b..e70f2d34d 100644--- a/source/de/anomic/plasma/parser/sevenzip/ByteArrayIInStream.java+++ b/source/de/anomic/plasma/parser/sevenzip/ByteArrayIInStream.java@@ -30,7 +30,7 @@ import SevenZip.IInStream;public class ByteArrayIInStream extends IInStream {- private class SeekableByteArrayInputStream extends ByteArrayInputStream {+ private static class SeekableByteArrayInputStream extends ByteArrayInputStream {public SeekableByteArrayInputStream(final byte[] buf) { super(buf); }public SeekableByteArrayInputStream(final byte[] buf, final int off, final int len) { super(buf, off, len); }diff --git a/source/de/anomic/plasma/parser/swf/swfParser.java b/source/de/anomic/plasma/parser/swf/swfParser.javaindex dbce2f4f0..8e4be9b86 100644--- a/source/de/anomic/plasma/parser/swf/swfParser.java+++ b/source/de/anomic/plasma/parser/swf/swfParser.java@@ -97,7 +97,7 @@ public class swfParser extends AbstractParser implements Parser {while ((urlStart = contents.indexOf("http://",urlEnd)) >= 0){urlEnd = contents.indexOf(linebreak,urlStart);url = contents.substring(urlStart,urlEnd);- urlnr = (new Integer(++urls)).toString();+ urlnr = (Integer.valueOf(++urls)).toString();anchors.put(new yacyURL(url, null), urlnr);contents = contents.substring(0,urlStart)+contents.substring(urlEnd);}diff --git a/source/de/anomic/plasma/plasmaDHTFlush.java b/source/de/anomic/plasma/plasmaDHTFlush.javaindex 0353610e6..8ccf73d57 100644--- a/source/de/anomic/plasma/plasmaDHTFlush.java+++ b/source/de/anomic/plasma/plasmaDHTFlush.java@@ -104,7 +104,7 @@ public class plasmaDHTFlush extends Thread {if (this.initialWordsDBSize == 0) return 100;else if (currentWordsDBSize >= this.initialWordsDBSize) return 0;//else return (float) ((initialWordsDBSize-currentWordsDBSize)/(initialWordsDBSize/100));- else return (this.transferedContainerCount*100/this.initialWordsDBSize);+ else return (this.transferedContainerCount*100f/this.initialWordsDBSize);}public int getTransferedEntrySpeed() {diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.javaindex 863877e4f..0e2ea6a70 100644--- a/source/de/anomic/plasma/plasmaHTCache.java+++ b/source/de/anomic/plasma/plasmaHTCache.java@@ -538,8 +538,8 @@ public final class plasmaHTCache {p = s.indexOf("/");if (p < 0) p = s.indexOf("\\");if (p < 0) return null;- String prefix = new String("");- if (s.startsWith("www")) prefix = new String("www.");+ String prefix = "";+ if (s.startsWith("www")) prefix = "www.";// remove the www|other|ip directorys = s.substring(p + 1);p = s.indexOf("/");@@ -666,7 +666,7 @@ public final class plasmaHTCache {if ((d >= 0) && (d > s)) {extention = path.substring(d);} else if (path.endsWith("/ndx")) {- extention = new String (".html"); // Just a wild guess+ extention = ".html"; // Just a wild guess}path = path.concat(replaceRegex(query, "(\"|\\\\|\\*|\\?|/|:|<|>|\\|+)", "_"));@@ -953,7 +953,6 @@ public final class plasmaHTCache {);}- @SuppressWarnings("null")public Entry(final Date initDate,final int depth,final yacyURL url,@@ -965,7 +964,7 @@ public final class plasmaHTCache {) {if (resourceInfo == null){System.out.println("Content information object is null. " + url);- System.exit(0);+ System.exit(0);}this.resInfo = resourceInfo;this.url = url;diff --git a/source/de/anomic/plasma/plasmaParserDocument.java b/source/de/anomic/plasma/plasmaParserDocument.javaindex e8eb86164..14b6a6dde 100644--- a/source/de/anomic/plasma/plasmaParserDocument.java+++ b/source/de/anomic/plasma/plasmaParserDocument.java@@ -152,7 +152,7 @@ dc_rightspublic String dc_creator() {if (creator == null)- return new String();+ return "";return creator.toString();}diff --git a/source/de/anomic/plasma/plasmaRankingCRProcess.java b/source/de/anomic/plasma/plasmaRankingCRProcess.javaindex 3fab22925..c407190bb 100644--- a/source/de/anomic/plasma/plasmaRankingCRProcess.java+++ b/source/de/anomic/plasma/plasmaRankingCRProcess.java@@ -218,7 +218,6 @@ public class plasmaRankingCRProcess {return true;}- @SuppressWarnings("null")public static void accumulate(final File from_dir, final File tmp_dir, final File err_dir, final File bkp_dir, final File to_file, int max_files, final boolean newdb) throws IOException {if (!(from_dir.isDirectory())) {System.out.println("source path " + from_dir + " is not a directory.");diff --git a/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java b/source/de/anomic/plasma/plasmaRankingRCIEvaluation.javaindex 30e8435af..b3be3ec13 100644--- a/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java+++ b/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java@@ -56,18 +56,18 @@ public class plasmaRankingRCIEvaluation {entry = rci.getEntry(key);c = entry.getSeqSet().size();if (c > maxcount) maxcount = c;- count_key = new Integer(c);+ count_key = Integer.valueOf(c);count_count = counts.get(count_key);if (count_count == null) {- count_count = new Integer(1);+ count_count = 1;} else {- count_count = new Integer(count_count.intValue() + 1);+ count_count = Integer.valueOf(count_count.intValue() + 1);}counts.put(count_key, count_count);}final int[] ctable = new int[maxcount + 1];for (int j = 0; j <= maxcount; j++) {- count_count = counts.get(new Integer(j));+ count_count = counts.get(Integer.valueOf(j));if (count_count == null) {ctable[j] = 0;} else {diff --git a/source/de/anomic/plasma/plasmaSearchEvent.java b/source/de/anomic/plasma/plasmaSearchEvent.javaindex a96713e7d..441fec0bb 100644--- a/source/de/anomic/plasma/plasmaSearchEvent.java+++ b/source/de/anomic/plasma/plasmaSearchEvent.java@@ -190,7 +190,7 @@ public final class plasmaSearchEvent {mindhtdistance = d;IAneardhthash = wordhash;}- IACount.put(wordhash, new Integer(container.size()));+ IACount.put(wordhash, Integer.valueOf(container.size()));IAResults.put(wordhash, indexContainer.compressIndex(container, null, 1000).toString());}serverProfiling.update("SEARCH", new plasmaProfiling.searchEvent(query.id(true), "abstract generation", this.rankedCache.searchContainerMaps()[0].size(), System.currentTimeMillis() - timer));@@ -224,7 +224,7 @@ public final class plasmaSearchEvent {snippetComputationAllTime += resultEntry.snippetComputationTime;// place the result to the result vector- result.push(resultEntry, new Long(rankedCache.getOrder().cardinal(resultEntry.word())));+ result.push(resultEntry, Long.valueOf(rankedCache.getOrder().cardinal(resultEntry.word())));// add referencessynchronized (rankedCache) {@@ -545,7 +545,7 @@ public final class plasmaSearchEvent {// place the result to the result vectorif (!result.exists(resultEntry)) {- result.push(resultEntry, new Long(rankedCache.getOrder().cardinal(resultEntry.word())));+ result.push(resultEntry, Long.valueOf(rankedCache.getOrder().cardinal(resultEntry.word())));rankedCache.addReferences(resultEntry);}//System.out.println("DEBUG SNIPPET_LOADING: thread " + id + " got " + resultEntry.url());@@ -585,7 +585,7 @@ public final class plasmaSearchEvent {if ((localSearchThread != null) && (localSearchThread.isAlive())) {// in case that the local search takes longer than some other remote search requests,// do some sleeps to give the local process a chance to contribute- try {Thread.sleep(item * 100);} catch (final InterruptedException e) {}+ try {Thread.sleep(item * 100L);} catch (final InterruptedException e) {}}// now wait until as many remote worker threads have finished, as we want to display resultswhile ((this.primarySearchThreads != null) && (this.primarySearchThreads.length > item) && (anyWorkerAlive()) &&@@ -630,7 +630,7 @@ public final class plasmaSearchEvent {if (imagemedia != null) {for (int j = 0; j < imagemedia.size(); j++) {ms = imagemedia.get(j);- images.push(ms, new Long(ms.ranking));+ images.push(ms, Long.valueOf(ms.ranking));}}}diff --git a/source/de/anomic/plasma/plasmaSearchQuery.java b/source/de/anomic/plasma/plasmaSearchQuery.javaindex c5bc5a36d..ca980e780 100644--- a/source/de/anomic/plasma/plasmaSearchQuery.java+++ b/source/de/anomic/plasma/plasmaSearchQuery.java@@ -108,7 +108,7 @@ public final class plasmaSearchQuery {this.onlineSnippetFetch = false;this.host = null;this.remotepeer = null;- this.handle = new Long(System.currentTimeMillis());+ this.handle = Long.valueOf(System.currentTimeMillis());this.specialRights = false;}@@ -142,7 +142,7 @@ public final class plasmaSearchQuery {this.onlineSnippetFetch = onlineSnippetFetch;this.host = host;this.remotepeer = null;- this.handle = new Long(System.currentTimeMillis());+ this.handle = Long.valueOf(System.currentTimeMillis());this.specialRights = specialRights;}diff --git a/source/de/anomic/plasma/plasmaSearchRankingProcess.java b/source/de/anomic/plasma/plasmaSearchRankingProcess.javaindex 6bc2494e6..4fcc1825c 100644--- a/source/de/anomic/plasma/plasmaSearchRankingProcess.java+++ b/source/de/anomic/plasma/plasmaSearchRankingProcess.java@@ -122,9 +122,7 @@ public final class plasmaSearchRankingProcess {this.localSearchContainerMaps[1].values(),query.maxDistance);serverProfiling.update("SEARCH", new plasmaProfiling.searchEvent(query.id(true), plasmaSearchEvent.JOIN, index.size(), System.currentTimeMillis() - timer));- final int joincount = index.size();-- if ((index == null) || (joincount == 0)) {+ if ((index == null) || (index.size() == 0)) {return;}@@ -166,7 +164,7 @@ public final class plasmaSearchRankingProcess {}// kick out entries that are too bad according to current findings- r = new Long(order.cardinal(iEntry));+ r = Long.valueOf(order.cardinal(iEntry));if ((maxentries >= 0) && (stack.size() >= maxentries) && (stack.bottom(r.longValue()))) continue;// check constraintsdiff --git a/source/de/anomic/plasma/plasmaSearchRankingProfile.java b/source/de/anomic/plasma/plasmaSearchRankingProfile.javaindex 72bdca15a..f2b861edd 100644--- a/source/de/anomic/plasma/plasmaSearchRankingProfile.java+++ b/source/de/anomic/plasma/plasmaSearchRankingProfile.java@@ -126,7 +126,7 @@ public class plasmaSearchRankingProfile {if ((s == 0) || (e.startsWith(prefix))) {p = e.indexOf("=");if (p < 0) System.out.println("DEBUG: bug in plasmaSearchRankingProfile: e = " + e);- if ((p > 0) && (e.length() > p + 1)) coeff.put(e.substring(s, p), new Integer(Integer.parseInt(e.substring(p + 1))));+ if ((p > 0) && (e.length() > p + 1)) coeff.put(e.substring(s, p), Integer.valueOf(Integer.parseInt(e.substring(p + 1))));}}coeff_domlength = parseMap(coeff, DOMLENGTH, coeff_domlength);diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.javaindex 2cf0e0265..662d9fd1a 100644--- a/source/de/anomic/plasma/plasmaSnippetCache.java+++ b/source/de/anomic/plasma/plasmaSnippetCache.java@@ -519,7 +519,7 @@ public class plasmaSnippetCache {score = 0;while (j.hasNext()) {if (hs.containsKey(j.next())) score++;}if (score > 0) {- os.put(new Integer(1000000 * score - sentence.length() * 10000 + uniqCounter--), sentence);+ os.put(Integer.valueOf(1000000 * score - sentence.length() * 10000 + uniqCounter--), sentence);}}@@ -723,7 +723,7 @@ public class plasmaSnippetCache {hash = j.next();pos = hs.get(hash);if (pos == null) {- remaininghashes.add(new String(hash));+ remaininghashes.add(hash);}}return remaininghashes;@@ -739,7 +739,7 @@ public class plasmaSnippetCache {while (words.hasMoreElements()) {word = words.nextElement();hash = indexWord.word2hash(new String(word));- if (!map.containsKey(hash)) map.put(hash, new Integer(pos)); // dont overwrite old values, that leads to too far word distances+ if (!map.containsKey(hash)) map.put(hash, Integer.valueOf(pos)); // dont overwrite old values, that leads to too far word distancespos += word.length() + 1;}return map;@@ -870,7 +870,7 @@ public class plasmaSnippetCache {} else {return null;}- return new Object[]{resource,new Long(contentLength)};+ return new Object[]{resource, Long.valueOf(contentLength)};}public static String failConsequences(final TextSnippet snippet, final String eventID) {diff --git a/source/de/anomic/plasma/plasmaStore.java b/source/de/anomic/plasma/plasmaStore.javaindex d1384d842..f65e33239 100644--- a/source/de/anomic/plasma/plasmaStore.java+++ b/source/de/anomic/plasma/plasmaStore.java@@ -79,7 +79,6 @@ public class plasmaStore {// finished with reading. now cut the result to the right sizeb = new byte[len];System.arraycopy(result, 0, b, 0, len);- result = null;return b;} finally {if (gzipin != null) try{gzipin.close();}catch(final Exception e){}diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex fe0303973..1d64cde61 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -722,8 +722,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.webIndex) {+ this.webIndex.close();+ }+ synchronized (this) {setConfig("network.unit.definition", networkDefinition);overwriteNetworkDefinition(this);final File indexPrimaryPath = getConfigPath(plasmaSwitchboardConstants.INDEX_PRIMARY_PATH, plasmaSwitchboardConstants.INDEX_PATH_DEFAULT);@@ -1683,8 +1685,8 @@ 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("wordcache", new Long(webIndex.cacheSize()));+ serverProfiling.update("ppm", Long.valueOf(currentPPM()));+ serverProfiling.update("wordcache", Long.valueOf(webIndex.cacheSize()));lastPPMUpdate = System.currentTimeMillis();}serverProfiling.update("indexed", queueEntry.url().toNormalform(true, false));@@ -1869,7 +1871,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) {@@ -2196,7 +2198,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/plasmaWebStructure.java b/source/de/anomic/plasma/plasmaWebStructure.javaindex ece343ba3..e2b78bf68 100644--- a/source/de/anomic/plasma/plasmaWebStructure.java+++ b/source/de/anomic/plasma/plasmaWebStructure.java@@ -148,7 +148,7 @@ public class plasmaWebStructure {crg = new StringBuffer(maxCRGDump);}- return new Integer[] {new Integer(LCount), new Integer(GCount)};+ return new Integer[] {Integer.valueOf(LCount), Integer.valueOf(GCount)};}public void flushCitationReference(final String type) {@@ -186,7 +186,7 @@ public class plasmaWebStructure {final int refsc = refstr2count(refs);for (int i = 0; i < refsc; i++) {c = refs.substring(8 + i * 10, 8 + (i + 1) * 10);- map.put(c.substring(0, 6), new Integer(Integer.parseInt(c.substring(6), 16)));+ map.put(c.substring(0, 6), Integer.valueOf(c.substring(6), 16));}return map;}@@ -306,7 +306,7 @@ public class plasmaWebStructure {if (refs.containsKey(dom)) {c = (refs.get(dom)).intValue();}- refs.put(dom, new Integer(++c));+ refs.put(dom, Integer.valueOf(++c));}// check if the maxref is exceeded@@ -441,7 +441,7 @@ public class plasmaWebStructure {}- public class structureEntry {+ public static class structureEntry {public String domhash, domain, date;public Map<String, Integer> references;public structureEntry(final String domhash, final String domain, final String date, final Map<String, Integer> references) {diff --git a/source/de/anomic/server/logging/logParsers/LogParserPLASMA.java b/source/de/anomic/server/logging/logParsers/LogParserPLASMA.javaindex 511ccb239..6c79aef5a 100644--- a/source/de/anomic/server/logging/logParsers/LogParserPLASMA.java+++ b/source/de/anomic/server/logging/logParsers/LogParserPLASMA.java@@ -162,8 +162,8 @@ public class LogParserPLASMA implements LogParser{public static final String TOTAL_PARSER_RUNS = "totalParserRuns";- private final double parserVersion = 0.1;- private final String parserType = "PLASMA";+ private static final double parserVersion = 0.1;+ private static final String parserType = "PLASMA";//RegExp for LogLevel Iprivate static final Pattern i1 = Pattern.compile("Received (\\d*) URLs from peer [\\w-_]{12}:[\\w-_]*/[\\w.-]* in (\\d*) ms, blocked (\\d*) URLs");@@ -434,49 +434,49 @@ public class LogParserPLASMA implements LogParser{public Hashtable<String, Object> getResults() {final Hashtable<String, Object> results = new Hashtable<String, Object>();- results.put(PARSER_VERSION , new Double(parserVersion));- results.put(URLS_RECEIVED , new Integer(urlSum));- results.put(URLS_REQUESTED , new Integer(urlReqSum));- results.put(URLS_BLOCKED , new Integer(blockedURLSum));- results.put(WORDS_RECEIVED , new Integer(wordsSum));- results.put(RWIS_RECEIVED , new Integer(rwiSum));- results.put(RWIS_BLOCKED , new Integer(blockedRWISum));- results.put(URLS_RECEIVED_TIME , new Long(urlTimeSum));- results.put(RWIS_RECEIVED_TIME , new Long(rwiTimeSum));- results.put(DHT_TRAFFIC_SENT , new Long(DHTSendTraffic));- results.put(DHT_URLS_SENT , new Integer(DHTSendURLs));- results.put(DHT_REJECTED , new Integer(RWIRejectCount));+ results.put(PARSER_VERSION , Double.valueOf(parserVersion));+ results.put(URLS_RECEIVED , Integer.valueOf(urlSum));+ results.put(URLS_REQUESTED , Integer.valueOf(urlReqSum));+ results.put(URLS_BLOCKED , Integer.valueOf(blockedURLSum));+ results.put(WORDS_RECEIVED , Integer.valueOf(wordsSum));+ results.put(RWIS_RECEIVED , Integer.valueOf(rwiSum));+ results.put(RWIS_BLOCKED , Integer.valueOf(blockedRWISum));+ results.put(URLS_RECEIVED_TIME , Long.valueOf(urlTimeSum));+ results.put(RWIS_RECEIVED_TIME , Long.valueOf(rwiTimeSum));+ results.put(DHT_TRAFFIC_SENT , Long.valueOf(DHTSendTraffic));+ results.put(DHT_URLS_SENT , Integer.valueOf(DHTSendURLs));+ results.put(DHT_REJECTED , Integer.valueOf(RWIRejectCount));results.put(DHT_REJECTED_PEERS_NAME , RWIRejectPeerNames);results.put(DHT_REJECTED_PEERS_HASH , RWIRejectPeerHashs);results.put(DHT_SENT_PEERS_NAME , DHTPeerNames);results.put(DHT_SENT_PEERS_HASH , DHTPeerHashs);- results.put(DHT_SELECTED , new Integer(DHTSelectionTargetCount));- results.put(DHT_WORDS_SELECTED , new Integer(DHTSelectionWordsCount));- results.put(DHT_WORDS_SELECTED_TIME , new Integer(DHTSelectionWordsTimeCount));- results.put(DHT_DISTANCE_MIN , new Double(minDHTDist));- results.put(DHT_DISTANCE_MAX , new Double(maxDHTDist));- results.put(DHT_DISTANCE_AVERAGE , new Double(avgDHTDist / DHTSelectionTargetCount));- results.put(PEERS_BUSY , new Integer(busyPeerCount));- results.put(PEERS_TOO_LESS , new Integer(notEnoughDHTPeers));- results.put(DHT_SENT_FAILED , new Integer(failedIndexDistributionCount));- results.put(ERROR_CHILD_TWICE_LEFT , new Integer(leftChildTwiceCount));- results.put(ERROR_CHILD_TWICE_RIGHT , new Integer(rightChildTwiceCount));- results.put(RANKING_DIST , new Integer(rankingDistributionCount));- results.put(RANKING_DIST_TIME , new Integer(rankingDistributionTime));- results.put(RANKING_DIST_FAILED , new Integer(rankingDistributionFailCount));- results.put(ERROR_MALFORMED_URL , new Integer(malformedURLCount));- results.put(INDEXED_SITES , new Integer(indexedSites));- results.put(INDEXED_WORDS , new Integer(indexedWordSum));- results.put(INDEXED_SITES_SIZE , new Integer(indexedSiteSizeSum));- results.put(INDEXED_ANCHORS , new Integer(indexedAnchorsCount));+ results.put(DHT_SELECTED , Integer.valueOf(DHTSelectionTargetCount));+ results.put(DHT_WORDS_SELECTED , Integer.valueOf(DHTSelectionWordsCount));+ results.put(DHT_WORDS_SELECTED_TIME , Integer.valueOf(DHTSelectionWordsTimeCount));+ results.put(DHT_DISTANCE_MIN , Double.valueOf(minDHTDist));+ results.put(DHT_DISTANCE_MAX , Double.valueOf(maxDHTDist));+ results.put(DHT_DISTANCE_AVERAGE , Double.valueOf(avgDHTDist / DHTSelectionTargetCount));+ results.put(PEERS_BUSY , Integer.valueOf(busyPeerCount));+ results.put(PEERS_TOO_LESS , Integer.valueOf(notEnoughDHTPeers));+ results.put(DHT_SENT_FAILED , Integer.valueOf(failedIndexDistributionCount));+ results.put(ERROR_CHILD_TWICE_LEFT , Integer.valueOf(leftChildTwiceCount));+ results.put(ERROR_CHILD_TWICE_RIGHT , Integer.valueOf(rightChildTwiceCount));+ results.put(RANKING_DIST , Integer.valueOf(rankingDistributionCount));+ results.put(RANKING_DIST_TIME , Integer.valueOf(rankingDistributionTime));+ results.put(RANKING_DIST_FAILED , Integer.valueOf(rankingDistributionFailCount));+ results.put(ERROR_MALFORMED_URL , Integer.valueOf(malformedURLCount));+ results.put(INDEXED_SITES , Integer.valueOf(indexedSites));+ results.put(INDEXED_WORDS , Integer.valueOf(indexedWordSum));+ results.put(INDEXED_SITES_SIZE , Integer.valueOf(indexedSiteSizeSum));+ results.put(INDEXED_ANCHORS , Integer.valueOf(indexedAnchorsCount));// results.put(INDEXED_STACK_TIME , new Integer(indexedStackingTime));// results.put(INDEXED_PARSE_TIME , new Integer(indexedParsingTime));// results.put(INDEXED_INDEX_TIME , new Integer(indexedIndexingTime));// results.put(INDEXED_STORE_TIME , new Integer(indexedStorageTime));- results.put(INDEXED_LINKSTORE_TIME , new Integer(indexedLinkStorageTime));- results.put(INDEXED_INDEXSTORE_TIME, new Integer(indexedIndexStorageTime));- results.put(TOTAL_PARSER_TIME , new Long(totalParserTime));- results.put(TOTAL_PARSER_RUNS , new Integer(totalParserRuns));+ results.put(INDEXED_LINKSTORE_TIME , Integer.valueOf(indexedLinkStorageTime));+ results.put(INDEXED_INDEXSTORE_TIME, Integer.valueOf(indexedIndexStorageTime));+ results.put(TOTAL_PARSER_TIME , Long.valueOf(totalParserTime));+ results.put(TOTAL_PARSER_RUNS , Integer.valueOf(totalParserRuns));return results;}@@ -510,7 +510,7 @@ public class LogParserPLASMA implements LogParser{System.out.println("DHT: Blocked " + blockedRWISum + " RWIs before requesting URLs, because URL-Hash was blacklisted.");System.out.println("DHT: " + rwiTimeSum / rwiSum + " milliseconds per RWI.");System.out.println("DHT: Rejected " + RWIRejectCount + " Indextransfers from " + RWIRejectPeerNames.size() + " PeerNames with " + RWIRejectPeerHashs.size() + " PeerHashs.");- System.out.println("DHT: " + ((double)Math.round(DHTSendTraffic*100/(1024*1024)))/100 + " MegaBytes (" + DHTSendTraffic + " Bytes) of DHT-Transfertraffic.");+ System.out.println("DHT: " + DHTSendTraffic/(1024*1024l) + " MegaBytes (" + DHTSendTraffic + " Bytes) of DHT-Transfertraffic.");System.out.println("DHT: Sended " + DHTSendURLs + " URLs via DHT.");System.out.println("DHT: DHT Transfers send to " + DHTPeerNames.size() + " Peernames with " + DHTPeerHashs.size() + " Peerhashs.");System.out.println("DHT: Totally selected " + DHTSelectionWordsCount + " words in " + DHTSelectionWordsTimeCount + " seconds (" + (float)DHTSelectionWordsCount/DHTSelectionWordsTimeCount + " words/s)");diff --git a/source/de/anomic/server/serverAbstractSwitch.java b/source/de/anomic/server/serverAbstractSwitch.javaindex 8d61f3bae..c309a3ca9 100644--- a/source/de/anomic/server/serverAbstractSwitch.java+++ b/source/de/anomic/server/serverAbstractSwitch.java@@ -159,7 +159,7 @@ public abstract class serverAbstractSwitch<E> implements serverSwitch<E> {public void cleanupAccessTracker(final long timeout) {final Iterator<Map.Entry<String, TreeMap<Long, String>>> i = accessTracker.entrySet().iterator();while (i.hasNext()) {- if (i.next().getValue().tailMap(new Long(System.currentTimeMillis() - timeout)).size() == 0) i.remove();+ if (i.next().getValue().tailMap(Long.valueOf(System.currentTimeMillis() - timeout)).size() == 0) i.remove();}}@@ -170,7 +170,7 @@ public abstract class serverAbstractSwitch<E> implements serverSwitch<E> {if (access == null) access = new TreeMap<Long, String>();synchronized (access) {- access.put(new Long(System.currentTimeMillis()), accessPath);+ access.put(Long.valueOf(System.currentTimeMillis()), accessPath);// write back to trackeraccessTracker.put(host, clearTooOldAccess(access));}@@ -196,7 +196,7 @@ public abstract class serverAbstractSwitch<E> implements serverSwitch<E> {}private TreeMap<Long, String> clearTooOldAccess(final TreeMap<Long, String> access) {- return new TreeMap<Long, String>(access.tailMap(new Long(System.currentTimeMillis() - maxTrackingTime)));+ return new TreeMap<Long, String>(access.tailMap(Long.valueOf(System.currentTimeMillis() - maxTrackingTime)));}public Iterator<String> accessHosts() {diff --git a/source/de/anomic/server/serverByteBuffer.java b/source/de/anomic/server/serverByteBuffer.javaindex 013a81eea..e1466b761 100644--- a/source/de/anomic/server/serverByteBuffer.java+++ b/source/de/anomic/server/serverByteBuffer.java@@ -123,7 +123,6 @@ public final class serverByteBuffer extends OutputStream {byte[] tmp = new byte[newsize];System.arraycopy(buffer, offset, tmp, 0, length);buffer = tmp;- tmp = null;offset = 0;}diff --git a/source/de/anomic/server/serverCharBuffer.java b/source/de/anomic/server/serverCharBuffer.javaindex ca6ec22df..ab6a63388 100644--- a/source/de/anomic/server/serverCharBuffer.java+++ b/source/de/anomic/server/serverCharBuffer.java@@ -94,8 +94,9 @@ public final class serverCharBuffer extends Writer {buffer = new char[length*2];offset = 0;+ FileReader fr = null;try {- final FileReader fr = new FileReader(f);+ fr = new FileReader(f);final char[] temp = new char[256];int c;while ((c = fr.read(temp)) > 0) {@@ -103,6 +104,9 @@ public final class serverCharBuffer extends Writer {}} catch (final FileNotFoundException e) {throw new IOException("File not found: " + f.toString() + "; " + e.getMessage());+ } finally {+ if(fr != null)+ fr.close();}}@@ -122,7 +126,6 @@ public final class serverCharBuffer extends Writer {char[] tmp = new char[newsize];System.arraycopy(buffer, offset, tmp, 0, length);buffer = tmp;- tmp = null;offset = 0;}diff --git a/source/de/anomic/server/serverCodings.java b/source/de/anomic/server/serverCodings.javaindex 3e318cc62..7219857a2 100644--- a/source/de/anomic/server/serverCodings.java+++ b/source/de/anomic/server/serverCodings.java@@ -223,7 +223,7 @@ public final class serverCodings {final Iterator<String> i = s.iterator();boolean hasNext = i.hasNext();while (hasNext) {- buf.append(i.next().toString());+ buf.append(i.next());hasNext = i.hasNext();if (hasNext) buf.append(separator);}diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.javaindex a72f1668a..41ec6a690 100644--- a/source/de/anomic/server/serverCore.java+++ b/source/de/anomic/server/serverCore.java@@ -335,7 +335,7 @@ public final class serverCore extends serverAbstractBusyThread implements server//System.out.println("server bfHosts=" + bfHost.toString());if (bfHost.get(cIP) != null) {Integer attempts = bfHost.get(cIP);- if (attempts == null) attempts = new Integer(1); else attempts = new Integer(attempts.intValue() + 1);+ if (attempts == null) attempts = Integer.valueOf(1); else attempts = Integer.valueOf(attempts.intValue() + 1);bfHost.put(cIP, attempts);this.log.logWarning("SLOWING DOWN ACCESS FOR BRUTE-FORCE PREVENTION FROM " + cIP + ", ATTEMPT " + attempts.intValue());// add a delay to make brute-force harder@@ -449,7 +449,7 @@ public final class serverCore extends serverAbstractBusyThread implements serverpublic final class Session extends Thread {- boolean destroyed = false;+ //boolean destroyed = false;private boolean runningsession = false;private boolean stopped = false;@@ -867,6 +867,12 @@ public final class serverCore extends serverAbstractBusyThread implements server} catch (final IOException e) {if (logerr) serverLog.logSevere("SERVER", "receive interrupted - exception 2 = " + e.getMessage());return null;+ } finally {+ try {+ readLineBuffer.close();+ } catch (IOException e) {+ e.printStackTrace();+ }}}@@ -894,10 +900,6 @@ public final class serverCore extends serverAbstractBusyThread implements serverreturn new String(buffer);}- protected void finalize() throws Throwable {- super.finalize();- }-public static final void checkInterruption() throws InterruptedException {final Thread currentThread = Thread.currentThread();if (currentThread.isInterrupted()) throw new InterruptedException();@@ -997,6 +999,7 @@ public final class serverCore extends serverAbstractBusyThread implements serverthis.log.logFine("Loading keystore file " + keyStoreFileName);final FileInputStream stream = new FileInputStream(keyStoreFileName);ks.load(stream, keyStorePwd.toCharArray());+ stream.close();// creating a keystore factorythis.log.logFine("Initializing key manager factory ...");diff --git a/source/de/anomic/server/serverDate.java b/source/de/anomic/server/serverDate.javaindex e7cd93956..ebe9a5082 100644--- a/source/de/anomic/server/serverDate.java+++ b/source/de/anomic/server/serverDate.java@@ -78,7 +78,7 @@ public final class serverDate {* RFC 2616 requires that HTTP clients are able to parse all 3 different* formats. All times MUST be in GMT/UTC, but ...*/- public static SimpleDateFormat[] FORMATS_HTTP = new SimpleDateFormat[] {+ private static final SimpleDateFormat[] FORMATS_HTTP = new SimpleDateFormat[] {// RFC 1123/822 (Standard) "Mon, 12 Nov 2007 10:11:12 GMT"FORMAT_RFC1123,// RFC 1036/850 (old) "Monday, 12-Nov-07 10:11:12 GMT"@@ -356,8 +356,8 @@ public final class serverDate {final StringBuffer uptime = new StringBuffer();- final int uptimeDays = (int) (Math.floor(mins/1440));- final int uptimeHours = (int) (Math.floor(mins/60)%24);+ final int uptimeDays = (int) (Math.floor(mins/1440.0));+ final int uptimeHours = (int) (Math.floor(mins/60.0)%24);final int uptimeMins = (int) mins%60;uptime.append(uptimeDays)diff --git a/source/de/anomic/server/serverDomains.java b/source/de/anomic/server/serverDomains.javaindex e5e7baae6..1bdea4a77 100644--- a/source/de/anomic/server/serverDomains.java+++ b/source/de/anomic/server/serverDomains.java@@ -367,7 +367,7 @@ public class serverDomains {int p;String tld;//String name;- final Integer ID = new Integer(id);+ final Integer ID = Integer.valueOf(id);for (int i = 0; i < TLDList.length; i++) {p = TLDList[i].indexOf('=');if (p > 0) {diff --git a/source/de/anomic/server/serverFileUtils.java b/source/de/anomic/server/serverFileUtils.javaindex 3f4de96c5..634051277 100644--- a/source/de/anomic/server/serverFileUtils.java+++ b/source/de/anomic/server/serverFileUtils.java@@ -36,6 +36,7 @@ import java.io.InputStreamReader;import java.io.OutputStream;import java.io.PrintWriter;import java.io.Reader;+import java.io.Serializable;import java.io.Writer;import java.util.Comparator;import java.util.HashSet;@@ -51,6 +52,7 @@ import java.util.zip.ZipOutputStream;import de.anomic.kelondro.kelondroRow;import de.anomic.kelondro.kelondroRowSet;+import de.anomic.server.logging.serverLog;import de.anomic.tools.nxTools;public final class serverFileUtils {@@ -309,8 +311,16 @@ public final class serverFileUtils {public static byte[] uncompressGZipArray(byte[] source) throws IOException {if (source == null) return null;- // support of gzipped data (requested by roland)- if ((source.length > 1) && (((source[1] << 8) | source[0]) == GZIPInputStream.GZIP_MAGIC)) {+ // support of gzipped data (requested by roland)+ /* "Bitwise OR of signed byte value+ *+ * [...] Values loaded from a byte array are sign extended to 32 bits before+ * any any bitwise operations are performed on the value. Thus, if b[0]+ * contains the value 0xff, and x is initially 0, then the code ((x <<+ * 8) | b[0]) will sign extend 0xff to get 0xffffffff, and thus give the+ * value 0xffffffff as the result. [...]" findbugs description of BIT_IOR_OF_SIGNED_BYTE+ */+ if ((source.length > 1) && (((source[1] << 8) | (source[0] & 0xff)) == GZIPInputStream.GZIP_MAGIC)) {System.out.println("DEBUG: uncompressGZipArray - uncompressing source");try {final ByteArrayInputStream byteInput = new ByteArrayInputStream(source);@@ -422,7 +432,7 @@ public final class serverFileUtils {}if(os != null) {for (final Iterator<String> i = set.iterator(); i.hasNext(); ) {- os.write((i.next().toString()).getBytes());+ os.write((i.next()).getBytes());if (sep != null) os.write(sep.getBytes());}os.close();@@ -472,13 +482,21 @@ public final class serverFileUtils {if (!(from_dir.isDirectory())) return;if (!(to_dir.isDirectory())) return;final String[] list = from_dir.list();- for (int i = 0; i < list.length; i++) (new File(from_dir, list[i])).renameTo(new File(to_dir, list[i]));+ for (int i = 0; i < list.length; i++) {+ if(!new File(from_dir, list[i]).renameTo(new File(to_dir, list[i])))+ serverLog.logWarning("serverFileUtils", "moveAll(): could not move from "+ from_dir + list[i] +" to "+ to_dir + list[i]);+ }}- public static class dirlistComparator implements Comparator<File> {+ public static class dirlistComparator implements Comparator<File>, Serializable {- public int compare(final File file1, final File file2) {+ /**+ * generated serial+ */+ private static final long serialVersionUID = -5196490300039230135L;++ public int compare(final File file1, final File file2) {if (file1.isDirectory() && !file2.isDirectory()) {return -1;} else if (!file1.isDirectory() && file2.isDirectory()) {diff --git a/source/de/anomic/server/serverInstantBlockingThread.java b/source/de/anomic/server/serverInstantBlockingThread.javaindex 298d81e59..c55506af8 100644--- a/source/de/anomic/server/serverInstantBlockingThread.java+++ b/source/de/anomic/server/serverInstantBlockingThread.java@@ -52,7 +52,7 @@ public class serverInstantBlockingThread<J extends serverProcessorJob> extends sthis.jobExecMethod = execMethod(env, jobExec);this.environment = (env instanceof Class) ? null : env;this.setName(jobExecMethod.getClass().getName() + "." + jobExecMethod.getName() + "." + handleCounter++);- this.handle = new Long(System.currentTimeMillis() + this.getName().hashCode());+ this.handle = Long.valueOf(System.currentTimeMillis() + this.getName().hashCode());}protected static Method execMethod(final Object env, final String jobExec) {diff --git a/source/de/anomic/server/serverInstantBusyThread.java b/source/de/anomic/server/serverInstantBusyThread.javaindex c45829986..ada15b6fb 100644--- a/source/de/anomic/server/serverInstantBusyThread.java+++ b/source/de/anomic/server/serverInstantBusyThread.java@@ -66,7 +66,7 @@ public final class serverInstantBusyThread extends serverAbstractBusyThread impl}this.environment = (env instanceof Class) ? null : env;this.setName(theClass.getName() + "." + jobExec);- this.handle = new Long(System.currentTimeMillis() + this.getName().hashCode());+ this.handle = Long.valueOf(System.currentTimeMillis() + this.getName().hashCode());}public int getJobCount() {diff --git a/source/de/anomic/server/serverProfiling.java b/source/de/anomic/server/serverProfiling.javaindex 7294cf9f3..a932225f4 100644--- a/source/de/anomic/server/serverProfiling.java+++ b/source/de/anomic/server/serverProfiling.java@@ -62,7 +62,7 @@ public class serverProfiling extends Thread {public void run() {while (running) {- update("memory", new Long(serverMemory.used()));+ update("memory", Long.valueOf(serverMemory.used()));try {Thread.sleep(this.delaytime);} catch (final InterruptedException e) {@@ -80,7 +80,7 @@ public class serverProfiling extends Thread {// update entryhistory.add(new Event(counter, eventPayload));counter++;- eventCounter.put(eventName, new Integer(counter));+ eventCounter.put(eventName, Integer.valueOf(counter));// clean up too old entriesEvent e;@@ -96,7 +96,7 @@ public class serverProfiling extends Thread {// update entryhistory.add(new Event(counter, eventPayload));counter++;- eventCounter.put(eventName, new Integer(counter));+ eventCounter.put(eventName, Integer.valueOf(counter));// store maphistoryMaps.put(eventName, history);diff --git a/source/de/anomic/server/serverSystem.java b/source/de/anomic/server/serverSystem.javaindex 7f2076e96..bcf03bb51 100644--- a/source/de/anomic/server/serverSystem.java+++ b/source/de/anomic/server/serverSystem.java@@ -35,226 +35,232 @@ import de.anomic.server.logging.serverLog;public final class serverSystem {- // constants for system identification- public static final int systemMacOSC = 0; // 'classic' Mac OS 7.6.1/8.*/9.*- public static final int systemMacOSX = 1; // all Mac OS X- public static final int systemUnix = 2; // all Unix/Linux type systems- public static final int systemWindows = 3; // all Windows 95/98/NT/2K/XP- public static final int systemUnknown = -1; // any other system-- // constants for file type identification (Mac only)- public static final String blankTypeString = "____";-- // system-identification statics- public static int systemOS = systemUnknown;- public static boolean isMacArchitecture = false;- public static boolean isUnixFS = false;- public static boolean canExecUnix = false;- public static boolean isWindows = false;-- // calculated system constants- public static int maxPathLength = 65535;-- // Macintosh-specific statics- private static Class<?> macMRJFileUtils = null;- private static Class<?> macMRJOSType = null;- private static Constructor<?> macMRJOSTypeConstructor = null;- private static Object macMRJOSNullObj = null;- private static Method macGetFileCreator = null;- private static Method macGetFileType = null;- private static Method macSetFileCreator = null;- private static Method macSetFileType = null;- private static Method macOpenURL = null;- public static final Hashtable<String, String> macFSTypeCache = new Hashtable<String, String>();- public static final Hashtable<String, String> macFSCreatorCache = new Hashtable<String, String>();-- // static initialization- static {- // check operation system type- final Properties sysprop = System.getProperties();- final String sysname = sysprop.getProperty("os.name","").toLowerCase();- if (sysname.startsWith("mac os x")) systemOS = systemMacOSX;- else if (sysname.startsWith("mac os")) systemOS = systemMacOSC;- else if (sysname.startsWith("windows")) systemOS = systemWindows;- else if ((sysname.startsWith("linux")) || (sysname.startsWith("unix"))) systemOS = systemUnix;- else systemOS = systemUnknown;-- isMacArchitecture = ((systemOS == systemMacOSC) || (systemOS == systemMacOSX));- isUnixFS = ((systemOS == systemMacOSX) || (systemOS == systemUnix));- canExecUnix = ((isUnixFS) || (!((systemOS == systemMacOSC) || (systemOS == systemWindows))));- isWindows = (systemOS == systemWindows);-- // set up the MRJ Methods through reflection- if (isMacArchitecture) try {- macMRJFileUtils = Class.forName("com.apple.mrj.MRJFileUtils");- macMRJOSType = Class.forName("com.apple.mrj.MRJOSType");- macGetFileType = macMRJFileUtils.getMethod("getFileType", new Class[] {Class.forName("java.io.File")});- macGetFileCreator = macMRJFileUtils.getMethod("getFileCreator", new Class[] {Class.forName("java.io.File")});- macSetFileType = macMRJFileUtils.getMethod("setFileType", new Class[] {Class.forName("java.io.File"), macMRJOSType});- macSetFileCreator = macMRJFileUtils.getMethod("setFileCreator", new Class[] {Class.forName("java.io.File"), macMRJOSType});- macMRJOSTypeConstructor = macMRJOSType.getConstructor(new Class[] {Class.forName("java.lang.String")});- macOpenURL = macMRJFileUtils.getMethod("openURL", new Class[] {Class.forName("java.lang.String")});- final byte[] nullb = new byte[4];- for (int i = 0; i < 4; i++) nullb[i] = 0;- macMRJOSNullObj = macMRJOSTypeConstructor.newInstance(new Object[] {new String(nullb)});- } catch (final Exception e) {- //e.printStackTrace();- macMRJFileUtils = null; macMRJOSType = null;+ // constants for system identification+ public static final int systemMacOSC = 0; // 'classic' Mac OS 7.6.1/8.*/9.*+ public static final int systemMacOSX = 1; // all Mac OS X+ public static final int systemUnix = 2; // all Unix/Linux type systems+ public static final int systemWindows = 3; // all Windows 95/98/NT/2K/XP+ public static final int systemUnknown = -1; // any other system++ // constants for file type identification (Mac only)+ public static final String blankTypeString = "____";++ // system-identification statics+ public static int systemOS = systemUnknown;+ public static boolean isMacArchitecture = false;+ public static boolean isUnixFS = false;+ public static boolean canExecUnix = false;+ public static boolean isWindows = false;++ // calculated system constants+ public static int maxPathLength = 65535;++ // Macintosh-specific statics+ private static Class<?> macMRJFileUtils = null;+ private static Class<?> macMRJOSType = null;+ private static Constructor<?> macMRJOSTypeConstructor = null;+ private static Object macMRJOSNullObj = null;+ private static Method macGetFileCreator = null;+ private static Method macGetFileType = null;+ private static Method macSetFileCreator = null;+ private static Method macSetFileType = null;+ private static Method macOpenURL = null;+ public static final Hashtable<String, String> macFSTypeCache = new Hashtable<String, String>();+ public static final Hashtable<String, String> macFSCreatorCache = new Hashtable<String, String>();++ // static initialization+ static {+ // check operation system type+ final Properties sysprop = System.getProperties();+ final String sysname = sysprop.getProperty("os.name","").toLowerCase();+ if (sysname.startsWith("mac os x")) systemOS = systemMacOSX;+ else if (sysname.startsWith("mac os")) systemOS = systemMacOSC;+ else if (sysname.startsWith("windows")) systemOS = systemWindows;+ else if ((sysname.startsWith("linux")) || (sysname.startsWith("unix"))) systemOS = systemUnix;+ else systemOS = systemUnknown;++ isMacArchitecture = ((systemOS == systemMacOSC) || (systemOS == systemMacOSX));+ isUnixFS = ((systemOS == systemMacOSX) || (systemOS == systemUnix));+ canExecUnix = ((isUnixFS) || (!((systemOS == systemMacOSC) || (systemOS == systemWindows))));+ isWindows = (systemOS == systemWindows);++ // set up the MRJ Methods through reflection+ if (isMacArchitecture) try {+ macMRJFileUtils = Class.forName("com.apple.mrj.MRJFileUtils");+ macMRJOSType = Class.forName("com.apple.mrj.MRJOSType");+ macGetFileType = macMRJFileUtils.getMethod("getFileType", new Class[] {Class.forName("java.io.File")});+ macGetFileCreator = macMRJFileUtils.getMethod("getFileCreator", new Class[] {Class.forName("java.io.File")});+ macSetFileType = macMRJFileUtils.getMethod("setFileType", new Class[] {Class.forName("java.io.File"), macMRJOSType});+ macSetFileCreator = macMRJFileUtils.getMethod("setFileCreator", new Class[] {Class.forName("java.io.File"), macMRJOSType});+ macMRJOSTypeConstructor = macMRJOSType.getConstructor(new Class[] {Class.forName("java.lang.String")});+ macOpenURL = macMRJFileUtils.getMethod("openURL", new Class[] {Class.forName("java.lang.String")});+ final byte[] nullb = new byte[4];+ for (int i = 0; i < 4; i++) nullb[i] = 0;+ macMRJOSNullObj = macMRJOSTypeConstructor.newInstance(new Object[] {new String(nullb)});+ } catch (final Exception e) {+ //e.printStackTrace();+ macMRJFileUtils = null; macMRJOSType = null;+ }++ // set up maximum path length according to system+ if (isWindows) maxPathLength = 255; else maxPathLength = 65535;}-- // set up maximum path length according to system- if (isWindows) maxPathLength = 255; else maxPathLength = 65535;- }-/* public static boolean isWindows() {+ /* public static boolean isWindows() {return systemOS == systemWindows;}*/-- public static Object getMacOSTS(final String s) {- if ((isMacArchitecture) && (macMRJFileUtils != null)) try {- if ((s == null) || (s.equals(blankTypeString))) return macMRJOSNullObj;- return macMRJOSTypeConstructor.newInstance(new Object[] {s});- } catch (final Exception e) {- return macMRJOSNullObj;++ public static Object getMacOSTS(final String s) {+ if ((isMacArchitecture) && (macMRJFileUtils != null)) try {+ if ((s == null) || (s.equals(blankTypeString))) return macMRJOSNullObj;+ return macMRJOSTypeConstructor.newInstance(new Object[] {s});+ } catch (final Exception e) {+ return macMRJOSNullObj;+ }+ return null;}- return null;- }- public static String getMacFSType(final File f) {- if ((isMacArchitecture) && (macMRJFileUtils != null)) try {- final String s = macGetFileType.invoke(null, new Object[] {f}).toString();- if ((s == null) || (s.charAt(0) == 0)) return blankTypeString;- return s;- } catch (final Exception e) {- return null;+ public static String getMacFSType(final File f) {+ if ((isMacArchitecture) && (macMRJFileUtils != null)) try {+ final String s = macGetFileType.invoke(null, new Object[] {f}).toString();+ if ((s == null) || (s.charAt(0) == 0)) return blankTypeString;+ return s;+ } catch (final Exception e) {+ return null;+ }+ return null;}- return null;- }- public static String getMacFSCreator(final File f) {- if ((isMacArchitecture) && (macMRJFileUtils != null)) try {- final String s = macGetFileCreator.invoke(null, new Object[] {f}).toString();- if ((s == null) || (s.charAt(0) == 0)) return blankTypeString;- return s;- } catch (final Exception e) {- return null;+ public static String getMacFSCreator(final File f) {+ if ((isMacArchitecture) && (macMRJFileUtils != null)) try {+ final String s = macGetFileCreator.invoke(null, new Object[] {f}).toString();+ if ((s == null) || (s.charAt(0) == 0)) return blankTypeString;+ return s;+ } catch (final Exception e) {+ return null;+ }+ return null;}- return null;- }- public static void setMacFSType(final File f, final String t) {- if ((isMacArchitecture) && (macMRJFileUtils != null)) try {- macSetFileType.invoke(null, new Object[] {f, getMacOSTS(t)});- } catch (final Exception e) {/*System.out.println(e.getMessage()); e.printStackTrace();*/}- }+ public static void setMacFSType(final File f, final String t) {+ if ((isMacArchitecture) && (macMRJFileUtils != null)) try {+ macSetFileType.invoke(null, new Object[] {f, getMacOSTS(t)});+ } catch (final Exception e) {/*System.out.println(e.getMessage()); e.printStackTrace();*/}+ }- public static void setMacFSCreator(final File f, final String t) {- if ((isMacArchitecture) && (macMRJFileUtils != null)) try {- macSetFileCreator.invoke(null, new Object[] {f, getMacOSTS(t)});- } catch (final Exception e) {/*System.out.println(e.getMessage()); e.printStackTrace();*/}- }+ public static void setMacFSCreator(final File f, final String t) {+ if ((isMacArchitecture) && (macMRJFileUtils != null)) try {+ macSetFileCreator.invoke(null, new Object[] {f, getMacOSTS(t)});+ } catch (final Exception e) {/*System.out.println(e.getMessage()); e.printStackTrace();*/}+ }- public static boolean aquireMacFSType(final File f) {- if ((!(isMacArchitecture)) || (macMRJFileUtils == null)) return false;- final String name = f.toString();-- // check file type- final int dot = name.lastIndexOf(".");- if ((dot < 0) || (dot + 1 >= name.length())) return false;- final String type = getMacFSType(f);- if ((type == null) || (type.equals(blankTypeString))) return false;- final String ext = name.substring(dot + 1).toLowerCase();- final String oldType = macFSTypeCache.get(ext);- if ((oldType != null) && (oldType.equals(type))) return false;- macFSTypeCache.put(ext, type);- return true;- }+ public static boolean aquireMacFSType(final File f) {+ if ((!(isMacArchitecture)) || (macMRJFileUtils == null)) return false;+ final String name = f.toString();++ // check file type+ final int dot = name.lastIndexOf(".");+ if ((dot < 0) || (dot + 1 >= name.length())) return false;+ final String type = getMacFSType(f);+ if ((type == null) || (type.equals(blankTypeString))) return false;+ final String ext = name.substring(dot + 1).toLowerCase();+ final String oldType = macFSTypeCache.get(ext);+ if ((oldType != null) && (oldType.equals(type))) return false;+ macFSTypeCache.put(ext, type);+ return true;+ }- public static boolean aquireMacFSCreator(final File f) {- if ((!(isMacArchitecture)) || (macMRJFileUtils == null)) return false;- final String name = f.toString();-- // check creator- final String creator = getMacFSCreator(f);- if ((creator == null) || (creator.equals(blankTypeString))) return false;- final String oldCreator = macFSCreatorCache.get(name);- if ((oldCreator != null) && (oldCreator.equals(creator))) return false;- macFSCreatorCache.put(name, creator);- return true;- }+ public static boolean aquireMacFSCreator(final File f) {+ if ((!(isMacArchitecture)) || (macMRJFileUtils == null)) return false;+ final String name = f.toString();++ // check creator+ final String creator = getMacFSCreator(f);+ if ((creator == null) || (creator.equals(blankTypeString))) return false;+ final String oldCreator = macFSCreatorCache.get(name);+ if ((oldCreator != null) && (oldCreator.equals(creator))) return false;+ macFSCreatorCache.put(name, creator);+ return true;+ }- public static boolean applyMacFSType(final File f) {- if ((!(isMacArchitecture)) || (macMRJFileUtils == null)) return false;- final String name = f.toString();-- // reconstruct file type- final int dot = name.lastIndexOf(".");- if ((dot < 0) || (dot + 1 >= name.length())) return false;- final String type = macFSTypeCache.get(name.substring(dot + 1).toLowerCase());- if (type == null) return false;- final String oldType = getMacFSType(f);- if ((oldType != null) && (oldType.equals(type))) return false;- setMacFSType(f, type);- return getMacFSType(f).equals(type);- }+ public static boolean applyMacFSType(final File f) {+ if ((!(isMacArchitecture)) || (macMRJFileUtils == null)) return false;+ final String name = f.toString();++ // reconstruct file type+ final int dot = name.lastIndexOf(".");+ if ((dot < 0) || (dot + 1 >= name.length())) return false;+ final String type = macFSTypeCache.get(name.substring(dot + 1).toLowerCase());+ if (type == null) return false;+ final String oldType = getMacFSType(f);+ if ((oldType != null) && (oldType.equals(type))) return false;+ setMacFSType(f, type);+ return getMacFSType(f).equals(type);+ }- public static boolean applyMacFSCreator(final File f) {- if ((!(isMacArchitecture)) || (macMRJFileUtils == null)) return false;- final String name = f.toString();-- // reconstruct file creator- final String creator = macFSCreatorCache.get(name);- if (creator == null) return false;- final String oldCreator = getMacFSCreator(f);- if ((oldCreator != null) && (oldCreator.equals(creator))) return false;- //System.out.println("***Setting creator for " + f.toString() + " to " + creator);- setMacFSCreator(f, creator);- return getMacFSCreator(f).equals(creator); // this is not always true! I guess it's caused by deprecation of the interface in 1.4er Apple Extensions- }-- public static String infoString() {- String s = "System=";- if (systemOS == systemUnknown) s += "unknown";- else if (systemOS == systemMacOSC) s += "Mac OS Classic";- else if (systemOS == systemMacOSX) s += "Mac OS X";- else if (systemOS == systemUnix) s += "Unix/Linux";- else if (systemOS == systemWindows) s += "Windows";- else s += "unknown";- if (isMacArchitecture) s += ", Mac System Architecture";- if (isUnixFS) s += ", has Unix-like File System";- if (canExecUnix) s += ", can execute Unix-Shell Commands";- return s;- }+ public static boolean applyMacFSCreator(final File f) {+ if ((!(isMacArchitecture)) || (macMRJFileUtils == null)) return false;+ final String name = f.toString();++ // reconstruct file creator+ final String creator = macFSCreatorCache.get(name);+ if (creator == null) return false;+ final String oldCreator = getMacFSCreator(f);+ if ((oldCreator != null) && (oldCreator.equals(creator))) return false;+ //System.out.println("***Setting creator for " + f.toString() + " to " + creator);+ setMacFSCreator(f, creator);+ return getMacFSCreator(f).equals(creator); // this is not always true! I guess it's caused by deprecation of the interface in 1.4er Apple Extensions+ }- /** generates a 2-character string containing information about the OS-type*/- public static String infoKey() {- String s = "";- if (systemOS == systemUnknown) s += "o";- else if (systemOS == systemMacOSC) s += "c";- else if (systemOS == systemMacOSX) s += "x";- else if (systemOS == systemUnix) s += "u";- else if (systemOS == systemWindows) s += "w";- else s += "o";- if (isMacArchitecture) s += "m";- if (isUnixFS) s += "f";- if (canExecUnix) s += "e";- return s;- }+ public static String infoString() {+ String s = "System=";+ if (systemOS == systemUnknown) s += "unknown";+ else if (systemOS == systemMacOSC) s += "Mac OS Classic";+ else if (systemOS == systemMacOSX) s += "Mac OS X";+ else if (systemOS == systemUnix) s += "Unix/Linux";+ else if (systemOS == systemWindows) s += "Windows";+ else s += "unknown";+ if (isMacArchitecture) s += ", Mac System Architecture";+ if (isUnixFS) s += ", has Unix-like File System";+ if (canExecUnix) s += ", can execute Unix-Shell Commands";+ return s;+ }- private static String errorResponse(final Process p) {- final BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream()));- String line, error = "";- try {- while ((line = err.readLine()) != null) {- error = line + "\n";- }- return error;- } catch (final IOException e) {- return null;+ /** generates a 2-character string containing information about the OS-type*/+ public static String infoKey() {+ String s = "";+ if (systemOS == systemUnknown) s += "o";+ else if (systemOS == systemMacOSC) s += "c";+ else if (systemOS == systemMacOSX) s += "x";+ else if (systemOS == systemUnix) s += "u";+ else if (systemOS == systemWindows) s += "w";+ else s += "o";+ if (isMacArchitecture) s += "m";+ if (isUnixFS) s += "f";+ if (canExecUnix) s += "e";+ return s;}- }- /*+ private static String errorResponse(final Process p) {+ final BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream()));+ String line, error = "";+ try {+ while ((line = err.readLine()) != null) {+ error = line + "\n";+ }+ return error;+ } catch (final IOException e) {+ return null;+ } finally {+ try {+ err.close();+ } catch (IOException e) {+ e.printStackTrace();+ }+ }+ }++ /*public static void openBrowser(URL url) {if (openBrowserJNLP(url)) return;openBrowserExec(url.toString(), "firefox");@@ -271,108 +277,109 @@ public final class serverSystem {return false;}}- */+ */- public static void openBrowser(final String url) {- openBrowser(url, "firefox");- }+ public static void openBrowser(final String url) {+ openBrowser(url, "firefox");+ }- public static void openBrowser(final String url, final String app) {- try {- String cmd;- Process p;- if (systemOS != systemUnknown) {- if (systemOS == systemMacOSC) {- if ((isMacArchitecture) && (macMRJFileUtils != null)) {- macOpenURL.invoke(null, new Object[] {url});- }- } else if (systemOS == systemMacOSX) {- p = Runtime.getRuntime().exec(new String[] {"/usr/bin/osascript", "-e", "open location \"" + url + "\""});- p.waitFor();- if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p));- } else if (systemOS == systemUnix) {- cmd = app + " -remote openURL(" + url + ") &";- p = Runtime.getRuntime().exec(cmd);- p.waitFor();- if (p.exitValue() != 0) {- cmd = app + " " + url + " &";- p = Runtime.getRuntime().exec(cmd);- p.waitFor();- }- if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p));- } else if (systemOS == systemWindows) {- // see forum at http://forum.java.sun.com/thread.jsp?forum=57&thread=233364&message=838441- if (System.getProperty("os.name").contains("2000")) cmd = "rundll32 url.dll,FileProtocolHandler " + url;- else cmd = "rundll32 url.dll,FileProtocolHandler \"" + url + "\"";- //cmd = "cmd.exe /c start javascript:document.location='" + url + "'";- p = Runtime.getRuntime().exec(cmd);- p.waitFor();- if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p));- }- }- } catch (final Exception e) {- System.out.println("please start your browser and open the following location: " + url);+ public static void openBrowser(final String url, final String app) {+ try {+ String cmd;+ Process p;+ if (systemOS != systemUnknown) {+ if (systemOS == systemMacOSC) {+ if ((isMacArchitecture) && (macMRJFileUtils != null)) {+ macOpenURL.invoke(null, new Object[] {url});+ }+ } else if (systemOS == systemMacOSX) {+ p = Runtime.getRuntime().exec(new String[] {"/usr/bin/osascript", "-e", "open location \"" + url + "\""});+ p.waitFor();+ if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p));+ } else if (systemOS == systemUnix) {+ cmd = app + " -remote openURL(" + url + ") &";+ p = Runtime.getRuntime().exec(cmd);+ p.waitFor();+ if (p.exitValue() != 0) {+ cmd = app + " " + url + " &";+ p = Runtime.getRuntime().exec(cmd);+ p.waitFor();+ }+ if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p));+ } else if (systemOS == systemWindows) {+ // see forum at http://forum.java.sun.com/thread.jsp?forum=57&thread=233364&message=838441+ if (System.getProperty("os.name").contains("2000")) cmd = "rundll32 url.dll,FileProtocolHandler " + url;+ else cmd = "rundll32 url.dll,FileProtocolHandler \"" + url + "\"";+ //cmd = "cmd.exe /c start javascript:document.location='" + url + "'";+ p = Runtime.getRuntime().exec(cmd);+ p.waitFor();+ if (p.exitValue() != 0) throw new RuntimeException("EXEC ERROR: " + errorResponse(p));+ }+ }+ } catch (final Exception e) {+ System.out.println("please start your browser and open the following location: " + url);+ }}- }- public static void deployScript(final File scriptFile, final String theScript) throws IOException {- serverFileUtils.copy(theScript.getBytes(), scriptFile);- if(!isWindows){ // set executable- try {- Runtime.getRuntime().exec("chmod 755 " + scriptFile.getAbsolutePath().replaceAll(" ", "\\ ")).waitFor();- } catch (final InterruptedException e) {- serverLog.logSevere("DEPLOY", "deploy of script file failed. file = " + scriptFile.getAbsolutePath(), e);- throw new IOException(e.getMessage());- }- }- }-- public static void execAsynchronous(final File scriptFile) throws IOException {- // runs a script as separate thread- String starterFileExtension = null;- String script = null;- if(isWindows){- starterFileExtension = ".starter.bat";- // use /K to debug, /C for release- script = "start /MIN CMD /C \"" + scriptFile.getAbsolutePath() + "\"";- } else { // unix/linux- starterFileExtension = ".starter.sh";- script = "#!/bin/sh" + serverCore.LF_STRING + scriptFile.getAbsolutePath().replaceAll(" ", "\\ ") + " &" + serverCore.LF_STRING;- }- final File starterFile = new File(scriptFile.getAbsolutePath().replaceAll(" ", "\\ ") + starterFileExtension);- deployScript(starterFile, script);- try {- Runtime.getRuntime().exec(starterFile.getAbsolutePath().replaceAll(" ", "\\ ")).waitFor();- } catch (final InterruptedException e) {- throw new IOException(e.getMessage());- }- starterFile.delete();- }-- public static Vector<String> execSynchronous(final String command) throws IOException {- // runs a unix/linux command and returns output as Vector of Strings- // this method blocks until the command is executed- final Process p = Runtime.getRuntime().exec(command);- final BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));- String text;- final Vector<String> output = new Vector<String>();- while ((text = in.readLine()) != null) {- output.add(text);- }- return output;- }-- public static void main(final String[] args) {- //try{System.getProperties().list(new PrintStream(new FileOutputStream(new File("system.properties.txt"))));} catch (FileNotFoundException e) {}- //System.out.println("nullstr=" + macMRJOSNullObj.toString());- if (args[0].equals("-f")) {- final File f = new File(args[1]);- System.out.println("File " + f.toString() + ": creator = " + getMacFSCreator(f) + "; type = " + getMacFSType(f));+ public static void deployScript(final File scriptFile, final String theScript) throws IOException {+ serverFileUtils.copy(theScript.getBytes(), scriptFile);+ if(!isWindows){ // set executable+ try {+ Runtime.getRuntime().exec("chmod 755 " + scriptFile.getAbsolutePath().replaceAll(" ", "\\ ")).waitFor();+ } catch (final InterruptedException e) {+ serverLog.logSevere("DEPLOY", "deploy of script file failed. file = " + scriptFile.getAbsolutePath(), e);+ throw new IOException(e.getMessage());+ }+ }}- if (args[0].equals("-u")) {- openBrowser(args[1]);++ public static void execAsynchronous(final File scriptFile) throws IOException {+ // runs a script as separate thread+ String starterFileExtension = null;+ String script = null;+ if(isWindows){+ starterFileExtension = ".starter.bat";+ // use /K to debug, /C for release+ script = "start /MIN CMD /C \"" + scriptFile.getAbsolutePath() + "\"";+ } else { // unix/linux+ starterFileExtension = ".starter.sh";+ script = "#!/bin/sh" + serverCore.LF_STRING + scriptFile.getAbsolutePath().replaceAll(" ", "\\ ") + " &" + serverCore.LF_STRING;+ }+ final File starterFile = new File(scriptFile.getAbsolutePath().replaceAll(" ", "\\ ") + starterFileExtension);+ deployScript(starterFile, script);+ try {+ Runtime.getRuntime().exec(starterFile.getAbsolutePath().replaceAll(" ", "\\ ")).waitFor();+ } catch (final InterruptedException e) {+ throw new IOException(e.getMessage());+ }+ starterFile.delete();+ }++ public static Vector<String> execSynchronous(final String command) throws IOException {+ // runs a unix/linux command and returns output as Vector of Strings+ // this method blocks until the command is executed+ final Process p = Runtime.getRuntime().exec(command);+ final BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));+ String text;+ final Vector<String> output = new Vector<String>();+ while ((text = in.readLine()) != null) {+ output.add(text);+ }+ in.close();+ return output;+ }++ public static void main(final String[] args) {+ //try{System.getProperties().list(new PrintStream(new FileOutputStream(new File("system.properties.txt"))));} catch (FileNotFoundException e) {}+ //System.out.println("nullstr=" + macMRJOSNullObj.toString());+ if (args[0].equals("-f")) {+ final File f = new File(args[1]);+ System.out.println("File " + f.toString() + ": creator = " + getMacFSCreator(f) + "; type = " + getMacFSType(f));+ }+ if (args[0].equals("-u")) {+ openBrowser(args[1]);+ }}- }}@@ -399,7 +406,7 @@ user.language |de |de |deuser.name |Bob |myself |User |public |user.timezone |ECT |Europe/Berlin |Europe/Berlin | |-------------------+----------------------+----------------------+----------------------+----------------------+-*/+ *//*static struct browser possible_browsers[] = {@@ -421,14 +428,14 @@ user.timezone |ECT |Europe/Berlin |Europe/Berlincommand = exec("galeon -n \"%s\"", uri);command = exec("%s -remote \"openURL(\"%s\"," "new-window)\"", web_browser, uri);command = exec("%s -remote \"openURL(\"%s\"," "new-tab)\"", web_browser, uri);-+current:command = exec("netscape -remote " "\"openURL(\"%s\")\"", uri);command = exec("opera -remote " "\"openURL(\"%s\")\"", uri);command = exec("galeon \"%s\"", uri);command = exec("%s -remote \"openURL(\"%s\")\"", web_browser, uri);-+no option:command = exec("kfmclient openURL \"%s\"", uri);command = exec("gnome-open \"%s\"", uri);-*/+ */diff --git a/source/de/anomic/tools/bbCode.java b/source/de/anomic/tools/bbCode.javaindex 40605bde1..9ca5091f6 100644--- a/source/de/anomic/tools/bbCode.java+++ b/source/de/anomic/tools/bbCode.java@@ -29,7 +29,7 @@ package de.anomic.tools;public class bbCode {- String text;+ //String text;/**init - no Code yet*/public bbCode(){diff --git a/source/de/anomic/tools/bitfield.java b/source/de/anomic/tools/bitfield.javaindex 8a366a0c2..d02ea956e 100644--- a/source/de/anomic/tools/bitfield.java+++ b/source/de/anomic/tools/bitfield.java@@ -57,7 +57,6 @@ public class bitfield {System.arraycopy(bb, 0, nb, 0, bb.length);for (int i = bb.length; i < nb.length; i++) nb[i] = 0;bb = nb;- nb = null;}bb[slot] = (value) ? setAtom(bb[slot], pos % 6) : unsetAtom(bb[slot], pos % 6);}diff --git a/source/de/anomic/tools/cryptbig.java b/source/de/anomic/tools/cryptbig.javaindex 1e860a01d..c1cfeabb0 100644--- a/source/de/anomic/tools/cryptbig.java+++ b/source/de/anomic/tools/cryptbig.java@@ -287,16 +287,16 @@ public class cryptbig {fin = new BufferedInputStream(new FileInputStream(inFileName), 4096);// read the file properties- final byte[] thisMagic = new byte[magicString.length()]; fin.read(thisMagic);+ final byte[] thisMagic = new byte[magicString.length()]; int bytesRead = fin.read(thisMagic);if (!((new String(thisMagic)).equals(magicString))) {// this is not an crypt file, so dont do anythingfin.close();return;}- final byte[] C = new byte[1]; fin.read(C); // the length of the following String, encoded as b64- final byte[] B = new byte[(int) kelondroBase64Order.standardCoder.decodeLong(new String(C))]; fin.read(B); // this is again the length of the following string, as encrypted b64-ed integer- final byte[] A = new byte[(int) kelondroBase64Order.standardCoder.decodeLong(new String(dcipher.doFinal(B), "UTF8"))]; fin.read(A);+ final byte[] C = new byte[1]; bytesRead = fin.read(C); // the length of the following String, encoded as b64+ final byte[] B = new byte[(int) kelondroBase64Order.standardCoder.decodeLong(new String(C))]; bytesRead = fin.read(B); // this is again the length of the following string, as encrypted b64-ed integer+ final byte[] A = new byte[(int) kelondroBase64Order.standardCoder.decodeLong(new String(dcipher.doFinal(B), "UTF8"))]; bytesRead = fin.read(A);final String X = new String(dcipher.doFinal(A), "UTF8");System.out.println("TEST: detecting X-String : " + X);@@ -443,7 +443,7 @@ public class cryptbig {final cryptbig crypter = new cryptbig(key);String e = crypter.encryptString(key);if (e.length() == 0) e = "0XXXX";- if (e.length() % 2 == 1) e += "X";+ if (e.length() % 2 != 0) e += "X";while (e.length() < 32) e = e + e;final char[] r = new char[16];for (int i = 0; i < 16; i++) r[i] = e.charAt(2 * i + 1);diff --git a/source/de/anomic/tools/diskUsage.java b/source/de/anomic/tools/diskUsage.javaindex 33dd64ce8..9e6eab94b 100644--- a/source/de/anomic/tools/diskUsage.java+++ b/source/de/anomic/tools/diskUsage.java@@ -291,7 +291,7 @@ public class diskUsage {final File file = new File("DATA");String path = null;- try { path = file.getCanonicalPath().toString(); } catch (final IOException e) {+ try { path = file.getCanonicalPath(); } catch (final IOException e) {usageError = "Cant get DATA directory";return;}diff --git a/source/de/anomic/tools/loaderThreads.java b/source/de/anomic/tools/loaderThreads.javaindex 1cbf7a087..29122f056 100644--- a/source/de/anomic/tools/loaderThreads.java+++ b/source/de/anomic/tools/loaderThreads.java@@ -165,7 +165,7 @@ public class loaderThreads {}- public class propLoader extends loaderCore implements loaderProcess {+ public static class propLoader extends loaderCore implements loaderProcess {public propLoader() {this.status = STATUS_READY;diff --git a/source/de/anomic/xml/opensearchdescriptionReader.java b/source/de/anomic/xml/opensearchdescriptionReader.javaindex a07b9ca93..625bd5a09 100644--- a/source/de/anomic/xml/opensearchdescriptionReader.java+++ b/source/de/anomic/xml/opensearchdescriptionReader.java@@ -97,7 +97,7 @@ public class opensearchdescriptionReader extends DefaultHandler {private Item channel;private final StringBuffer buffer;private boolean parsingChannel;- private String imageURL;+ private final String imageURL = null;private final ArrayList<String> itemsGUID; // a list of GUIDs, so the items can be retrieved by a specific orderprivate final HashMap<String, Item> items; // a guid:Item mapdiff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.javaindex 9a446fe4a..2fd9424e7 100644--- a/source/de/anomic/yacy/yacyClient.java+++ b/source/de/anomic/yacy/yacyClient.java@@ -927,7 +927,7 @@ public final class yacyClient {return resultObj;} finally {- resultObj.put("payloadSize", new Integer(payloadSize));+ resultObj.put("payloadSize", Integer.valueOf(payloadSize));}}diff --git a/source/de/anomic/yacy/yacyNewsDB.java b/source/de/anomic/yacy/yacyNewsDB.javaindex e8db559af..ff26a621b 100644--- a/source/de/anomic/yacy/yacyNewsDB.java+++ b/source/de/anomic/yacy/yacyNewsDB.java@@ -79,7 +79,7 @@ public class yacyNewsDB {news = null;}- public void finalize() {+ protected void finalize() {close();}diff --git a/source/de/anomic/yacy/yacyNewsQueue.java b/source/de/anomic/yacy/yacyNewsQueue.javaindex 917b4ccc0..f0c00a4c9 100644--- a/source/de/anomic/yacy/yacyNewsQueue.java+++ b/source/de/anomic/yacy/yacyNewsQueue.java@@ -90,7 +90,7 @@ public class yacyNewsQueue {queueStack = null;}- public void finalize() {+ protected void finalize() {close();}diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex f79d6855c..c028a93d3 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -204,13 +204,13 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {seedActiveDB.remove(mySeed.hash);seedPassiveDB.remove(mySeed.hash);seedPotentialDB.remove(mySeed.hash);- } catch (final IOException e) {}+ } catch (final IOException e) { serverLog.logWarning("yacySeedDB", "could not remove hash ("+ e.getClass() +"): "+ e.getMessage()); }}public void saveMySeed() {try {this.mySeed().save(myOwnSeedFile);- } catch (final IOException e) {}+ } catch (final IOException e) { serverLog.logWarning("yacySeedDB", "could not save mySeed '"+ myOwnSeedFile +"': "+ e.getMessage()); }}public boolean noDHTActivity() {@@ -221,7 +221,11 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {@SuppressWarnings("unchecked")private synchronized kelondroMapDataMining openSeedTable(final File seedDBFile) {final boolean usetree = false;- new File(seedDBFile.getParent()).mkdirs();+ final File parentDir = new File(seedDBFile.getParent());+ if (!parentDir.exists()) {+ if(!parentDir.mkdirs())+ serverLog.logWarning("yacySeedDB", "could not create directories for "+ seedDBFile.getParent());+ }Class[] args;try {args = new Class[]{"".getClass(), Class.forName("java.util.Map")};@@ -253,7 +257,8 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {// seed.db is detectedyacyCore.log.logFine("seed-db " + seedDBFile.toString() + " reset (on-the-fly)");seedDB.close();- seedDBFile.delete();+ if(!seedDBFile.delete())+ serverLog.logWarning("yacySeedDB", "could not delete file "+ seedDBFile);// create new seed databaseseedDB = openSeedTable(seedDBFile);return seedDB;@@ -462,7 +467,7 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {nameLookupCache.remove(seed.getName());seedActiveDB.remove(seed.hash);seedPotentialDB.remove(seed.hash);- } catch (final Exception e) {}+ } catch (final Exception e) { serverLog.logWarning("yacySeedDB", "could not remove hash ("+ e.getClass() +"): "+ e.getMessage()); }//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));try {final HashMap<String, String> seedPropMap = seed.getMap();@@ -487,7 +492,7 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {nameLookupCache.remove(seed.getName());seedActiveDB.remove(seed.hash);seedPassiveDB.remove(seed.hash);- } catch (final Exception e) {}+ } catch (final Exception e) { serverLog.logWarning("yacySeedDB", "could not remove hash ("+ e.getClass() +"): "+ e.getMessage()); }if (seed.isProper(false) != null) return;//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));try {@@ -511,14 +516,14 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {if(peerHash == null) return;try {seedPassiveDB.remove(peerHash);- } catch (final IOException e) { }+ } catch (final IOException e) { serverLog.logWarning("yacySeedDB", "could not remove hash ("+ e.getClass() +"): "+ e.getMessage()); }}public synchronized void removePotential(final String peerHash) {if(peerHash == null) return;try {seedPotentialDB.remove(peerHash);- } catch (final IOException e) { }+ } catch (final IOException e) { serverLog.logWarning("yacySeedDB", "could not remove hash ("+ e.getClass() +"): "+ e.getMessage()); }}public boolean hasConnected(final String hash) {@@ -826,7 +831,12 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {throw new Exception("UPLOAD CHECK - Error: the result vector is different. " + errorMsg + serverCore.CRLF_STRING);}} finally {- if (seedFile != null) try { seedFile.delete(); } catch (final Exception e) {/* ignore this */}+ if (seedFile != null)+ try {+ seedFile.delete();+ } catch (final Exception e) {+ /* ignore this */+ }}return log;diff --git a/source/de/anomic/yacy/yacyTray.java b/source/de/anomic/yacy/yacyTray.javaindex 0ab0ef12d..467ee13c7 100644--- a/source/de/anomic/yacy/yacyTray.java+++ b/source/de/anomic/yacy/yacyTray.java@@ -45,7 +45,7 @@ import de.anomic.server.serverSystem;public class yacyTray implements ActionListener, ItemListener {- private final boolean testing = false;+ private static final boolean testing = false;plasmaSwitchboard sb;diff --git a/source/de/anomic/yacy/yacyURL.java b/source/de/anomic/yacy/yacyURL.javaindex e17c65fcb..d8794fa27 100644--- a/source/de/anomic/yacy/yacyURL.java+++ b/source/de/anomic/yacy/yacyURL.java@@ -565,31 +565,97 @@ public class yacyURL implements Serializable {this.getHost().toLowerCase() + ((defaultPort) ? ("") : (":" + this.port)) + path;}- public boolean equals(final Object other) {- if(other != null && other instanceof yacyURL) {- final yacyURL otherURL = (yacyURL) other;- return (((this.protocol == otherURL.protocol) || (this.protocol.equals(otherURL.protocol))) &&- ((this.host == otherURL.host ) || (this.host.equals(otherURL.host))) &&- ((this.userInfo == otherURL.userInfo) || (this.userInfo.equals(otherURL.userInfo))) &&- ((this.path == otherURL.path ) || (this.path.equals(otherURL.path))) &&- ((this.quest == otherURL.quest ) || (this.quest.equals(otherURL.quest))) &&- ((this.ref == otherURL.ref ) || (this.ref.equals(otherURL.ref))) &&- ((this.port == otherURL.port )));- }- return super.equals(other);- }+// public boolean equals(final Object other) {+// if(other != null && other instanceof yacyURL) {+// final yacyURL otherURL = (yacyURL) other;+// return (((this.protocol == otherURL.protocol) || (this.protocol.equals(otherURL.protocol))) &&+// ((this.host == otherURL.host ) || (this.host.equals(otherURL.host))) &&+// ((this.userInfo == otherURL.userInfo) || (this.userInfo.equals(otherURL.userInfo))) &&+// ((this.path == otherURL.path ) || (this.path.equals(otherURL.path))) &&+// ((this.quest == otherURL.quest ) || (this.quest.equals(otherURL.quest))) &&+// ((this.ref == otherURL.ref ) || (this.ref.equals(otherURL.ref))) &&+// ((this.port == otherURL.port )));+// }+// return super.equals(other);+// }+//+// /**+// * hash code computation for yacyURL: please don't mix this up with the YaCy-Hash+// * this hash here is only used by hashing data structures, like a HashMap+// * We do not use tha yacy hash here, because this needs the computation of a DNS+// * which is very time-intensive+// */+// public int hashCode() {+// return this.toNormalform(true, false).hashCode();+// }- /**- * hash code computation for yacyURL: please don't mix this up with the YaCy-Hash- * this hash here is only used by hashing data structures, like a HashMap- * We do not use tha yacy hash here, because this needs the computation of a DNS- * which is very time-intensive- */- public int hashCode() {- return this.toNormalform(true, false).hashCode();- }-- public int compareTo(final Object h) {+ /* (non-Javadoc)+ * @see java.lang.Object#hashCode()+ */+ @Override+ public int hashCode() {+ final int prime = 31;+ int result = 1;+ result = prime * result + ((host == null) ? 0 : host.hashCode());+ result = prime * result + ((path == null) ? 0 : path.hashCode());+ result = prime * result + port;+ result = prime * result+ + ((protocol == null) ? 0 : protocol.hashCode());+ result = prime * result + ((quest == null) ? 0 : quest.hashCode());+ result = prime * result + ((ref == null) ? 0 : ref.hashCode());+ result = prime * result+ + ((userInfo == null) ? 0 : userInfo.hashCode());+ return result;+ }++ /* (non-Javadoc)+ * @see java.lang.Object#equals(java.lang.Object)+ */+ @Override+ public boolean equals(Object obj) {+ if (this == obj)+ return true;+ if (obj == null)+ return false;+ if (!(obj instanceof yacyURL))+ return false;+ yacyURL other = (yacyURL) obj;+ if (host == null) {+ if (other.host != null)+ return false;+ } else if (!host.equals(other.host))+ return false;+ if (path == null) {+ if (other.path != null)+ return false;+ } else if (!path.equals(other.path))+ return false;+ if (port != other.port)+ return false;+ if (protocol == null) {+ if (other.protocol != null)+ return false;+ } else if (!protocol.equals(other.protocol))+ return false;+ if (quest == null) {+ if (other.quest != null)+ return false;+ } else if (!quest.equals(other.quest))+ return false;+ if (ref == null) {+ if (other.ref != null)+ return false;+ } else if (!ref.equals(other.ref))+ return false;+ if (userInfo == null) {+ if (other.userInfo != null)+ return false;+ } else if (!userInfo.equals(other.userInfo))+ return false;+ return true;+ }++ public int compareTo(final Object h) {assert (h instanceof yacyURL);return this.toString().compareTo(((yacyURL) h).toString());}@@ -647,15 +713,16 @@ public class yacyURL implements Serializable {}// find rootpath- String pathx = new String(this.path);- if (pathx.startsWith("/"))- pathx = pathx.substring(1);- if (pathx.endsWith("/"))- pathx = pathx.substring(0, pathx.length() - 1);- p = pathx.indexOf('/');+ int rootpathStart = 0;+ int rootpathEnd = this.path.length() - 1;+ if (this.path.startsWith("/"))+ rootpathStart = 1;+ if (this.path.endsWith("/"))+ rootpathEnd = this.path.length() - 2;+ p = this.path.indexOf('/', rootpathStart);String rootpath = "";- if (p > 0) {- rootpath = pathx.substring(0, p);+ if (p > 0 && p < rootpathEnd) {+ rootpath = path.substring(rootpathStart, p);}// we collected enough information to compute the fragments that arediff --git a/source/de/anomic/yacy/yacyVersion.java b/source/de/anomic/yacy/yacyVersion.javaindex 651d530b7..067d11d83 100644--- a/source/de/anomic/yacy/yacyVersion.java+++ b/source/de/anomic/yacy/yacyVersion.java@@ -153,7 +153,7 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya// compare-operator for two yacyVersion objects// must be implemented to make it possible to put this object into// a ordered structure, like TreeSet or TreeMap- return (new Integer(v0.svn)).compareTo(new Integer(v1.svn));+ return (Integer.valueOf(v0.svn)).compareTo(Integer.valueOf(v1.svn));}public boolean equals(final Object obj) {@@ -359,7 +359,9 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<yaif ((!download.exists()) || (download.length() == 0)) throw new IOException("wget of url " + release.url + " failed");} catch (final IOException e) {serverLog.logSevere("yacyVersion", "download of " + release.name + " failed: " + e.getMessage());- if (download != null && download.exists()) download.delete();+ if (download != null && download.exists())+ if(!download.delete())+ serverLog.logWarning("yacyVersion", "could not delete file "+ download);download = null;} finally {if (res != null) {@@ -614,7 +616,7 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya// remove old filesfinal long now = System.currentTimeMillis();- final long deleteAfterMillis = deleteAfterDays * 24 * 60 * 60000l;+ final long deleteAfterMillis = deleteAfterDays * 24L * 60 * 60000;String lastMain = null;String filename;diff --git a/source/de/anomic/ymage/AnimGifEncoder.java b/source/de/anomic/ymage/AnimGifEncoder.javaindex 8c9952940..78497f522 100644--- a/source/de/anomic/ymage/AnimGifEncoder.java+++ b/source/de/anomic/ymage/AnimGifEncoder.java@@ -75,7 +75,7 @@ public class AnimGifEncoder {private boolean m_default_interlace = false;/** The default delay time, */- private final int m_default_delay = 100;+ private final static int m_default_delay = 100;/** Set when looping the set is requested. */private boolean m_loop = true;diff --git a/source/de/anomic/ymage/ymageChart.java b/source/de/anomic/ymage/ymageChart.javaindex 9b9350277..7df6e2091 100644--- a/source/de/anomic/ymage/ymageChart.java+++ b/source/de/anomic/ymage/ymageChart.java@@ -45,8 +45,8 @@ public class ymageChart extends ymageMatrix {String[] colnames = new String[]{"FFFFFF","FFFFFF","FFFFFF","FFFFFF","FFFFFF"};String[] colscale = new String[]{null,null,null,null,null};String[] tablenames = new String[]{"","","","",""};- String name;- String backgroundColor, foregroundColor;+ //String name;+ //String backgroundColor, foregroundColor;public ymageChart(final int width, final int height, final String backgroundColor, final String foregroundColor, final String lightColor,final int leftborder, final int rightborder, final int topborder, final int bottomborder,@@ -56,9 +56,9 @@ public class ymageChart extends ymageMatrix {this.rightborder = rightborder;this.topborder = topborder;this.bottomborder = bottomborder;- this.name = name;- this.backgroundColor = backgroundColor;- this.foregroundColor = foregroundColor;+ //this.name = name;+ //this.backgroundColor = backgroundColor;+ //this.foregroundColor = foregroundColor;if (name != null) {this.setColor(foregroundColor);ymageToolPrint.print(this, width / 2 - name.length() * 3, 6, 0, name, -1);diff --git a/source/de/anomic/ymage/ymageFontGenerator.java b/source/de/anomic/ymage/ymageFontGenerator.javaindex 70359b9a2..37811c859 100644--- a/source/de/anomic/ymage/ymageFontGenerator.java+++ b/source/de/anomic/ymage/ymageFontGenerator.java@@ -38,7 +38,7 @@ public class ymageFontGenerator {0x78:xyz{|}~*/- public static final String[][] font =+ private static final String[][] font ={{".....", //0x20".....",diff --git a/source/de/anomic/ymage/ymageGraph.java b/source/de/anomic/ymage/ymageGraph.javaindex 4409d8fee..b70c16569 100644--- a/source/de/anomic/ymage/ymageGraph.java+++ b/source/de/anomic/ymage/ymageGraph.java@@ -92,7 +92,7 @@ public class ymageGraph {borders.add(fromPoint + "$" + toPoint);}- public class coordinate {+ public static class coordinate {public double x, y;public int layer;public coordinate(final double x, final double y, final int layer) {diff --git a/source/de/anomic/ymage/ymageICOParser.java b/source/de/anomic/ymage/ymageICOParser.javaindex a64623f5a..b089a0769 100644--- a/source/de/anomic/ymage/ymageICOParser.java+++ b/source/de/anomic/ymage/ymageICOParser.java@@ -36,7 +36,7 @@ public class ymageICOParser {// this is a implementation of http://msdn2.microsoft.com/en-us/library/ms997538(d=printer).aspx- public static int ICONDIRENTRY_size = 16;+ public static final int ICONDIRENTRY_size = 16;private final int idCount;ymageBMPParser.INFOHEADER[] infoheaders;@@ -65,7 +65,7 @@ public class ymageICOParser {}- public class ICONDIRENTRY {+ public static class ICONDIRENTRY {public int bWidth, bHeight, bColorCount, bReserved, wPlanes, wBitCount, dwBytesInRes, dwImageOffset;diff --git a/source/de/anomic/ymage/ymageMatrix.java b/source/de/anomic/ymage/ymageMatrix.javaindex df5db2a6a..1b7655d7f 100644--- a/source/de/anomic/ymage/ymageMatrix.java+++ b/source/de/anomic/ymage/ymageMatrix.java@@ -130,9 +130,9 @@ public class ymageMatrix {final int r = (int) (c >> 16);final int g = (int) ((c >> 8) & 0xff);final int b = (int) (c & 0xff);- defaultCol[0] = (g + b) / 2;- defaultCol[1] = (r + b) / 2;- defaultCol[2] = (r + g) / 2;+ defaultCol[0] = (g + b) >>> 1; // / 2;+ defaultCol[1] = (r + b) >>> 1; // / 2;+ defaultCol[2] = (r + g) >>> 1; // / 2;} else {defaultCol[0] = (int) (c >> 16);defaultCol[1] = (int) ((c >> 8) & 0xff);diff --git a/source/migration.java b/source/migration.javaindex 07ed6ee48..f094a8c9c 100644--- a/source/migration.java+++ b/source/migration.java@@ -59,29 +59,29 @@ public class migration {public static void migrateDefaultFiles(final plasmaSwitchboard sb){File file=new File(sb.htDocsPath, "share/dir.html");if(file.exists())- file.delete();+ delete(file);file=new File(sb.htDocsPath, "share/dir.class");if(file.exists())- file.delete();+ delete(file);file=new File(sb.htDocsPath, "share/dir.java");if(file.exists())- file.delete();+ delete(file);file=new File(sb.htDocsPath, "www/welcome.html");if(file.exists())- file.delete();+ delete(file);file=new File(sb.htDocsPath, "www/welcome.java");if(file.exists())- file.delete();+ delete(file);file=new File(sb.htDocsPath, "www/welcome.class");if(file.exists())- file.delete();+ delete(file);}public static void installSkins(final plasmaSwitchboard sb){final File skinsPath = sb.getConfigPath("skinPath", "DATA/SKINS");final File defaultSkinsPath = new File(sb.getRootPath(), "skins");if(defaultSkinsPath.exists()){final String[] skinFiles = listManager.getDirListing(defaultSkinsPath.getAbsolutePath());- skinsPath.mkdirs();+ mkdirs(skinsPath);for(int i=0;i<skinFiles.length;i++){if(skinFiles[i].endsWith(".css")){try{@@ -106,7 +106,7 @@ public class migration {}}else{try {- styleFile.getParentFile().mkdirs();+ mkdirs(styleFile.getParentFile());serverFileUtils.copy(skinFile, styleFile);serverLog.logInfo("MIGRATION", "copied new Skinfile");} catch (final IOException e) {@@ -114,15 +114,33 @@ public class migration {}}}++ /**+ * @param path+ */+ private static void mkdirs(final File path) {+ if (!path.exists()) {+ if(!path.mkdirs())+ serverLog.logWarning("MIGRATION", "could not create directories for "+ path);+ }+ }public static void migrateBookmarkTagsDB(final plasmaSwitchboard sb){sb.bookmarksDB.close();final File tagsDBFile=new File(sb.workPath, "bookmarkTags.db");if(tagsDBFile.exists()){- tagsDBFile.delete();+ delete(tagsDBFile);serverLog.logInfo("MIGRATION", "Migrating bookmarkTags.db to use wordhashs as keys.");}sb.initBookmarks();}++ /**+ * @param filename+ */+ private static void delete(final File filename) {+ if(!filename.delete())+ serverLog.logWarning("MIGRATION", "could not delete "+ filename);+ }public static void migrateWorkFiles(final plasmaSwitchboard sb){File file=new File(sb.getRootPath(), "DATA/SETTINGS/wiki.db");File file2;diff --git a/source/yacy.java b/source/yacy.javaindex 7c702601c..c6cdb8016 100644--- a/source/yacy.java+++ b/source/yacy.java@@ -173,8 +173,10 @@ public final class yacy {}// ensure that there is a DATA directory, if not, create one and if that fails warn and die- File f = homePath; if (!(f.exists())) f.mkdirs();- f = new File(homePath, "DATA/"); if (!(f.exists())) f.mkdirs();+ File f = homePath;+ mkdirsIfNeseccary(f);+ f = new File(homePath, "DATA/");+ mkdirsIfNeseccary(f);if (!(f.exists())) {System.err.println("Error creating DATA-directory in " + homePath.toString() + " . Please check your write-permission for this folder. YaCy will now terminate.");System.exit(-1);@@ -182,7 +184,7 @@ public final class yacy {// setting up loggingf = new File(homePath, "DATA/LOG/");- if (!f.exists()) f.mkdirs();+ mkdirsIfNeseccary(f);f = new File(homePath, "DATA/LOG/yacy.logging");if (!f.exists()) try {serverFileUtils.copy(new File(homePath, "yacy.logging"), f);@@ -204,9 +206,10 @@ public final class yacy {f = new File(homePath, "DATA/yacy.running");if (f.exists()) { // another instance running? VM crash? User will have to care about thisserverLog.logSevere("STARTUP", "WARNING: the file " + f + " exists, this usually means that a YaCy instance is still running");- f.delete();+ delete(f);}- f.createNewFile();+ if(!f.createNewFile())+ serverLog.logSevere("STARTUP", "WARNING: the file " + f + " can not be created!");f.deleteOnExit();pro = new File(homePath, "libx").exists();@@ -214,7 +217,9 @@ public final class yacy {final String newconf = "DATA/SETTINGS/yacy.conf".replace("/", File.separator);final File oldconffile = new File(homePath, oldconf);if (oldconffile.exists()) {- oldconffile.renameTo(new File(homePath, newconf));+ final File newconfFile = new File(homePath, newconf);+ if(!oldconffile.renameTo(newconfFile))+ serverLog.logSevere("STARTUP", "WARNING: the file " + oldconffile + " can not be renamed to "+ newconfFile +"!");}sb = new plasmaSwitchboard(homePath, "defaults/yacy.init".replace("/", File.separator), newconf, pro);sbSync.V(); // signal that the sb reference was set@@ -270,7 +275,7 @@ public final class yacy {// create some directoriesfinal File htRootPath = new File(homePath, sb.getConfig("htRootPath", "htroot"));final File htDocsPath = sb.getConfigPath(plasmaSwitchboardConstants.HTDOCS_PATH, plasmaSwitchboardConstants.HTDOCS_PATH_DEFAULT);- if (!(htDocsPath.exists())) htDocsPath.mkdir();+ mkdirIfNeseccary(htDocsPath);//final File htTemplatePath = new File(homePath, sb.getConfig("htTemplatePath","htdocs"));// create default notifier picture@@ -298,11 +303,11 @@ public final class yacy {}final File wwwDefaultPath = new File(htDocsPath, "www");- if (!(wwwDefaultPath.exists())) wwwDefaultPath.mkdir();+ mkdirIfNeseccary(wwwDefaultPath);final File shareDefaultPath = new File(htDocsPath, "share");- if (!(shareDefaultPath.exists())) shareDefaultPath.mkdir();+ mkdirIfNeseccary(shareDefaultPath);migration.migrate(sb, oldRev, newRev);@@ -353,12 +358,12 @@ public final class yacy {final File locale_source = sb.getConfigPath("locale.source", "locales");try{final File[] locale_source_files = locale_source.listFiles();- locale_work.mkdirs();+ mkdirsIfNeseccary(locale_work);File target;for (int i=0; i < locale_source_files.length; i++){target = new File(locale_work, locale_source_files[i].getName());if (locale_source_files[i].getName().endsWith(".lng")) {- if (target.exists()) target.delete();+ if (target.exists()) delete(target);serverFileUtils.copy(locale_source_files[i], target);}}@@ -458,7 +463,35 @@ public final class yacy {//} catch (Exception e) {} // was once stopped by de.anomic.net.ftpc$sm.checkExit(ftpc.java:1790)}- /**+ /**+ * @param f+ */+ private static void delete(File f) {+ if(!f.delete())+ serverLog.logSevere("STARTUP", "WARNING: the file " + f + " can not be deleted!");+ }++ /**+ * @see File#mkdir()+ * @param path+ */+ private static void mkdirIfNeseccary(final File path) {+ if (!(path.exists()))+ if(!path.mkdir())+ serverLog.logWarning("STARTUP", "could not create directory "+ path.toString());+ }++ /**+ * @see File#mkdirs()+ * @param path+ */+ private static void mkdirsIfNeseccary(final File path) {+ if (!(path.exists()))+ if(!path.mkdirs())+ serverLog.logWarning("STARTUP", "could not create directories "+ path.toString());+ }++ /*** Loads the configuration from the data-folder.* FIXME: Why is this called over and over again from every method, instead* of setting the configurationdata once for this class in main?@@ -479,14 +512,24 @@ public final class yacy {}final Properties config = new Properties();- try {- config.load(new FileInputStream(new File(homePath, "DATA/SETTINGS/yacy.conf")));+ FileInputStream fis = null;+ try {+ fis = new FileInputStream(new File(homePath, "DATA/SETTINGS/yacy.conf"));+ config.load(fis);} catch (final FileNotFoundException e) {serverLog.logSevere(mes, "could not find configuration file.");System.exit(-1);} catch (final IOException e) {serverLog.logSevere(mes, "could not read configuration file.");System.exit(-1);+ } finally {+ if(fis != null) {+ try {+ fis.close();+ } catch (IOException e) {+ e.printStackTrace();+ }+ }}return config;