More findbugs all over

This commit is contained in:
zzz
2018-08-26 15:13:49 +00:00
parent 1f92232253
commit e64ad7ce57
11 changed files with 23 additions and 39 deletions

View File

@ -176,7 +176,7 @@ class Daemon {
private static void update(NamingService router, Set<String> knownNames,
NamingService publishedNS, AddressBook addressbook,
Iterator<Map.Entry<String, HostTxtEntry>> iter, Log log) {
long start = System.currentTimeMillis();
long start = DEBUG ? System.currentTimeMillis() : 0;
int old = 0, nnew = 0, invalid = 0, conflict = 0, total = 0;
int deleted = 0;
while(iter.hasNext()) {

View File

@ -107,7 +107,6 @@ public class ConfigAdvancedHandler extends FormHandler {
boolean saved = _context.router().saveConfig(ConfigAdvancedHelper.PROP_FLOODFILL_PARTICIPANT, _ff);
if (_ff.equals("false") || _ff.equals("true")) {
FloodfillNetworkDatabaseFacade fndf = (FloodfillNetworkDatabaseFacade) _context.netDb();
boolean wasFF = fndf.floodfillEnabled();
boolean isFF = _ff.equals("true");
// this will rebuild the RI, log in the event log, etc.
fndf.setFloodfillEnabled(isFF);

View File

@ -281,15 +281,13 @@ class PacketHandler {
if ( (con.getHighestAckedThrough() <= 5) && (packet.getSequenceNum() <= 5) ) {
if (_log.shouldLog(Log.INFO))
_log.info("Received additional packet w/o SendStreamID after the syn on " + con + ": " + packet);
receiveKnownCon(con, packet);
return;
} else {
if (_log.shouldLog(Log.WARN))
_log.warn("hrmph, received while ack of syn was in flight on " + con + ": " + packet + " acked: " + con.getAckedPackets());
// allow unlimited packets without a SendStreamID for now
receiveKnownCon(con, packet);
return;
}
receiveKnownCon(con, packet);
return;
}
} else {
// if it has a send ID, it's almost certainly for a recently removed connection.
@ -299,6 +297,7 @@ class PacketHandler {
recent + ' ' + packet);
}
// don't bother sending reset
// TODO send reset if recent && has data?
packet.releasePayload();
return;
}

View File

@ -2622,11 +2622,6 @@ public class WebMail extends HttpServlet
ArrayList<String> ccList = new ArrayList<String>();
ArrayList<String> bccList = new ArrayList<String>();
String sender = null;
if (from != null && Mail.validateAddress(from)) {
sender = Mail.getAddress( from );
}
// no validation
Mail.getRecipientsFromList( toList, to, ok );
Mail.getRecipientsFromList( ccList, cc, ok );
@ -2731,7 +2726,6 @@ public class WebMail extends HttpServlet
String[] cc = draft.cc;
String[] bcc = draft.getBcc();
String subject = draft.subject;
MailPart text = draft.getPart();
List<Attachment> attachments = draft.getAttachments();
ArrayList<String> toList = new ArrayList<String>();
@ -2972,7 +2966,8 @@ public class WebMail extends HttpServlet
// header set in processRequest()
I2PAppContext ctx = I2PAppContext.getGlobalContext();
b64UIDL = Base64.encode(ctx.random().nextLong() + "drft");
} else {
}
MailCache drafts = sessionObject.caches.get(DIR_DRAFTS);
if (drafts == null) {
sessionObject.error += "No Drafts folder?\n";
@ -3007,7 +3002,6 @@ public class WebMail extends HttpServlet
// needed when processing the CANCEL button
out.println("<input type=\"hidden\" name=\"" + DRAFT_EXISTS + "\" value=\"1\">");
}
}
boolean fixed = Boolean.parseBoolean(Config.getProperty( CONFIG_SENDER_FIXED, "true" ));

View File

@ -109,8 +109,8 @@ public class FortunaStandalone extends BasePRNGStandalone implements Serializabl
int pool;
int pool0Count;
int reseedCount;
static long refillCount = 0;
static long lastRefill = System.currentTimeMillis();
//static long refillCount = 0;
//static long lastRefill = System.currentTimeMillis();
public static final String SEED = "gnu.crypto.prng.fortuna.seed";
@ -126,10 +126,13 @@ public class FortunaStandalone extends BasePRNGStandalone implements Serializabl
pool0Count = 0;
allocBuffer();
}
/** Unused, see AsyncFortunaStandalone */
protected void allocBuffer() {
buffer = new byte[4*1024*1024]; //256]; // larger buffer to reduce churn
}
/** Unused, see AsyncFortunaStandalone */
public void seed(byte val[]) {
Map<String, byte[]> props = Collections.singletonMap(SEED, val);
init(props);
@ -145,9 +148,10 @@ public class FortunaStandalone extends BasePRNGStandalone implements Serializabl
generator.init(attributes);
}
/** Unused, see AsyncFortunaStandalone */
public void fillBlock()
{
long start = System.currentTimeMillis();
//long start = System.currentTimeMillis();
if (pool0Count >= MIN_POOL_SIZE
&& System.currentTimeMillis() - lastReseed > 100)
{
@ -162,11 +166,11 @@ public class FortunaStandalone extends BasePRNGStandalone implements Serializabl
lastReseed = System.currentTimeMillis();
}
generator.nextBytes(buffer);
long now = System.currentTimeMillis();
long diff = now-lastRefill;
lastRefill = now;
long refillTime = now-start;
System.out.println("Refilling " + (++refillCount) + " after " + diff + " for the PRNG took " + refillTime);
//long now = System.currentTimeMillis();
//long diff = now-lastRefill;
//lastRefill = now;
//long refillTime = now-start;
//System.out.println("Refilling " + (++refillCount) + " after " + diff + " for the PRNG took " + refillTime);
}
@Override

View File

@ -213,7 +213,7 @@ public class MetaNamingService extends DummyNamingService {
*/
public void export(Writer out, Properties options) throws IOException {
for (NamingService ns : _services) {
export(out, options);
ns.export(out, options);
}
}

View File

@ -422,8 +422,8 @@ public class Blocklist {
// buf.deleteCharAt(end1 - 1);
// end1--;
//}
if (end1 <= 0)
return null; // blank
//if (end1 <= 0)
// return null; // blank
int start2 = -1;
int mask = -1;
String comment = null;

View File

@ -495,11 +495,7 @@ class StoreJob extends JobImpl {
StoreMessageSelector selector = new StoreMessageSelector(getContext(), getJobId(), peer, token, expiration);
if (_log.shouldLog(Log.DEBUG)) {
if (shouldEncrypt)
_log.debug("sending encrypted store to " + peer.getIdentity().getHash() + " through " + outTunnel + ": " + sent);
else
_log.debug("sending store to " + peer.getIdentity().getHash() + " through " + outTunnel + ": " + sent);
//_log.debug("Expiration is " + new Date(sent.getMessageExpiration()));
_log.debug("sending encrypted store to " + peer.getIdentity().getHash() + " through " + outTunnel + ": " + sent);
}
getContext().messageRegistry().registerPending(selector, onReply, onFail);
getContext().tunnelDispatcher().dispatchOutbound(sent, outTunnel.getSendTunnelId(0), null, to);

View File

@ -981,7 +981,7 @@ public class NTCPConnection implements Closeable {
List<Block> blocks = new ArrayList<Block>(2);
Block block = new NTCP2Payload.RIBlock(ri, shouldFlood);
int size = block.getTotalLength();
if (size > BUFFER_SIZE) {
if (size + NTCP2Payload.BLOCK_HEADER_SIZE > BUFFER_SIZE) {
if (_log.shouldWarn())
_log.warn("RI too big: " + ri);
return;
@ -993,7 +993,6 @@ public class NTCPConnection implements Closeable {
// all zeros is fine here
//block = new NTCP2Payload.PaddingBlock(_context, padlen);
block = new NTCP2Payload.PaddingBlock(padlen);
size += block.getTotalLength();
blocks.add(block);
}
// use a "read buf" for the temp array
@ -1040,7 +1039,6 @@ public class NTCPConnection implements Closeable {
// all zeros is fine here
//block = new NTCP2Payload.PaddingBlock(_context, padlen);
block = new NTCP2Payload.PaddingBlock(padlen);
plen += block.getTotalLength();
blocks.add(block);
}
// use a "read buf" for the temp array

View File

@ -1904,7 +1904,6 @@ public class PeerState {
_context.statManager().addRateData("udp.sendConfirmFragments", state.getFragmentCount());
_context.statManager().addRateData("udp.sendConfirmVolley", numSends);
_transport.succeeded(state);
int numFragments = state.getFragmentCount();
// this adjusts the rtt/rto/window/etc
messageACKed(state.getMessageSize(), state.getLifetime(), numSends);
//if (getSendWindowBytesRemaining() > 0)

View File

@ -87,11 +87,6 @@ class FragmentedMessage {
_lastReceived = _lastReceived || isLast;
if (fragmentNum > _highFragmentNum)
_highFragmentNum = fragmentNum;
if (isLast && fragmentNum <= 0) {
if (_log.shouldLog(Log.ERROR))
_log.error("hmm, isLast and fragmentNum=" + fragmentNum + " for message " + _messageId);
return false;
}
return true;
}