forked from I2P_Developers/i2p.i2p
Findbugs: More findbugs fixes. Including but not limited to: null check fixes and some synchronization
This commit is contained in:
@ -517,7 +517,6 @@ public class MetaInfo
|
||||
* @since 0.9.1
|
||||
*/
|
||||
boolean checkPiece(PartialPiece pp) {
|
||||
MessageDigest sha1 = SHA1.getInstance();
|
||||
int piece = pp.getPiece();
|
||||
byte[] hash;
|
||||
try {
|
||||
|
@ -754,7 +754,7 @@ public class SnarkManager implements CompleteListener {
|
||||
* @since 0.9.1
|
||||
*/
|
||||
public void saveOpenTrackers(List<String> ot) {
|
||||
String val = setListConfig(PROP_OPENTRACKERS, ot);
|
||||
setListConfig(PROP_OPENTRACKERS, ot);
|
||||
if (ot == null)
|
||||
ot = Collections.singletonList(I2PSnarkUtil.DEFAULT_OPENTRACKERS);
|
||||
_util.setOpenTrackers(ot);
|
||||
|
@ -2548,7 +2548,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
if (showPriority) {
|
||||
buf.append("<td class=\"priority\">");
|
||||
File f = item;
|
||||
if ((!complete) && (!item.isDirectory()) && f != null) {
|
||||
if ((!complete) && (!item.isDirectory())) {
|
||||
int pri = snark.getStorage().getPriority(f.getCanonicalPath());
|
||||
buf.append("<input type=\"radio\" value=\"5\" name=\"pri.").append(f.getCanonicalPath()).append("\" ");
|
||||
if (pri > 0)
|
||||
|
@ -273,8 +273,6 @@ public class IndexBean {
|
||||
TunnelController cur = getController(_tunnel);
|
||||
|
||||
Properties config = getConfig();
|
||||
if (config == null)
|
||||
return "Invalid params";
|
||||
|
||||
if (cur == null) {
|
||||
// creating new
|
||||
@ -970,8 +968,6 @@ public class IndexBean {
|
||||
|
||||
TunnelController tun = getController(_tunnel);
|
||||
Properties config = getConfig();
|
||||
if (config == null)
|
||||
return "Invalid params";
|
||||
if (tun == null) {
|
||||
// creating new
|
||||
tun = new TunnelController(config, "", true);
|
||||
@ -1038,8 +1034,6 @@ public class IndexBean {
|
||||
private String generateNewEncryptionKey() {
|
||||
TunnelController tun = getController(_tunnel);
|
||||
Properties config = getConfig();
|
||||
if (config == null)
|
||||
return "Invalid params";
|
||||
if (tun == null) {
|
||||
// creating new
|
||||
tun = new TunnelController(config, "", true);
|
||||
|
@ -93,7 +93,8 @@ class ConnectionDataReceiver implements MessageOutputStream.DataReceiver {
|
||||
|
||||
if (doSend) {
|
||||
PacketLocal packet = send(buf, off, size);
|
||||
if (packet == null) return _dummyStatus;
|
||||
// this shouldn't be null
|
||||
//if (packet == null) return _dummyStatus;
|
||||
|
||||
//dont wait for non-acks
|
||||
if ( (packet.getSequenceNum() > 0) || (packet.isFlagSet(Packet.FLAG_SYNCHRONIZE)) )
|
||||
|
@ -598,7 +598,6 @@ public class DSAEngine {
|
||||
private Signature altSignRaw(SimpleDataStructure hash, SigningPrivateKey privateKey) throws GeneralSecurityException {
|
||||
SigType type = privateKey.getType();
|
||||
String algo = getRawAlgo(type);
|
||||
java.security.Signature jsig = java.security.Signature.getInstance(algo);
|
||||
PrivateKey privKey = SigUtil.toJavaKey(privateKey);
|
||||
return altSignRaw(algo, hash, privKey, type);
|
||||
}
|
||||
|
@ -175,7 +175,6 @@ class SigUtil {
|
||||
throws GeneralSecurityException {
|
||||
SigType type = pk.getType();
|
||||
int len = type.getPubkeyLen();
|
||||
int sublen = len / 2;
|
||||
byte[] b = pk.getData();
|
||||
BigInteger s = new NativeBigInteger(1, b);
|
||||
// see ECConstants re: casting
|
||||
|
@ -113,7 +113,7 @@ public class Clock implements Timestamper.UpdateListener {
|
||||
/*
|
||||
* @return the current delta from System.currentTimeMillis() in milliseconds
|
||||
*/
|
||||
public long getOffset() {
|
||||
public synchronized long getOffset() {
|
||||
return _offset;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class SimpleTimer {
|
||||
}
|
||||
// FIXME if you plan to use this class again
|
||||
while (_events.containsKey(time))
|
||||
time = new Long(time.longValue() + 1);
|
||||
time = Long.valueOf(time.longValue() + 1);
|
||||
_events.put(time, event);
|
||||
_eventTimes.put(event, time);
|
||||
|
||||
|
@ -374,7 +374,6 @@ public class MessageHistory {
|
||||
buf.append(getPrefix());
|
||||
buf.append("timed out waiting for a reply to [").append(sentMessage.getMessageType());
|
||||
buf.append("] [").append(sentMessage.getMessageId()).append("] expiring on [");
|
||||
if (sentMessage != null)
|
||||
buf.append(getTime(sentMessage.getReplySelector().getExpiration()));
|
||||
buf.append("] ").append(sentMessage.getReplySelector().toString());
|
||||
addEntry(buf.toString());
|
||||
|
@ -86,7 +86,7 @@ public class StatisticsManager implements Service {
|
||||
|
||||
if (_context.getBooleanPropertyDefaultTrue(PROP_PUBLISH_RANKINGS) &&
|
||||
_context.random().nextInt(RANDOM_INCLUDE_STATS) == 0) {
|
||||
long publishedUptime = _context.router().getUptime();
|
||||
//long publishedUptime = _context.router().getUptime();
|
||||
// Don't publish these for first hour
|
||||
// Disabled in 0.9
|
||||
//if (publishedUptime > 62*60*1000)
|
||||
|
@ -283,7 +283,6 @@ public class TunnelPoolSettings {
|
||||
}
|
||||
|
||||
private static final boolean getBoolean(String str, boolean defaultValue) {
|
||||
if (str == null) return defaultValue;
|
||||
boolean v = Boolean.parseBoolean(str) ||
|
||||
(str != null && "YES".equals(str.toUpperCase(Locale.US)));
|
||||
return v;
|
||||
|
@ -223,7 +223,6 @@ public class HandleDatabaseLookupMessageJob extends JobImpl {
|
||||
private static boolean isUnreachable(RouterInfo info) {
|
||||
if (info == null) return true;
|
||||
String cap = info.getCapabilities();
|
||||
if (cap == null) return false;
|
||||
return cap.indexOf(Router.CAPABILITY_REACHABLE) >= 0;
|
||||
}
|
||||
|
||||
|
@ -310,8 +310,6 @@ class FloodfillPeerSelector extends PeerSelector {
|
||||
if (pinfo == null)
|
||||
return rv;
|
||||
Collection<RouterAddress> paddr = pinfo.getAddresses();
|
||||
if (paddr == null)
|
||||
return rv;
|
||||
for (RouterAddress pa : paddr) {
|
||||
byte[] pib = pa.getIP();
|
||||
if (pib == null) continue;
|
||||
|
@ -926,7 +926,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
|
||||
*/
|
||||
void dropAfterLookupFailed(Hash peer) {
|
||||
_context.peerManager().removeCapabilities(peer);
|
||||
boolean removed = _kb.remove(peer);
|
||||
_kb.remove(peer);
|
||||
//if (removed) {
|
||||
// if (_log.shouldLog(Log.INFO))
|
||||
// _log.info("Removed kbucket entry for " + peer);
|
||||
|
@ -1270,8 +1270,6 @@ public class ProfileOrganizer {
|
||||
if (pinfo == null)
|
||||
return rv;
|
||||
Collection<RouterAddress> paddr = pinfo.getAddresses();
|
||||
if (paddr == null)
|
||||
return rv;
|
||||
for (RouterAddress pa : paddr) {
|
||||
byte[] pib = pa.getIP();
|
||||
if (pib == null) continue;
|
||||
|
@ -139,11 +139,9 @@ public class OutboundMessageRegistry {
|
||||
|
||||
if (o instanceof OutNetMessage) {
|
||||
msg = (OutNetMessage)o;
|
||||
if (msg != null)
|
||||
rv.add(msg);
|
||||
} else if (o instanceof List) {
|
||||
msgs = (List<OutNetMessage>)o;
|
||||
if (msgs != null)
|
||||
rv.addAll(msgs);
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ public class DHSessionKeyBuilder {
|
||||
//_peerValue = new NativeBigInteger(val);
|
||||
}
|
||||
|
||||
public BigInteger getPeerPublicValue() {
|
||||
public synchronized BigInteger getPeerPublicValue() {
|
||||
return _peerValue;
|
||||
}
|
||||
|
||||
|
@ -952,8 +952,7 @@ public class NTCPTransport extends TransportImpl {
|
||||
}
|
||||
} else if (enabled.equals("false") &&
|
||||
name != null && name.length() > 0 &&
|
||||
!name.equals(ohost) &&
|
||||
nport != null) {
|
||||
!name.equals(ohost)) {
|
||||
// Host name is configured, and we have a port (either auto or configured)
|
||||
// but we probably only get here if the port is auto,
|
||||
// otherwise createNTCPAddress() would have done it already
|
||||
|
@ -1306,7 +1306,7 @@ class EstablishmentManager {
|
||||
_outboundByHash.remove(outboundState.getRemoteIdentity().calculateHash(), outboundState);
|
||||
// should have already been removed in handleOutbound() above
|
||||
// remove only if value == state
|
||||
boolean removed = _outboundStates.remove(outboundState.getRemoteHostId(), outboundState);
|
||||
_outboundStates.remove(outboundState.getRemoteHostId(), outboundState);
|
||||
if (outboundState.getState() != OB_STATE_CONFIRMED_COMPLETELY) {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Expired: " + outboundState + " Lifetime: " + outboundState.getLifetime());
|
||||
|
@ -150,7 +150,6 @@ class OutboundMessageFragments {
|
||||
*
|
||||
*/
|
||||
public void add(OutNetMessage msg) {
|
||||
I2NPMessage msgBody = msg.getMessage();
|
||||
RouterInfo target = msg.getTarget();
|
||||
if (target == null)
|
||||
return;
|
||||
|
@ -58,7 +58,7 @@ class OutboundTunnelEndpoint {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("outbound tunnel " + _config + " received a full message: " + msg
|
||||
+ " to be forwarded on to "
|
||||
+ (toRouter != null ? toRouter.toBase64().substring(0,4) : "")
|
||||
+ toRouter.toBase64().substring(0,4)
|
||||
+ (toTunnel != null ? ":" + toTunnel.getTunnelId() : ""));
|
||||
int size = msg.getMessageSize();
|
||||
// don't drop it if we are the target
|
||||
|
@ -348,9 +348,6 @@ public abstract class TunnelPeerSelector {
|
||||
|
||||
private static boolean shouldExclude(RouterContext ctx, Log log, RouterInfo peer, char excl[]) {
|
||||
String cap = peer.getCapabilities();
|
||||
if (cap == null) {
|
||||
return true;
|
||||
}
|
||||
for (int j = 0; j < excl.length; j++) {
|
||||
if (cap.indexOf(excl[j]) >= 0) {
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user