diff --git a/htroot/ViewFile.java b/htroot/ViewFile.java index 037b4347e..fb184d434 100644 --- a/htroot/ViewFile.java +++ b/htroot/ViewFile.java @@ -148,12 +148,7 @@ public class ViewFile { // trying to load the resource body resource = plasmaHTCache.getResourceContentStream(url); resourceLength = plasmaHTCache.getResourceContentLength(url); - try { - responseHeader = plasmaHTCache.loadResponseHeader(url); - } catch (IllegalAccessException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } + responseHeader = plasmaHTCache.loadResponseHeader(url); // if the resource body was not cached we try to load it from web if (resource == null) { diff --git a/source/de/anomic/crawler/CrawlSwitchboard.java b/source/de/anomic/crawler/CrawlSwitchboard.java index 794e7069a..1b3b6fcc8 100644 --- a/source/de/anomic/crawler/CrawlSwitchboard.java +++ b/source/de/anomic/crawler/CrawlSwitchboard.java @@ -71,7 +71,7 @@ public final class CrawlSwitchboard { final yacySeedDB peers, final String networkName, final Log log, - final File queuesRoot) throws IOException { + final File queuesRoot) { log.logInfo("Initializing Word Index for the network '" + networkName + "', word hash cache size is " + Word.hashCacheSize + "."); diff --git a/source/de/anomic/data/wiki/abstractWikiParser.java b/source/de/anomic/data/wiki/abstractWikiParser.java index 48c100ecb..a7255cb1c 100644 --- a/source/de/anomic/data/wiki/abstractWikiParser.java +++ b/source/de/anomic/data/wiki/abstractWikiParser.java @@ -41,7 +41,7 @@ public abstract class abstractWikiParser implements wikiParser { return transform(content, "UTF-8"); } - public String transform(final byte[] content, final String encoding, final String publicAddress) throws UnsupportedEncodingException { + public String transform(final byte[] content, final String encoding, final String publicAddress) { final ByteArrayInputStream bais = new ByteArrayInputStream(content); try { return transform( diff --git a/source/de/anomic/data/wiki/knwikiParser.java b/source/de/anomic/data/wiki/knwikiParser.java index c2cfc5240..893669dca 100644 --- a/source/de/anomic/data/wiki/knwikiParser.java +++ b/source/de/anomic/data/wiki/knwikiParser.java @@ -192,16 +192,13 @@ public class knwikiParser implements wikiParser { public static final String escapeNewLine = "@"; private String text; - private final boolean escaped; private final boolean nl; public Text(final String text, final boolean escaped, final boolean newLineBefore) { this.text = text; - this.escaped = escaped; this.nl = newLineBefore; } - public String setTextPlain(final String text) { return this.text = text; } public String setText(final String text) { if (this.nl) this.text = text.substring(escapeNewLine.length()); @@ -218,8 +215,6 @@ public class knwikiParser implements wikiParser { } public String toString() { return this.text; } - public boolean isEscaped() { return this.escaped; } - public boolean isNewLineBefore() { return this.nl; } static Text[] split2Texts(final String text, final String escapeBegin, final String escapeEnd) { if (text == null) return null; diff --git a/source/de/anomic/http/httpdBoundedSizeOutputStream.java b/source/de/anomic/http/httpdBoundedSizeOutputStream.java index a638897af..fa0d849c0 100644 --- a/source/de/anomic/http/httpdBoundedSizeOutputStream.java +++ b/source/de/anomic/http/httpdBoundedSizeOutputStream.java @@ -52,7 +52,7 @@ public class httpdBoundedSizeOutputStream extends httpdByteCountOutputStream { super.write(b); } - public void write(final byte[] b, final int off, final int len) throws IOException { + public synchronized void write(final byte[] b, final int off, final int len) throws IOException { if (this.byteCount + len > this.maxSize) { // write out the rest until we reach the limit final long rest = this.maxSize-this.byteCount; @@ -64,7 +64,7 @@ public class httpdBoundedSizeOutputStream extends httpdByteCountOutputStream { super.write(b, off, len); } - public void write(final int b) throws IOException { + public synchronized void write(final int b) throws IOException { if (this.byteCount + 1 > this.maxSize) { // throw an exception throw new httpdLimitExceededException("Limit exceeded",this.maxSize); diff --git a/source/de/anomic/kelondro/blob/Compressor.java b/source/de/anomic/kelondro/blob/Compressor.java index 6d9ffe86a..efe9d33cf 100644 --- a/source/de/anomic/kelondro/blob/Compressor.java +++ b/source/de/anomic/kelondro/blob/Compressor.java @@ -205,7 +205,7 @@ public class Compressor implements BLOB { return (b == null) ? 0 : b.length; } - private int removeFromQueues(byte[] key) throws IOException { + private int removeFromQueues(byte[] key) { byte[] b = buffer.remove(new String(key)); if (b != null) return b.length; return 0; diff --git a/source/de/anomic/kelondro/blob/Heap.java b/source/de/anomic/kelondro/blob/Heap.java index 2558e5215..b8b75374b 100755 --- a/source/de/anomic/kelondro/blob/Heap.java +++ b/source/de/anomic/kelondro/blob/Heap.java @@ -317,7 +317,7 @@ public final class Heap extends HeapModifier implements BLOB { if (entry.getValue().intValue() == reclen) { // we found an entry that has exactly the size that we need! // we use that entry and stop looking for a larger entry - file.seek(entry.getKey()); + file.seek(entry.getKey().longValue()); final int reclenf = file.readInt(); assert reclenf == reclen; file.write(key); @@ -419,7 +419,7 @@ public final class Heap extends HeapModifier implements BLOB { return super.keys(up, firstKey); } - public synchronized long length() throws IOException { + public synchronized long length() { return super.length() + this.buffersize; } diff --git a/source/de/anomic/kelondro/blob/HeapReader.java b/source/de/anomic/kelondro/blob/HeapReader.java index 5649462de..cc94427ed 100644 --- a/source/de/anomic/kelondro/blob/HeapReader.java +++ b/source/de/anomic/kelondro/blob/HeapReader.java @@ -368,7 +368,7 @@ public class HeapReader { return this.index.keys(up, firstKey); } - public long length() throws IOException { + public long length() { return this.heapFile.length(); } diff --git a/source/de/anomic/kelondro/io/AbstractRandomAccess.java b/source/de/anomic/kelondro/io/AbstractRandomAccess.java index 62bafcdea..3dfecd58f 100644 --- a/source/de/anomic/kelondro/io/AbstractRandomAccess.java +++ b/source/de/anomic/kelondro/io/AbstractRandomAccess.java @@ -92,7 +92,7 @@ public abstract class AbstractRandomAccess implements RandomAccessInterface { this.write(int2array(v)); } - public final static byte[] int2array(final int v) throws IOException { + public final static byte[] int2array(final int v) { byte[] b = new byte[4]; b[0] = (byte) ((v >>> 24) & 0xFF); b[1] = (byte) ((v >>> 16) & 0xFF); diff --git a/source/de/anomic/kelondro/io/ChannelRandomAccess.java b/source/de/anomic/kelondro/io/ChannelRandomAccess.java deleted file mode 100644 index b27332996..000000000 --- a/source/de/anomic/kelondro/io/ChannelRandomAccess.java +++ /dev/null @@ -1,82 +0,0 @@ -// kelondroFileRA.java -// ----------------------- -// part of The Kelondro Database -// (C) by Michael Peter Christen; mc@yacy.net -// first published on http://www.anomic.de -// Frankfurt, Germany, 2004 -// last major change: 05.02.2004 -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -package de.anomic.kelondro.io; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; - - -public final class ChannelRandomAccess extends AbstractRandomAccess implements RandomAccessInterface { - - private FileChannel channel; - private RandomAccessFile raf; - - public ChannelRandomAccess(final File file) throws IOException, FileNotFoundException { - this.name = file.getName(); - this.file = file; - this.raf = new RandomAccessFile(file, "rw"); - this.channel = raf.getChannel(); - } - - public long length() throws IOException { - return channel.size(); - } - - public void setLength(long length) throws IOException { - channel.truncate(length); - } - - public long available() throws IOException { - return channel.size() - channel.position(); - } - - public final void readFully(final byte[] b, final int off, final int len) throws IOException { - ByteBuffer bb = ByteBuffer.wrap(b); - channel.read(bb); - } - - public void write(final byte[] b, final int off, final int len) throws IOException { - ByteBuffer bb = ByteBuffer.wrap(b, off, len); - channel.write(bb); - } - - public void seek(final long pos) throws IOException { - channel.position(pos); - } - - public void close() throws IOException { - channel.close(); - raf.close(); - } - - protected void finalize() throws Throwable { - if (channel != null) { - this.close(); - } - super.finalize(); - } -} diff --git a/source/de/anomic/kelondro/table/Records.java b/source/de/anomic/kelondro/table/Records.java index a1afcfaf1..b6ce1a529 100644 --- a/source/de/anomic/kelondro/table/Records.java +++ b/source/de/anomic/kelondro/table/Records.java @@ -41,7 +41,6 @@ import java.util.logging.Logger; import de.anomic.kelondro.index.Column; import de.anomic.kelondro.index.Row; import de.anomic.kelondro.index.Row.EntryIndex; -import de.anomic.kelondro.io.ChannelRandomAccess; import de.anomic.kelondro.io.FileRandomAccess; import de.anomic.kelondro.io.IOChunksInterface; import de.anomic.kelondro.io.RandomAccessInterface; @@ -53,8 +52,6 @@ import de.anomic.kelondro.util.kelondroException; import de.anomic.yacy.logging.Log; public class Records { - - private static final boolean useChannel = false; // static seek pointers private static int LEN_DESCR = 60; @@ -354,7 +351,7 @@ public class Records { public static int staticsize(final File file) { if (!(file.exists())) return 0; try { - final RandomAccessInterface ra = (useChannel) ? new ChannelRandomAccess(new File(file.getCanonicalPath())) : new FileRandomAccess(new File(file.getCanonicalPath())); + final RandomAccessInterface ra = new FileRandomAccess(new File(file.getCanonicalPath())); final IOChunksInterface entryFile = new RandomAccessIOChunks(ra, ra.name()); final int used = entryFile.readInt(POS_USEDC); // works only if consistency with file size is given @@ -388,7 +385,7 @@ public class Records { if (file.exists()) { // opens an existing tree this.filename = file.getCanonicalPath(); - RandomAccessInterface raf = (useChannel) ? new ChannelRandomAccess(new File(this.filename)) : new FileRandomAccess(new File(this.filename)); + RandomAccessInterface raf = new FileRandomAccess(new File(this.filename)); //kelondroRA raf = new kelondroBufferedRA(new kelondroFileRA(this.filename), 1024, 100); //kelondroRA raf = new kelondroCachedRA(new kelondroFileRA(this.filename), 5000000, 1000); //kelondroRA raf = new kelondroNIOFileRA(this.filename, (file.length() < 4000000), 10000); @@ -396,7 +393,7 @@ public class Records { initExistingFile(raf); } else { this.filename = file.getCanonicalPath(); - final RandomAccessInterface raf = (useChannel) ? new ChannelRandomAccess(new File(this.filename)) : new FileRandomAccess(new File(this.filename)); + final RandomAccessInterface raf = new FileRandomAccess(new File(this.filename)); // kelondroRA raf = new kelondroBufferedRA(new kelondroFileRA(this.filename), 1024, 100); // kelondroRA raf = new kelondroNIOFileRA(this.filename, false, 10000); initNewFile(raf, FHandles, txtProps); @@ -420,7 +417,7 @@ public class Records { assert f != null; this.entryFile.close(); FileUtils.deletedelete(f); - ra = (useChannel) ? new ChannelRandomAccess(f) : new FileRandomAccess(f); + ra = new FileRandomAccess(f); initNewFile(ra, this.HANDLES.length, this.TXTPROPS.length); } diff --git a/source/de/anomic/kelondro/table/SQLTable.java b/source/de/anomic/kelondro/table/SQLTable.java index 454664a14..e19358dfe 100644 --- a/source/de/anomic/kelondro/table/SQLTable.java +++ b/source/de/anomic/kelondro/table/SQLTable.java @@ -225,7 +225,7 @@ public class SQLTable implements ObjectIndex { throw new UnsupportedOperationException(); } - public synchronized void addUnique(final List rows) throws IOException { + public synchronized void addUnique(final List rows) { throw new UnsupportedOperationException(); } diff --git a/source/de/anomic/kelondro/table/Table.java b/source/de/anomic/kelondro/table/Table.java index 429e37d5c..a6c19833b 100644 --- a/source/de/anomic/kelondro/table/Table.java +++ b/source/de/anomic/kelondro/table/Table.java @@ -646,7 +646,7 @@ public class Table implements ObjectIndex { byte[] fk; int c; - public rowIterator(final boolean up, final byte[] firstKey) throws IOException { + public rowIterator(final boolean up, final byte[] firstKey) { this.up = up; this.fk = firstKey; this.i = index.keys(up, firstKey); @@ -654,12 +654,7 @@ public class Table implements ObjectIndex { } public CloneableIterator clone(final Object modifier) { - try { - return new rowIterator(up, fk); - } catch (final IOException e) { - e.printStackTrace(); - return null; - } + return new rowIterator(up, fk); } public boolean hasNext() { diff --git a/source/de/anomic/kelondro/text/ReferenceContainer.java b/source/de/anomic/kelondro/text/ReferenceContainer.java index 9315b6348..cbdee18d6 100644 --- a/source/de/anomic/kelondro/text/ReferenceContainer.java +++ b/source/de/anomic/kelondro/text/ReferenceContainer.java @@ -495,7 +495,7 @@ public class ReferenceContainer extends RowSet return pivot; } - public String toString() { + public synchronized String toString() { return "C[" + new String(termHash) + "] has " + this.size() + " entries"; } diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.java index b6b1d585e..cfe47726a 100644 --- a/source/de/anomic/plasma/plasmaHTCache.java +++ b/source/de/anomic/plasma/plasmaHTCache.java @@ -241,7 +241,7 @@ public final class plasmaHTCache { * @throws UnsupportedProtocolException if the protocol is not supported and therefore the * info object couldn't be created */ - public static httpResponseHeader loadResponseHeader(final yacyURL url) throws IllegalAccessException { + public static httpResponseHeader loadResponseHeader(final yacyURL url) { // loading data from database Map hdb; diff --git a/source/de/anomic/server/serverInstantBlockingThread.java b/source/de/anomic/server/serverInstantBlockingThread.java index 4e27ef4a2..62e3ddfd3 100644 --- a/source/de/anomic/server/serverInstantBlockingThread.java +++ b/source/de/anomic/server/serverInstantBlockingThread.java @@ -48,13 +48,13 @@ public class serverInstantBlockingThread extends s // define execution class this.jobExecMethod = execMethod(env, jobExec); - this.environment = (env instanceof Class) ? null : env; + this.environment = (env instanceof Class) ? null : env; this.setName(jobExecMethod.getClass().getName() + "." + jobExecMethod.getName() + "." + handleCounter++); this.handle = Long.valueOf(System.currentTimeMillis() + this.getName().hashCode()); } protected static Method execMethod(final Object env, final String jobExec) { - final Class theClass = (env instanceof Class) ? (Class) env : env.getClass(); + final Class theClass = (env instanceof Class) ? (Class) env : env.getClass(); try { final Method[] methods = theClass.getMethods(); for (int i = 0; i < methods.length; i++) { diff --git a/source/de/anomic/server/serverInstantBusyThread.java b/source/de/anomic/server/serverInstantBusyThread.java index a955a4663..77cc0007c 100644 --- a/source/de/anomic/server/serverInstantBusyThread.java +++ b/source/de/anomic/server/serverInstantBusyThread.java @@ -40,7 +40,7 @@ public final class serverInstantBusyThread extends serverAbstractBusyThread impl // jobExec is the name of a method of the object 'env' that executes the one-step-run // jobCount is the name of a method that returns the size of the job // freemem is the name of a method that tries to free memory and returns void - final Class theClass = (env instanceof Class) ? (Class) env : env.getClass(); + final Class theClass = (env instanceof Class) ? (Class) env : env.getClass(); try { this.jobExecMethod = theClass.getMethod(jobExec, new Class[0]); } catch (final NoSuchMethodException e) { @@ -64,7 +64,7 @@ public final class serverInstantBusyThread extends serverAbstractBusyThread impl } catch (final NoSuchMethodException e) { throw new RuntimeException("serverInstantThread, wrong declaration of freemem: " + e.getMessage()); } - this.environment = (env instanceof Class) ? null : env; + this.environment = (env instanceof Class) ? null : env; this.setName(theClass.getName() + "." + jobExec); this.handle = Long.valueOf(System.currentTimeMillis() + this.getName().hashCode()); } diff --git a/source/de/anomic/yacy/logging/ConsoleOutErrHandler.java b/source/de/anomic/yacy/logging/ConsoleOutErrHandler.java index 30f39d69d..81b6a6385 100644 --- a/source/de/anomic/yacy/logging/ConsoleOutErrHandler.java +++ b/source/de/anomic/yacy/logging/ConsoleOutErrHandler.java @@ -150,7 +150,7 @@ public final class ConsoleOutErrHandler extends Handler { this.stdErrHandler.close(); } - public void setLevel(final Level newLevel) throws SecurityException { + public synchronized void setLevel(final Level newLevel) throws SecurityException { super.setLevel(newLevel); } diff --git a/source/de/anomic/yacy/logging/ConsoleOutHandler.java b/source/de/anomic/yacy/logging/ConsoleOutHandler.java index b218b7900..26319c76f 100644 --- a/source/de/anomic/yacy/logging/ConsoleOutHandler.java +++ b/source/de/anomic/yacy/logging/ConsoleOutHandler.java @@ -38,12 +38,12 @@ public final class ConsoleOutHandler extends StreamHandler { setOutputStream(System.out); } - public void publish(final LogRecord record) { + public synchronized void publish(final LogRecord record) { super.publish(record); flush(); } - public void close() { + public synchronized void close() { flush(); } } diff --git a/source/de/anomic/yacy/logging/MiniLogFormatter.java b/source/de/anomic/yacy/logging/MiniLogFormatter.java index 1c09c6033..feb1de176 100644 --- a/source/de/anomic/yacy/logging/MiniLogFormatter.java +++ b/source/de/anomic/yacy/logging/MiniLogFormatter.java @@ -36,7 +36,7 @@ public final class MiniLogFormatter extends SimpleFormatter { super(); } - public String format(final LogRecord record) { + public synchronized String format(final LogRecord record) { final StringBuilder buffer = this.buffer; buffer.setLength(0); diff --git a/source/de/anomic/yacy/logging/SimpleLogFormatter.java b/source/de/anomic/yacy/logging/SimpleLogFormatter.java index 611949c34..c90c49868 100644 --- a/source/de/anomic/yacy/logging/SimpleLogFormatter.java +++ b/source/de/anomic/yacy/logging/SimpleLogFormatter.java @@ -50,7 +50,7 @@ public class SimpleLogFormatter extends SimpleFormatter { super(); } - public String format(final LogRecord record) { + public synchronized String format(final LogRecord record) { final StringBuffer buffer = this.buffer; buffer.setLength(0); diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.java index 42d1da530..95d4acf49 100644 --- a/source/de/anomic/yacy/yacySeedDB.java +++ b/source/de/anomic/yacy/yacySeedDB.java @@ -30,7 +30,6 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.lang.ref.SoftReference; -import java.lang.reflect.Method; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; @@ -240,7 +239,6 @@ public final class yacySeedDB implements httpdAlternativeDomainNames { return this.sizeConnected() <= dhtActivityMagic; } - @SuppressWarnings("unchecked") private synchronized MapDataMining openSeedTable(final File seedDBFile) { final File parentDir = new File(seedDBFile.getParent()); if (!parentDir.exists()) {