findbugs all over

This commit is contained in:
zzz
2014-06-13 21:37:18 +00:00
parent ab44488e4c
commit 002d057c92
19 changed files with 50 additions and 25 deletions

View File

@ -37,8 +37,8 @@ class PeerMonitorTask implements Runnable
private final PeerCoordinator coordinator;
private long lastDownloaded = 0;
private long lastUploaded = 0;
//private long lastDownloaded = 0;
//private long lastUploaded = 0;
PeerMonitorTask(PeerCoordinator coordinator)
{

View File

@ -49,7 +49,7 @@ public class I2PSnarkServlet extends BasicServlet {
/** generally "i2psnark" */
private String _contextName;
private SnarkManager _manager;
private static long _nonce;
private long _nonce;
private String _themePath;
private String _imgPath;
private String _lastAnnounceURL;

View File

@ -324,7 +324,7 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging {
/**
* Generic options used for clients and servers.
* NOT a copy, Do NOT modify for per-connection options, make a copy.
* @return NOT a copy, do NOT modify for per-connection options
* @return non-null, NOT a copy, do NOT modify for per-connection options
*/
public Properties getClientOptions() { return _clientOptions; }

View File

@ -608,7 +608,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
error = usingWWWProxy ? "dnfp" : "dnf";
}
byte[] header = getErrorPage(error, ERR_DESTINATION_UNKNOWN);
String message = ise.getLocalizedMessage();
String message = ise != null ? ise.getLocalizedMessage() : "unknown error";
try {
writeErrorMessage(header, message, out, targetRequest, usingWWWProxy, wwwProxy);
} catch(IOException ioe) {}

View File

@ -255,7 +255,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
// Port-specific spoofhost
String spoofHost;
int ourPort = socket.getLocalPort();
if (ourPort != 80 && ourPort > 0 && ourPort <= 65535 && opts != null) {
if (ourPort != 80 && ourPort > 0 && ourPort <= 65535) {
String portSpoof = opts.getProperty("spoofedHost." + ourPort);
if (portSpoof != null)
spoofHost = portSpoof.trim();
@ -284,11 +284,9 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
// server, reads the response headers, rewriting to include Content-encoding: x-i2p-gzip
// if it was one of the Accept-encoding: values, and gzip the payload
boolean allowGZIP = true;
if (opts != null) {
String val = opts.getProperty("i2ptunnel.gzip");
if ( (val != null) && (!Boolean.parseBoolean(val)) )
allowGZIP = false;
}
if (_log.shouldLog(Log.INFO))
_log.info("HTTP server encoding header: " + enc + "/" + altEnc);
boolean alt = (altEnc != null) && (altEnc.indexOf("x-i2p-gzip") >= 0);

View File

@ -1579,6 +1579,11 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
this.constraint = constraint;
}
@Override
public boolean equals(Object o) {
return super.equals(o) && (o instanceof VersionAvailable);
}
@Override
public String toString() {
return "VersionAvailable \"" + version + "\" " + sourceMap +

View File

@ -235,11 +235,11 @@ public class PcapWriter {
seq = 0xffffffff;
else
seq = pkt.getSequenceNum();
DataHelper.writeLong(_fos, 4, seq);
long acked = 0;
if (con != null) {
acked = getLowestAckedThrough(pkt, con);
}
DataHelper.writeLong(_fos, 4, pkt.getSequenceNum());
DataHelper.writeLong(_fos, 4, acked);
// offset and flags 2 bytes

View File

@ -57,7 +57,7 @@ class Mail {
private int size;
public String sender, // as received, trimmed only, not HTML escaped
reply, subject, dateString,
formattedSender, // address only, enclosed with <>, not HTML escaped
//formattedSender, // address only, enclosed with <>, not HTML escaped
formattedSubject,
formattedDate, // US Locale, UTC
localFormattedDate, // Current Locale, local time zone
@ -78,7 +78,7 @@ class Mail {
public Mail(String uidl) {
this.uidl = uidl;
formattedSender = unknown;
//formattedSender = unknown;
formattedSubject = unknown;
formattedDate = unknown;
localFormattedDate = unknown;
@ -306,7 +306,7 @@ class Mail {
if( line.startsWith( "From:" ) ) {
sender = line.substring( 5 ).trim();
formattedSender = getAddress( sender );
//formattedSender = getAddress( sender );
shortSender = sender.replace("\"", "").trim();
int lt = shortSender.indexOf('<');
if (lt > 0)

View File

@ -113,9 +113,9 @@ class MailPart {
str = getHeaderLineAttribute( headerLines[i], "boundary" );
if( str != null )
boundary = str;
if( x_type != null && x_type.startsWith( "multipart" ) && boundary != null )
if (x_type.startsWith( "multipart" ) && boundary != null )
x_multipart = true;
if( x_type != null && x_type.startsWith( "message" ) )
if (x_type.startsWith( "message" ) )
x_message = true;
str = getHeaderLineAttribute( headerLines[i], "name" );
if( str != null )

View File

@ -32,10 +32,10 @@ class BackgroundChecker {
private static final int MIN_CHECK_MINUTES = 15;
// short for testing
//private static final long MIN_IDLE = 10*60*1000;
private final long MIN_IDLE = 30*60*1000;
private static final long MIN_IDLE = 30*60*1000;
// short for testing
//private static final long MIN_SINCE = 10*60*1000;
private final long MIN_SINCE = 60*60*1000;
private static final long MIN_SINCE = 60*60*1000;
public BackgroundChecker(POP3MailBox mailbox) {
this.mailbox = mailbox;

View File

@ -136,7 +136,6 @@ public class POP3MailBox implements NewMailListener {
*/
private ReadBuffer getHeader( int id ) {
Debug.debug(Debug.DEBUG, "getHeader(" + id + ")");
Integer idObj = Integer.valueOf(id);
ReadBuffer header = null;
if (id >= 1 && id <= mails) {
/*
@ -234,7 +233,6 @@ public class POP3MailBox implements NewMailListener {
*/
private ReadBuffer getBody(int id) {
Debug.debug(Debug.DEBUG, "getBody(" + id + ")");
Integer idObj = Integer.valueOf(id);
ReadBuffer body = null;
if (id >= 1 && id <= mails) {
try {

View File

@ -117,7 +117,7 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
_context.random().nextBytes(dummy);
spk = new SigningPrivateKey(dummy);
}
session.getProducer().createLeaseSet(session, leaseSet, li.getSigningPrivateKey(), li.getPrivateKey());
session.getProducer().createLeaseSet(session, leaseSet, spk, li.getPrivateKey());
session.setLeaseSet(leaseSet);
} catch (DataFormatException dfe) {
session.propogateError("Error signing the leaseSet", dfe);

View File

@ -181,4 +181,9 @@ public class Destination extends KeysAndCert {
_cache.clear();
}
}
@Override
public boolean equals(Object o) {
return super.equals(o) && (o instanceof Destination);
}
}

View File

@ -29,4 +29,9 @@ public class RouterIdentity extends KeysAndCert {
public boolean isHidden() {
return (_certificate != null) && (_certificate.getCertificateType() == Certificate.CERTIFICATE_TYPE_HIDDEN);
}
@Override
public boolean equals(Object o) {
return super.equals(o) && (o instanceof LeaseSet);
}
}

View File

@ -203,7 +203,6 @@ public class SessionConfig extends DataStructureImpl {
_signature.writeBytes(out);
}
/* FIXME missing hashCode() method FIXME */
@Override
public boolean equals(Object object) {
if ((object != null) && (object instanceof SessionConfig)) {
@ -217,6 +216,11 @@ public class SessionConfig extends DataStructureImpl {
return false;
}
@Override
public int hashCode() {
return _signature != null ? _signature.hashCode() : 0;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder("[SessionConfig: ");

View File

@ -80,4 +80,9 @@ class LogRecord {
((_throwable == null && r._throwable == null) ||
(_throwable != null && r._throwable != null && _throwable.getClass() == r._throwable.getClass()));
}
@Override
public int hashCode() {
return _message != null ? _message.hashCode() : 0;
}
}

View File

@ -805,4 +805,10 @@ public class NativeBigInteger extends BigInteger {
// use linux as the default, don't throw exception
return "jbigi-linux-";
}
@Override
public boolean equals(Object o) {
// for findbugs
return super.equals(o);
}
}

View File

@ -260,8 +260,6 @@ class OutboundClientMessageJobHelper {
// remembering that key+tag so that we can decrypt it later. this means we can do the
// garlic encryption without any ElGamal (yay)
MessageWrapper.OneTimeSession sess = MessageWrapper.generateSession(ctx, skm);
if (sess == null)
return null;
GarlicMessage msg = MessageWrapper.wrap(ctx, dsm, sess);
return msg;
}

View File

@ -187,6 +187,7 @@ public class MessageWrapper {
* The recipient can then send us an AES-encrypted message,
* avoiding ElGamal.
*
* @return non-null
* @since 0.9.9
*/
public static OneTimeSession generateSession(RouterContext ctx, SessionKeyManager skm) {