removed call to class.finalize() because of deprecation in java 9

next: removal of finalize() implementation
after testing with assert false
pull/419/head
Michael Peter Christen 4 years ago
parent 9ef4503672
commit 9e13d77de4

@ -152,7 +152,6 @@ public class Handler implements IInArchive {
protected void finalize() throws Throwable {
close();
super.finalize();
}
public void close() throws IOException {

@ -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() {
@ -149,7 +148,7 @@ public class NoticedURL {
}
public boolean isEmpty() {
if (!isEmptyLocal()) return false;
if (!this.isEmptyLocal()) return false;
if (this.remoteStack != null && !this.remoteStack.isEmpty()) return false;
return true;
}
@ -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);
}

@ -51,7 +51,7 @@ public final class CachedFileReader extends AbstractReader implements Reader {
@Override
public 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 {
@Override
public 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;
}
@Override
public final synchronized void seek(final long pos) throws IOException {
RAFile.seek(pos);
this.RAFile.seek(pos);
}
@Override
public 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 {
@Override
protected void finalize() throws Throwable {
this.close();
super.finalize();
}
}

@ -50,27 +50,27 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {
@Override
public final synchronized long length() throws IOException {
checkReopen();
this.checkReopen();
return this.RAFile.length();
}
@Override
public final synchronized void setLength(long length) throws IOException {
checkReopen();
this.checkReopen();
this.cachelen = 0;
this.RAFile.setLength(length);
}
@Override
public final synchronized long available() throws IOException {
checkReopen();
this.checkReopen();
return this.length() - this.RAFile.getFilePointer();
}
@Override
public 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;
@ -108,17 +108,17 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {
@Override
public final synchronized void write(final byte[] b, final int off, final int len) throws IOException {
checkReopen();
this.checkReopen();
//assert len > 0;
// write to file
if (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 cache
System.arraycopy(b, off, this.cache, this.cachelen, len);
@ -139,7 +139,7 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {
@Override
public final synchronized void seek(final long pos) throws IOException {
checkReopen();
this.checkReopen();
this.RAFile.seek(pos);
}
@ -173,7 +173,6 @@ public final class CachedFileWriter extends AbstractWriter implements Writer {
@Override
protected final void finalize() throws Throwable {
this.close();
super.finalize();
}
}

@ -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 {
@Override
protected final void finalize() throws Throwable {
if (this.ra != null) this.close();
super.finalize();
}
public final void deleteOnExit() {

Loading…
Cancel
Save