diff --git a/apps/BOB/src/net/i2p/BOB/I2Plistener.java b/apps/BOB/src/net/i2p/BOB/I2Plistener.java index 28c053a3a..f862c7cae 100644 --- a/apps/BOB/src/net/i2p/BOB/I2Plistener.java +++ b/apps/BOB/src/net/i2p/BOB/I2Plistener.java @@ -30,16 +30,15 @@ import net.i2p.client.streaming.I2PSocketManager; */ public class I2Plistener implements Runnable { - private NamedDB info, database; - private Logger _log; - public I2PSocketManager socketManager; - public I2PServerSocket serverSocket; - private AtomicBoolean lives; + private final NamedDB info, database; + private final Logger _log; + private final I2PServerSocket serverSocket; + private final AtomicBoolean lives; /** * Constructor * @param SS - * @param S + * @param S unused * @param info * @param database * @param _log @@ -48,7 +47,6 @@ public class I2Plistener implements Runnable { this.database = database; this.info = info; this._log = _log; - this.socketManager = S; this.serverSocket = SS; this.lives = lives; } diff --git a/apps/BOB/src/net/i2p/BOB/TCPlistener.java b/apps/BOB/src/net/i2p/BOB/TCPlistener.java index e5dd41d59..70ff52b14 100644 --- a/apps/BOB/src/net/i2p/BOB/TCPlistener.java +++ b/apps/BOB/src/net/i2p/BOB/TCPlistener.java @@ -30,12 +30,11 @@ import net.i2p.client.streaming.I2PSocketManager; */ public class TCPlistener implements Runnable { - private NamedDB info, database; - private Logger _log; - public I2PSocketManager socketManager; - public I2PServerSocket serverSocket; - private ServerSocket listener; - private AtomicBoolean lives; + private final NamedDB info, database; + private final Logger _log; + private final I2PSocketManager socketManager; + private final ServerSocket listener; + private final AtomicBoolean lives; /** * Constructor diff --git a/apps/BOB/src/net/i2p/BOB/UDPIOthread.java b/apps/BOB/src/net/i2p/BOB/UDPIOthread.java index 1b6f4249d..9448d1d7b 100644 --- a/apps/BOB/src/net/i2p/BOB/UDPIOthread.java +++ b/apps/BOB/src/net/i2p/BOB/UDPIOthread.java @@ -34,15 +34,17 @@ import net.i2p.util.Log; * The skeletal frame is here, just needs to be finished. * * @author sponge + * @deprecated incomplete, unused */ public class UDPIOthread implements I2PSessionListener, Runnable { - private NamedDB info; - private Log _log; - private Socket socket; + private final NamedDB info; + private final Log _log; + private final Socket socket; private DataInputStream in; private DataOutputStream out; - private I2PSession _session; + private final I2PSession _session; + // FIXME never set private Destination _peerDestination; private boolean up; @@ -58,7 +60,6 @@ public class UDPIOthread implements I2PSessionListener, Runnable { this._log = _log; this.socket = socket; this._session = _session; - } /** diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java index 19ab11a46..916793941 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java @@ -27,7 +27,6 @@ import net.i2p.util.Log; public class I2PSOCKSTunnel extends I2PTunnelClientBase { private HashMap> proxies = null; // port# + "" or "default" -> hostname list - protected Destination outProxyDest = null; //public I2PSOCKSTunnel(int localPort, Logging l, boolean ownDest) { // I2PSOCKSTunnel(localPort, l, ownDest, (EventDispatcher)null); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPClientBase.java index a89e34898..75b0d683d 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPClientBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPClientBase.java @@ -52,8 +52,6 @@ import net.i2p.util.EventDispatcher; private static final AtomicLong __clientId = new AtomicLong(); protected long _clientId; - protected Destination dest; - private final Object startLock = new Object(); private final I2PSession _session; @@ -98,6 +96,7 @@ import net.i2p.util.EventDispatcher; // create a session try { ByteArrayInputStream in = new ByteArrayInputStream(key); + // FIXME this may not pick up non-default I2CP host/port settings from tunnel _session = client.createSession(in, tunnel.getClientOptions()); connected(_session); } catch(Exception exc) { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPServerBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPServerBase.java index b5fc94b2e..ade6e3058 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPServerBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPServerBase.java @@ -87,19 +87,12 @@ public class I2PTunnelUDPServerBase extends I2PTunnelTask implements Source, Sin private void init(boolean verify, InputStream privData, String privkeyname, Logging l) { this.l = l; - int portNum = 7654; - if (getTunnel().port != null) { - try { - portNum = Integer.parseInt(getTunnel().port); - } catch (NumberFormatException nfe) { - _log.log(Log.CRIT, "Invalid port specified [" + getTunnel().port + "], reverting to " + portNum); - } - } // create i2pclient I2PClient client = I2PClientFactory.createClient(); try { + // FIXME this may not pick up non-default I2CP host/port settings from tunnel _session = client.createSession(privData, getTunnel().getClientOptions()); connected(_session); } catch(I2PSessionException exc) { diff --git a/apps/routerconsole/java/src/net/i2p/router/news/NewsMetadata.java b/apps/routerconsole/java/src/net/i2p/router/news/NewsMetadata.java index 15adf5955..9abf512ef 100644 --- a/apps/routerconsole/java/src/net/i2p/router/news/NewsMetadata.java +++ b/apps/routerconsole/java/src/net/i2p/router/news/NewsMetadata.java @@ -1,6 +1,8 @@ package net.i2p.router.news; import java.util.List; + +import net.i2p.data.DataHelper; import net.i2p.util.VersionComparator; /** @@ -16,7 +18,7 @@ public class NewsMetadata { public String feedID; public long feedUpdated; - // I2P metadata + /** I2P metadata */ public List releases; public static class Release implements Comparable { @@ -31,6 +33,31 @@ public class NewsMetadata { // Sort latest version first. return VersionComparator.comp(other.i2pVersion, i2pVersion); } + + /** + * For findbugs. + * Warning, not a complete comparison. + * Must be enhanced before using in a Map or Set. + * @since 0.9.21 + */ + @Override + public boolean equals(Object o) { + if (o == null) + return false; + if (!(o instanceof Release)) + return false; + Release r = (Release) o; + return DataHelper.eq(i2pVersion, r.i2pVersion); + } + + /** + * For findbugs. + * @since 0.9.21 + */ + @Override + public int hashCode() { + return DataHelper.hashCode(i2pVersion); + } } public static class Update implements Comparable { @@ -44,6 +71,7 @@ public class NewsMetadata { return getTypeOrder() - other.getTypeOrder(); } + /** lower is preferred */ protected int getTypeOrder() { if ("su3".equalsIgnoreCase(type)) return 1; @@ -52,5 +80,30 @@ public class NewsMetadata { else return 3; } + + /** + * For findbugs. + * Warning, not a complete comparison. + * Must be enhanced before using in a Map or Set. + * @since 0.9.21 + */ + @Override + public boolean equals(Object o) { + if (o == null) + return false; + if (!(o instanceof Update)) + return false; + Update u = (Update) o; + return getTypeOrder() == u.getTypeOrder(); + } + + /** + * For findbugs. + * @since 0.9.21 + */ + @Override + public int hashCode() { + return getTypeOrder(); + } } } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/WebAppConfiguration.java b/apps/routerconsole/java/src/net/i2p/router/web/WebAppConfiguration.java index d03795be0..440c61c03 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/WebAppConfiguration.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/WebAppConfiguration.java @@ -1,6 +1,8 @@ package net.i2p.router.web; import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; @@ -108,7 +110,7 @@ public class WebAppConfiguration implements Configuration { return; StringTokenizer tok = new StringTokenizer(cp, " ,"); StringBuilder buf = new StringBuilder(); - Set systemCP = getSystemClassPath(); + Set systemCP = getSystemClassPath(); while (tok.hasMoreTokens()) { if (buf.length() > 0) buf.append(','); @@ -127,8 +129,8 @@ public class WebAppConfiguration implements Configuration { // TODO: Add a classpath to the command line in i2pstandalone.xml? File jfile = new File(path); File jdir = jfile.getParentFile(); - if (systemCP.contains(jfile.toURI().toURL()) || - (jdir != null && systemCP.contains(jdir.toURI().toURL()))) { + if (systemCP.contains(jfile.toURI()) || + (jdir != null && systemCP.contains(jdir.toURI()))) { //System.err.println("Not adding " + path + " to classpath for " + appName + ", already in system classpath"); // Ticket #957... don't know why... if (!ctxPath.equals("/susimail")) @@ -151,13 +153,20 @@ public class WebAppConfiguration implements Configuration { } } - /** @since 0.9 */ - private static Set getSystemClassPath() { + /** + * Convert URL to URI so there's no blocking equals(), + * not that there's really any hostnames in here, + * but keep findbugs happy. + * @since 0.9 + */ + private static Set getSystemClassPath() { URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); URL urls[] = urlClassLoader.getURLs(); - Set rv = new HashSet(32); + Set rv = new HashSet(32); for (int i = 0; i < urls.length; i++) { - rv.add(urls[i]); + try { + rv.add(urls[i].toURI()); + } catch (URISyntaxException use) {} } return rv; } diff --git a/apps/susimail/src/src/i2p/susi/webmail/encoding/HeaderLine.java b/apps/susimail/src/src/i2p/susi/webmail/encoding/HeaderLine.java index c18b9eac8..4ed370dd2 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/encoding/HeaderLine.java +++ b/apps/susimail/src/src/i2p/susi/webmail/encoding/HeaderLine.java @@ -66,7 +66,7 @@ public class HeaderLine implements Encoding { boolean quoting = false; boolean quote = false; boolean linebreak = false; - String quotedSequence = null; + StringBuilder quotedSequence = null; int rest = in.length; int index = 0; while( true ) { @@ -102,14 +102,15 @@ public class HeaderLine implements Encoding { } if( quote ) { if( ! quoting ) { - quotedSequence = "=?utf-8?Q?"; + quotedSequence = new StringBuilder(64); + quotedSequence.append("=?utf-8?Q?"); quoting = true; } - quotedSequence += HexTable.table[ c < 0 ? 256 + c : c ]; + quotedSequence.append(HexTable.table[ c < 0 ? 256 + c : c ]); } else { if( quoting ) { - quotedSequence += "?="; + quotedSequence.append("?="); int sl = quotedSequence.length(); if( l + sl > 76 ) { /* @@ -138,7 +139,7 @@ public class HeaderLine implements Encoding { } } if( quoting ) { - quotedSequence += "?="; + quotedSequence.append("?="); int sl = quotedSequence.length(); if( l + sl > 76 ) { /* diff --git a/core/java/src/net/i2p/crypto/eddsa/math/FieldElement.java b/core/java/src/net/i2p/crypto/eddsa/math/FieldElement.java index 7b29590ef..4bea7c39e 100644 --- a/core/java/src/net/i2p/crypto/eddsa/math/FieldElement.java +++ b/core/java/src/net/i2p/crypto/eddsa/math/FieldElement.java @@ -1,11 +1,15 @@ package net.i2p.crypto.eddsa.math; +import java.io.Serializable; + /** * * @since 0.9.15 * */ -public abstract class FieldElement { +public abstract class FieldElement implements Serializable { + private static final long serialVersionUID = 1239527465875676L; + protected final Field f; public FieldElement(Field f) { diff --git a/history.txt b/history.txt index 0092e5f22..b58e40bbf 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,15 @@ +2015-07-12 zzz + * Findbugs all over + +2015-07-08 zzz + * Tunnels: New Bloom filter size, increase bandwidth limit (ticket #1505) + +2015-07-07 zzz + * Crypto: Check for error return from sign() + * i2psnark: Tweak dest display in footer + * Streaming: New config to add to DSA-only list + * Updates: New news URL + 2015-07-05 zzz * SSU: Compete better with NTCP for outbound bandwidth allocations * Transport: Adjust thread priorities to prevent I/O stalling @@ -26,8 +38,8 @@ raise class L/M boundary to match so defaulted routers are still L 2015-06-22 dg - * NetDB: Partially revert last NetDB change: flood because we don't want to create a hole in the DHT - before publisher resends to somebody else. + * NetDB: Partially revert last NetDB change: flood because we don't want + to create a hole in the DHT before publisher resends to somebody else. 2015-06-20 dg * I2PSnark: Auto-start now only starts torrents which were running at shutdown (#766) diff --git a/router/java/src/net/i2p/data/router/RouterKeyGenerator.java b/router/java/src/net/i2p/data/router/RouterKeyGenerator.java index 69e6aacec..02e49ede5 100644 --- a/router/java/src/net/i2p/data/router/RouterKeyGenerator.java +++ b/router/java/src/net/i2p/data/router/RouterKeyGenerator.java @@ -52,6 +52,8 @@ public class RouterKeyGenerator extends RoutingKeyGenerator { public RouterKeyGenerator(I2PAppContext context) { _log = context.logManager().getLog(RoutingKeyGenerator.class); _context = context; + // make sure GMT is set, azi2phelper Vuze plugin is disabling static JVM TZ setting in Router.java + _fmt.setCalendar(_cal); // ensure non-null mod data generateDateBasedModData(); } @@ -61,14 +63,10 @@ public class RouterKeyGenerator extends RoutingKeyGenerator { private volatile long _nextMidnight; private volatile long _lastChanged; - private final static Calendar _cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT")); + private final Calendar _cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT")); private static final String FORMAT = "yyyyMMdd"; private static final int LENGTH = FORMAT.length(); - private final static SimpleDateFormat _fmt = new SimpleDateFormat(FORMAT, Locale.US); - static { - // make sure GMT is set, azi2phelper Vuze plugin is disabling static JVM TZ setting in Router.java - _fmt.setCalendar(_cal); - } + private final SimpleDateFormat _fmt = new SimpleDateFormat(FORMAT, Locale.US); /** * The current (today's) mod data. diff --git a/router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java b/router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java index 9c8bf9d77..62fa46231 100644 --- a/router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java +++ b/router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java @@ -113,7 +113,7 @@ class BloomFilterIVValidator implements IVValidator { path = _context.getBaseDir().toString(); } String msg = - "Configured for " + DataHelper.formatSize(KBps *1024) + + "Configured for " + DataHelper.formatSize(KBps *1024L) + "Bps share bandwidth but only " + DataHelper.formatSize(maxMemory) + "B available memory." + " Recommend increasing wrapper.java.maxmemory in " + @@ -121,7 +121,7 @@ class BloomFilterIVValidator implements IVValidator { // getMaxMemory() returns significantly lower than wrapper config, so add 10% " to at least " + (recMaxMem * 11 / 10 / (1024*1024)) + " (MB)" + " if the actual share bandwidth exceeds " + - DataHelper.formatSize(threshKBps * 1024) + "Bps."; + DataHelper.formatSize(threshKBps * 1024L) + "Bps."; System.out.println("WARN: " + msg); _context.logManager().getLog(BloomFilterIVValidator.class).logAlways(Log.WARN, msg); }