about 20 findbugs fixes all over

This commit is contained in:
zzz
2013-11-10 20:07:46 +00:00
parent 0a8f79f0e3
commit d2a1025b3f
16 changed files with 92 additions and 38 deletions

View File

@@ -232,7 +232,7 @@ public class Snark
private byte[] id;
private final byte[] infoHash;
private String additionalTrackerURL;
private final I2PSnarkUtil _util;
protected final I2PSnarkUtil _util;
private final Log _log;
private final PeerCoordinatorSet _peerCoordinatorSet;
private volatile String trackerProblems;

View File

@@ -531,7 +531,7 @@ public class SnarkManager implements CompleteListener {
_util.setStartupDelay(minutes);
changed = true;
_config.setProperty(PROP_STARTUP_DELAY, Integer.toString(minutes));
addMessage(_("Startup delay changed to {0}", DataHelper.formatDuration2(minutes * 60 * 1000)));
addMessage(_("Startup delay changed to {0}", DataHelper.formatDuration2(minutes * (60L * 1000))));
}
}
@@ -1489,7 +1489,7 @@ public class SnarkManager implements CompleteListener {
private class DirMonitor implements Runnable {
public void run() {
// don't bother delaying if auto start is false
long delay = 60 * 1000 * getStartupDelayMinutes();
long delay = (60L * 1000) * getStartupDelayMinutes();
if (delay > 0 && shouldAutoStart()) {
addMessage(_("Adding torrents in {0}", DataHelper.formatDuration2(delay)));
try { Thread.sleep(delay); } catch (InterruptedException ie) {}

View File

@@ -60,7 +60,7 @@ public class BDecoder
private int indicator = 0;
// Used for ugly hack to get SHA hash over the metainfo info map
private final String special_map = "info";
private static final String special_map = "info";
private boolean in_special_map = false;
/** creation deferred until we encounter the special map, to make processing of announce replies more efficient */
private MessageDigest sha_digest;

View File

@@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
import net.i2p.I2PAppContext;
import net.i2p.data.ByteArray;
import net.i2p.data.DataHelper;
import net.i2p.util.ByteCache;
import net.i2p.util.Log;
import net.i2p.util.SystemVersion;
@@ -469,7 +470,7 @@ class BasicServlet extends HttpServlet
{
String cpath = getServletContext().getContextPath();
// this won't work if we aren't at top level
String cname = cpath == "" ? "i2psnark" : cpath.substring(1).replace("/", "_");
String cname = "".equals(cpath) ? "i2psnark" : cpath.substring(1).replace("/", "_");
return (new File(_context.getBaseDir(), "webapps/" + cname + ".war")).lastModified();
}
@@ -578,7 +579,7 @@ class BasicServlet extends HttpServlet
byte[] buf = ba.getData();
try {
if (skip > 0)
in.skip(skip);
DataHelper.skip(in, skip);
int read = 0;
long tot = 0;
boolean done = false;

View File

@@ -198,7 +198,7 @@ public class FetchAndAdd extends Snark implements EepGet.StatusListener, Runnabl
//_total = -1;
_transferred = 0;
_failCause = null;
_started = _ctx.clock().now();
_started = _util.getContext().clock().now();
_isRunning = true;
_active = false;
_thread = new I2PAppThread(this, "Torrent File EepGet", true);

View File

@@ -71,7 +71,7 @@ abstract class IRCFilter {
// Allow numerical responses
try {
Integer.valueOf(command);
Integer.parseInt(command);
return s;
} catch(NumberFormatException nfe){}

View File

@@ -238,8 +238,8 @@ public class ConfigNetHelper extends HelperBase {
return kbytesToBits(getShareBandwidth());
}
private String kbytesToBits(int kbytes) {
return DataHelper.formatSize(kbytes * 8 * 1024) + ' ' + _("bits per second") +
' ' + _("or {0} bytes per month maximum", DataHelper.formatSize(kbytes * 1024l * 60 * 60 * 24 * 31));
return DataHelper.formatSize(kbytes * (8 * 1024L)) + ' ' + _("bits per second") +
' ' + _("or {0} bytes per month maximum", DataHelper.formatSize(kbytes * (1024L * 60 * 60 * 24 * 31)));
}
public String getInboundBurstRate() {
return "" + _context.bandwidthLimiter().getInboundBurstKBytesPerSecond();

View File

@@ -435,11 +435,11 @@ public class MultiPartRequest
}
/* ------------------------------------------------------------ */
private class Part
private static class Part
{
String _name=null;
String _filename=null;
String _name;
String _filename;
Hashtable _headers= new Hashtable(10);
byte[] _data=null;
byte[] _data;
}
};