Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
removed call to class.finalize() because of deprecation in java 9 next: removal of finalize() implementation after testing with assert false
Michael Peter Christen9e13d77de4f9
diff --git a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Handler.java b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Handler.javaindex 1f1601ac5..141fd896d 100644--- a/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Handler.java+++ b/libbuild/J7Zip-modified/src/SevenZip/Archive/SevenZip/Handler.java@@ -152,7 +152,6 @@ public class Handler implements IInArchive {protected void finalize() throws Throwable {close();- super.finalize();}public void close() throws IOException {diff --git a/source/net/yacy/crawler/data/NoticedURL.java b/source/net/yacy/crawler/data/NoticedURL.javaindex e0777e3c4..0e188d602 100644--- a/source/net/yacy/crawler/data/NoticedURL.java+++ b/source/net/yacy/crawler/data/NoticedURL.java@@ -58,16 +58,16 @@ public class NoticedURL {/** links found by crawling to depth-1 */private Balancer coreStack;-+/** links found by crawling at target depth */private Balancer limitStack;-+/** links from remote crawl orders (init on demand) */private Balancer remoteStack;-+/** links that are not passed to a loader; the index will be generated from the Request entry */private Balancer noloadStack;-+private final File cachePath;protected NoticedURL(@@ -82,7 +82,7 @@ public class NoticedURL {this.limitStack = new HostBalancer(new File(cachePath, "CrawlerLimitStacks"), onDemandLimit, exceed134217727);this.remoteStack = null; // init on demand (on first push)-+ConcurrentLog.info("NoticedURL", "opening CrawlerNoLoadStacks..");this.noloadStack = new HostBalancer(new File(cachePath, "CrawlerNoLoadStacks"), onDemandLimit, exceed134217727);ConcurrentLog.info("NoticedURL", "FINISHED CREATING STACKS at " + cachePath.toString());@@ -131,9 +131,8 @@ public class NoticedURL {protected void finalize() throws Throwable {if ((this.coreStack != null) || (this.limitStack != null) || (this.remoteStack != null)) {ConcurrentLog.warn("plasmaCrawlNURL", "NURL stack closed by finalizer");- close();+ this.close();}- super.finalize();}public int size() {@@ -147,9 +146,9 @@ public class NoticedURL {if (!this.noloadStack.isEmpty()) return false;return true;}-+public boolean isEmpty() {- if (!isEmptyLocal()) return false;+ if (!this.isEmptyLocal()) return false;if (this.remoteStack != null && !this.remoteStack.isEmpty()) return false;return true;}@@ -163,7 +162,7 @@ public class NoticedURL {default: return true;}}-+public int stackSize(final StackType stackType) {switch (stackType) {case NOLOAD: return (this.noloadStack == null) ? 0 : this.noloadStack.size();@@ -299,9 +298,9 @@ public class NoticedURL {protected void shift(final StackType fromStack, final StackType toStack, final CrawlSwitchboard cs, final RobotsTxt robots) {try {- final Request entry = pop(fromStack, false, cs, robots);+ final Request entry = this.pop(fromStack, false, cs, robots);if (entry != null) {- final String warning = push(toStack, entry, null, robots);+ final String warning = this.push(toStack, entry, null, robots);if (warning != null) {ConcurrentLog.warn("NoticedURL", "shift from " + fromStack + " to " + toStack + ": " + warning);}@@ -346,15 +345,15 @@ public class NoticedURL {// it may be possible that another process has taken alls = balancer.size(); // this time read the size to find errorsif (s == 0) return null; // the balancer is actually empty!-+// if the balancer is not empty, try againentry = balancer.pop(delay, cs, robots);if (entry != null) return entry;-+if (s > balancer.size()) continue; // the balancer has shrinked, thats good, it will terminateerrors++; // bad, if the size does not shrink we are in danger to not terminateif (errors < 100) continue; // there is the possibility that it is not a bug but concurrency, so just ignore it for some time-+// at this point we consider the balancer to be brokenfinal int aftersize = balancer.size(); // get the amount of data that we loosebalancer.clear(); // the balancer is broken and cannot shrinkdiff --git a/source/net/yacy/kelondro/io/CachedFileReader.java b/source/net/yacy/kelondro/io/CachedFileReader.javaindex 4cfc6a198..b7107ebdd 100644--- a/source/net/yacy/kelondro/io/CachedFileReader.java+++ b/source/net/yacy/kelondro/io/CachedFileReader.java@@ -1,4 +1,4 @@-// CachedFileReader.java+// CachedFileReader.java// ---------------------// (C) 2009 by Michael Peter Christen; [email protected]// first published 09.09.2009 on http://yacy.net@@ -48,10 +48,10 @@ public final class CachedFileReader extends AbstractReader implements Reader {}this.cachelen = 0;}-+@Overridepublic final synchronized long available() throws IOException {- return this.length() - RAFile.getFilePointer();+ return this.length() - this.RAFile.getFilePointer();}@Override@@ -61,28 +61,28 @@ public final class CachedFileReader extends AbstractReader implements Reader {@Overridepublic final synchronized void readFully(final byte[] b, final int off, int len) throws IOException {- long seek = RAFile.getFilePointer();- if (cache != null && cachelen - seek >= len) {+ final long seek = this.RAFile.getFilePointer();+ if (this.cache != null && this.cachelen - seek >= len) {// read from cache- System.arraycopy(cache, (int) (seek), b, off, len);- RAFile.seek(seek + len);+ System.arraycopy(this.cache, (int) (seek), b, off, len);+ this.RAFile.seek(seek + len);return;}// cannot use the cache- RAFile.readFully(b, off, len);+ this.RAFile.readFully(b, off, len);return;}@Overridepublic final synchronized void seek(final long pos) throws IOException {- RAFile.seek(pos);+ this.RAFile.seek(pos);}-+@Overridepublic final synchronized void close() {- if (RAFile != null) try {- try{RAFile.getChannel().close();} catch (final IOException e) {}- RAFile.close();+ if (this.RAFile != null) try {+ try{this.RAFile.getChannel().close();} catch (final IOException e) {}+ this.RAFile.close();} catch (final IOException e) {ConcurrentLog.logException(e);}@@ -92,7 +92,6 @@ public final class CachedFileReader extends AbstractReader implements Reader {@Overrideprotected void finalize() throws Throwable {this.close();- super.finalize();}}diff --git a/source/net/yacy/kelondro/io/CachedFileWriter.java b/source/net/yacy/kelondro/io/CachedFileWriter.javaindex e35793dde..e57aa30f6 100644--- a/source/net/yacy/kelondro/io/CachedFileWriter.java+++ b/source/net/yacy/kelondro/io/CachedFileWriter.java@@ -1,4 +1,4 @@-// CachedFileWriter.java+// CachedFileWriter.java// ---------------------------------// part of The Kelondro Database// (C) by Michael Peter Christen; [email protected]@@ -46,31 +46,31 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {this.cache = new byte[32768];this.cachestart = 0;this.cachelen = 0;- }-+ }+@Overridepublic final synchronized long length() throws IOException {- checkReopen();+ this.checkReopen();return this.RAFile.length();}-+@Overridepublic final synchronized void setLength(long length) throws IOException {- checkReopen();+ this.checkReopen();this.cachelen = 0;this.RAFile.setLength(length);}-+@Overridepublic final synchronized long available() throws IOException {- checkReopen();+ this.checkReopen();return this.length() - this.RAFile.getFilePointer();}@Overridepublic final synchronized void readFully(final byte[] b, final int off, int len) throws IOException {- checkReopen();- long seek = this.RAFile.getFilePointer();+ this.checkReopen();+ final long seek = this.RAFile.getFilePointer();if (this.cache != null && this.cachestart <= seek && this.cachelen - seek + this.cachestart >= len) {// read from cache//System.out.println("*** DEBUG FileRA " + this.file.getName() + ": CACHE HIT at " + seek);@@ -84,7 +84,7 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {return;}// we fill the cache here- long available = this.RAFile.length() - seek;+ final long available = this.RAFile.length() - seek;if (available == -seek) return; // we don't know how this happens but we just silently ignore it by now TODO:fixme//System.out.println("*** available = " + available);if (available < len) throw new IOException("EOF in " + this.file.getName() + ", available = " + available + ", requested = " + len + ", this.RAFile.length() = " + this.RAFile.length() + ", seek = " + seek);@@ -95,7 +95,7 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {this.cachelen += len;} else {// fill the cache as much as possible- int m = (int) Math.min(available, this.cache.length);+ final int m = (int) Math.min(available, this.cache.length);this.RAFile.readFully(this.cache, 0, m);this.cachestart = seek;this.cachelen = m;@@ -103,22 +103,22 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {//System.out.println("*** DEBUG FileRA " + this.file.getName() + ": replace fill " + len + " bytes");System.arraycopy(this.cache, 0, b, off, len);}-+}@Overridepublic final synchronized void write(final byte[] b, final int off, final int len) throws IOException {- checkReopen();+ this.checkReopen();//assert len > 0;// write to fileif (this.cache.length > 512) {// the large cache is only useful during an initialization phase- byte[] newcache = new byte[512];+ final byte[] newcache = new byte[512];System.arraycopy(this.cache, 0, newcache, 0, newcache.length);this.cache = newcache;if (this.cachelen > this.cache.length) this.cachelen = this.cache.length;}- long seekpos = this.RAFile.getFilePointer();+ final long seekpos = this.RAFile.getFilePointer();if (this.cachelen + len <= this.cache.length && this.cachestart + this.cachelen == seekpos) {// append to cacheSystem.arraycopy(b, off, this.cache, this.cachelen, len);@@ -139,7 +139,7 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {@Overridepublic final synchronized void seek(final long pos) throws IOException {- checkReopen();+ this.checkReopen();this.RAFile.seek(pos);}@@ -156,7 +156,7 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {this.cache = null;this.RAFile = null;}-+private final void checkReopen() {if (this.RAFile != null) return;// re-open the file@@ -173,7 +173,6 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {@Overrideprotected final void finalize() throws Throwable {this.close();- super.finalize();}}diff --git a/source/net/yacy/kelondro/io/RandomAccessIO.java b/source/net/yacy/kelondro/io/RandomAccessIO.javaindex ea50f7e4d..1672c928b 100644--- a/source/net/yacy/kelondro/io/RandomAccessIO.java+++ b/source/net/yacy/kelondro/io/RandomAccessIO.java@@ -120,22 +120,22 @@ public final class RandomAccessIO {public final synchronized void writeSpace(long pos, int spaceCount) throws IOException {if (spaceCount < 512) {- write(pos, space(spaceCount));+ this.write(pos, space(spaceCount));return;}- byte[] b = space(512);+ final byte[] b = space(512);while (spaceCount > b.length) {- write(pos, b);+ this.write(pos, b);pos += b.length;spaceCount -= b.length;}if (spaceCount > 0) {- write(pos, space(spaceCount));+ this.write(pos, space(spaceCount));}}private final static byte[] space(int count) {- byte[] s = new byte[count];+ final byte[] s = new byte[count];while (count-- > 0) s[count] = 0;return s;}@@ -147,7 +147,6 @@ public final class RandomAccessIO {@Overrideprotected final void finalize() throws Throwable {if (this.ra != null) this.close();- super.finalize();}public final void deleteOnExit() {