forked from I2P_Developers/i2p.i2p
Findbugs all over
This commit is contained in:
@ -189,7 +189,7 @@ class Daemon {
|
||||
Destination oldDest;
|
||||
if (knownNames != null) {
|
||||
oldDest = null;
|
||||
isKnown = key != null ? knownNames.contains(key) : null;
|
||||
isKnown = key != null ? knownNames.contains(key) : false;
|
||||
} else {
|
||||
oldDest = key != null ? router.lookup(key) : null;
|
||||
isKnown = oldDest != null;
|
||||
@ -803,7 +803,7 @@ class Daemon {
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Daemon daemon = new Daemon();
|
||||
if (args != null && args.length > 0 && args[0].equals("test"))
|
||||
if (args.length > 0 && args[0].equals("test"))
|
||||
daemon.test(args);
|
||||
else
|
||||
daemon.run(args);
|
||||
@ -823,11 +823,14 @@ class Daemon {
|
||||
ctx.logManager().flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args may be null
|
||||
*/
|
||||
public void run(String[] args) {
|
||||
_running = true;
|
||||
String settingsLocation = "config.txt";
|
||||
File homeFile;
|
||||
if (args.length > 0) {
|
||||
if (args != null && args.length > 0) {
|
||||
homeFile = new SecureDirectory(args[0]);
|
||||
if (!homeFile.isAbsolute())
|
||||
homeFile = new SecureDirectory(I2PAppContext.getGlobalContext().getRouterDir(), args[0]);
|
||||
|
@ -590,12 +590,7 @@ public class BlockFile implements Closeable {
|
||||
_isClosed = true;
|
||||
metaIndex.close();
|
||||
|
||||
Set<String> oi = openIndices.keySet();
|
||||
Iterator<String> i = oi.iterator();
|
||||
Object k;
|
||||
while(i.hasNext()) {
|
||||
k = i.next();
|
||||
BSkipList bsl = openIndices.get(k);
|
||||
for (BSkipList bsl : openIndices.values()) {
|
||||
bsl.close();
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
||||
public static final Set<String> DEFAULT_TRACKER_ANNOUNCES;
|
||||
|
||||
/** host names for config form */
|
||||
public static final Set<String> KNOWN_OPENTRACKERS = new HashSet<String>(Arrays.asList(new String[] {
|
||||
static final Set<String> KNOWN_OPENTRACKERS = new HashSet<String>(Arrays.asList(new String[] {
|
||||
"tracker.welterde.i2p", "cfmqlafjfmgkzbt4r3jsfyhgsr5abgxryl6fnz3d3y5a365di5aa.b32.i2p",
|
||||
"opentracker.dg2.i2p", "w7tpbzncbcocrqtwwm3nezhnnsw4ozadvi2hmvzdhrqzfxfum7wa.b32.i2p",
|
||||
"tracker.thebland.i2p", "s5ikrdyjwbcgxmqetxb3nyheizftms7euacuub2hic7defkh3xhq.b32.i2p",
|
||||
|
@ -811,8 +811,8 @@ public class TunnelConfig {
|
||||
"proxyUsername", "proxyPassword"
|
||||
};
|
||||
|
||||
public static final Set<String> _noShowSet = new HashSet<String>(128);
|
||||
public static final Set<String> _nonProxyNoShowSet = new HashSet<String>(4);
|
||||
static final Set<String> _noShowSet = new HashSet<String>(128);
|
||||
static final Set<String> _nonProxyNoShowSet = new HashSet<String>(4);
|
||||
static {
|
||||
_noShowSet.addAll(Arrays.asList(_noShowOpts));
|
||||
_noShowSet.addAll(Arrays.asList(_booleanClientOpts));
|
||||
|
@ -102,10 +102,11 @@ public class ConfigSummaryHandler extends FormHandler {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (Iterator<Integer> iter = sections.keySet().iterator(); iter.hasNext(); ) {
|
||||
int i = iter.next();
|
||||
for (Iterator<Map.Entry<Integer, String>> iter = sections.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Map.Entry<Integer, String> e = iter.next();
|
||||
Integer i = e.getKey();
|
||||
if (toDelete.contains(i)) {
|
||||
String removedName = sections.get(i);
|
||||
String removedName = e.getValue();
|
||||
iter.remove();
|
||||
addFormNotice(_t("Removed") + ": " + removedName);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -396,8 +397,8 @@ class SAMStreamSession implements SAMMessageSess {
|
||||
* @return An id associated to the socket handler
|
||||
*/
|
||||
protected int createSocketHandler ( I2PSocket s, int id ) {
|
||||
SAMStreamSessionSocketReader reader = null;
|
||||
StreamSender sender = null;
|
||||
SAMStreamSessionSocketReader reader;
|
||||
StreamSender sender;
|
||||
if (id == 0) {
|
||||
id = createUniqueId();
|
||||
}
|
||||
@ -468,8 +469,9 @@ class SAMStreamSession implements SAMMessageSess {
|
||||
StreamSender sender;
|
||||
|
||||
synchronized (handlersMap) {
|
||||
reader = handlersMap.remove(Integer.valueOf(id));
|
||||
sender = sendersMap.remove(Integer.valueOf(id));
|
||||
Integer iid = Integer.valueOf(id);
|
||||
reader = handlersMap.remove(iid);
|
||||
sender = sendersMap.remove(iid);
|
||||
}
|
||||
|
||||
if (reader != null)
|
||||
@ -486,17 +488,10 @@ class SAMStreamSession implements SAMMessageSess {
|
||||
*
|
||||
*/
|
||||
private void removeAllSocketHandlers() {
|
||||
Integer id;
|
||||
Set<Integer> keySet;
|
||||
Iterator<Integer> iter;
|
||||
|
||||
synchronized (handlersMap) {
|
||||
keySet = handlersMap.keySet();
|
||||
iter = keySet.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
id = iter.next();
|
||||
handlersMap.get(id).stopRunning();
|
||||
for (Map.Entry<Integer, SAMStreamSessionSocketReader> e : handlersMap.entrySet()) {
|
||||
Integer id = e.getKey();
|
||||
e.getValue().stopRunning();
|
||||
sendersMap.get(id).shutDownGracefully();
|
||||
}
|
||||
handlersMap.clear();
|
||||
|
@ -288,12 +288,11 @@ class MessageInputStream extends InputStream {
|
||||
|
||||
buf.append(" not ready blocks: [");
|
||||
long notAvailable = 0;
|
||||
for (Long id : _notYetReadyBlocks.keySet()) {
|
||||
ByteArray ba = _notYetReadyBlocks.get(id);
|
||||
for (Map.Entry<Long, ByteArray> e : _notYetReadyBlocks.entrySet()) {
|
||||
Long id = e.getKey();
|
||||
ByteArray ba = e.getValue();
|
||||
buf.append(id).append(" ");
|
||||
|
||||
if (ba != null)
|
||||
notAvailable += ba.getValid();
|
||||
notAvailable += ba.getValid();
|
||||
}
|
||||
|
||||
buf.append("] not ready bytes: ").append(notAvailable);
|
||||
@ -589,11 +588,11 @@ class MessageInputStream extends InputStream {
|
||||
buf.append(" blocks: ").append(_readyDataBlocks.size());
|
||||
buf.append(" not ready blocks: [");
|
||||
long notAvailable = 0;
|
||||
for (Long id : _notYetReadyBlocks.keySet()) {
|
||||
ByteArray ba = _notYetReadyBlocks.get(id);
|
||||
for (Map.Entry<Long, ByteArray> e : _notYetReadyBlocks.entrySet()) {
|
||||
Long id = e.getKey();
|
||||
ByteArray ba = e.getValue();
|
||||
buf.append(id).append(" ");
|
||||
if (ba != null)
|
||||
notAvailable += ba.getValid();
|
||||
notAvailable += ba.getValid();
|
||||
}
|
||||
buf.append("] not ready bytes: ").append(notAvailable);
|
||||
buf.append(" highest ready block: ").append(_highestReadyBlockId);
|
||||
|
@ -31,7 +31,7 @@ public class TranslateSVGServlet extends HttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 18638760L;
|
||||
private final I2PAppContext _context;
|
||||
private final String DIR = "/svg";
|
||||
private static final String DIR = "/svg";
|
||||
|
||||
public TranslateSVGServlet() {
|
||||
super();
|
||||
|
@ -898,6 +898,10 @@ public class WebMail extends HttpServlet
|
||||
// because we may already have UIDLs in the MailCache to fetch
|
||||
synchronized(_so) {
|
||||
mc = _so.caches.get(DIR_FOLDER);
|
||||
if (mc == null) {
|
||||
_so.error += "Internal error, no folder\n";
|
||||
return;
|
||||
}
|
||||
while (mc.isLoading()) {
|
||||
try {
|
||||
_so.wait(5000);
|
||||
@ -910,9 +914,7 @@ public class WebMail extends HttpServlet
|
||||
if (log.shouldDebug()) log.debug("Done waiting for folder load");
|
||||
// fetch the mail outside the lock
|
||||
// TODO, would be better to add each email as we get it
|
||||
if (mc != null) {
|
||||
found = mc.getMail(MailCache.FetchMode.HEADER);
|
||||
}
|
||||
found = mc.getMail(MailCache.FetchMode.HEADER);
|
||||
}
|
||||
if (log.shouldDebug()) log.debug("CW.FNM connected? " + connected + " found? " + found);
|
||||
synchronized(_so) {
|
||||
@ -2898,7 +2900,7 @@ public class WebMail extends HttpServlet
|
||||
} else {
|
||||
sessionObject.error += relay.error;
|
||||
}
|
||||
sessionObject.info.replace(_t("Sending mail.") + '\n', "");
|
||||
sessionObject.info = sessionObject.info.replace(_t("Sending mail.") + '\n', "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3377,7 +3379,7 @@ public class WebMail extends HttpServlet
|
||||
out.println(button(DELETE, _t("Delete")));
|
||||
}
|
||||
out.println(button(LOGOUT, _t("Logout") ));
|
||||
if (mail.hasBody() && !mc.getFolderName().equals(DIR_DRAFTS)) {
|
||||
if (hasHeader && mail.hasBody() && !mc.getFolderName().equals(DIR_DRAFTS)) {
|
||||
// can't move unless has body
|
||||
// can't move from drafts
|
||||
out.println(button(MOVE_TO, _t("Move to Folder") + ':'));
|
||||
|
@ -877,7 +877,6 @@
|
||||
<pathelement location="apps/jetty/jettylib/jetty-webapp.jar" />
|
||||
<pathelement location="apps/jetty/jettylib/jetty-xml.jar" />
|
||||
<pathelement location="apps/jetty/jettylib/tomcat-api.jar" />
|
||||
<pathelement location="apps/jrobin/jrobin-1.5.9.1.jar" />
|
||||
<pathelement location="installer/lib/wrapper/all/wrapper.jar" />
|
||||
<!-- following are only for debian builds -->
|
||||
<pathelement location="core/java/build/libintl.jar" />
|
||||
@ -2060,6 +2059,8 @@
|
||||
|
||||
<target name="findbugs" depends="build2, buildUtilityJar">
|
||||
<echo message="Starting findbugs, this will take a while..." />
|
||||
<!-- ref: https://github.com/spotbugs/spotbugs/issues/148 -->
|
||||
<echo message="If this doesn't work with Java 9+. try Java 8" />
|
||||
<exec executable="nice" failonerror="true">
|
||||
<arg value="findbugs"/>
|
||||
<arg value="-textui"/>
|
||||
@ -2070,7 +2071,7 @@
|
||||
<arg value="-output"/>
|
||||
<arg value="i2p.fba"/>
|
||||
<arg value="-auxclasspath"/>
|
||||
<arg value="build/commons-el.jar:build/jasper-runtime.jar:build/javax.servlet.jar:build/org.mortbay.jetty.jar:apps/jrobin/jrobin-1.5.9.1.jar:installer/lib/wrapper/all/wrapper.jar:apps/susidns/src/lib/standard.jar:apps/susidns/src/lib/jstl.jar:apps/jrobin/jrobin-1.5.9.1.jar"/>
|
||||
<arg value="build/commons-el.jar:build/jasper-runtime.jar:build/javax.servlet.jar:build/org.mortbay.jetty.jar:build/jrobin.jar:installer/lib/wrapper/all/wrapper.jar:apps/susidns/src/lib/standard.jar:apps/susidns/src/lib/jstl.jar"/>
|
||||
<arg value="-sourcepath"/>
|
||||
<arg value="apps/BOB/src/:apps/addressbook/java/src/:apps/i2psnark/java/src/:apps/i2ptunnel/java/src/:apps/ministreaming/java/src/:apps/routerconsole/java/src/:apps/sam/java/src/:apps/streaming/java/src/:apps/susidns/src/java/src/:apps/susimail/src/src/:apps/systray/java/src/:core/java/src/:router/java/src/:installer/java/src"/>
|
||||
<!-- start of the files to be analyzed -->
|
||||
|
@ -44,7 +44,7 @@ import net.i2p.util.SystemVersion;
|
||||
*/
|
||||
public final class KeyStoreUtil {
|
||||
|
||||
public static boolean _blacklistLogged;
|
||||
private static boolean _blacklistLogged;
|
||||
|
||||
public static final String DEFAULT_KEYSTORE_PASSWORD = "changeit";
|
||||
private static final String DEFAULT_KEY_ALGORITHM = "RSA";
|
||||
@ -1331,8 +1331,8 @@ public final class KeyStoreUtil {
|
||||
String alias = args[2];
|
||||
String pw = args[3];
|
||||
boolean ok = createKeys(ksf, DEFAULT_KEYSTORE_PASSWORD, alias, "test cname", "test ou",
|
||||
//DEFAULT_KEY_VALID_DAYS, "EdDSA", 256, pw);
|
||||
DEFAULT_KEY_VALID_DAYS, "ElGamal", 2048, pw);
|
||||
DEFAULT_KEY_VALID_DAYS, "EdDSA", 256, pw);
|
||||
//DEFAULT_KEY_VALID_DAYS, "ElGamal", 2048, pw);
|
||||
System.out.println("genkey ok? " + ok);
|
||||
}
|
||||
|
||||
|
@ -829,10 +829,11 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
|
||||
* @since 0.7.12
|
||||
*/
|
||||
public String verifyAndGetSigner(File signedFile) {
|
||||
for (SigningPublicKey signingPublicKey : _trustedKeys.keySet()) {
|
||||
for (Map.Entry<SigningPublicKey, String> e : _trustedKeys.entrySet()) {
|
||||
SigningPublicKey signingPublicKey = e.getKey();
|
||||
boolean isValidSignature = verify(signedFile, signingPublicKey);
|
||||
if (isValidSignature)
|
||||
return _trustedKeys.get(signingPublicKey);
|
||||
return e.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ public class HandshakeState implements Destroyable {
|
||||
private DHState localEphemeral;
|
||||
private DHState remotePublicKey;
|
||||
private DHState remoteEphemeral;
|
||||
private DHState fixedEphemeral;
|
||||
private int action;
|
||||
private final int requirements;
|
||||
private int patternIndex;
|
||||
@ -486,10 +485,7 @@ public class HandshakeState implements Destroyable {
|
||||
// then the ephemeral key may have already been provided.
|
||||
if (localEphemeral == null)
|
||||
throw new IllegalStateException("Pattern definition error");
|
||||
if (fixedEphemeral == null)
|
||||
localEphemeral.generateKeyPair();
|
||||
else
|
||||
localEphemeral.copyFrom(fixedEphemeral);
|
||||
localEphemeral.generateKeyPair();
|
||||
len = localEphemeral.getPublicKeyLength();
|
||||
if (space < len)
|
||||
throw new ShortBufferException();
|
||||
@ -802,8 +798,6 @@ public class HandshakeState implements Destroyable {
|
||||
remotePublicKey.destroy();
|
||||
if (remoteEphemeral != null)
|
||||
remoteEphemeral.destroy();
|
||||
if (fixedEphemeral != null)
|
||||
fixedEphemeral.destroy();
|
||||
if (prologue != null)
|
||||
Noise.destroy(prologue);
|
||||
}
|
||||
|
@ -312,6 +312,7 @@ public class DeliveryInstructions extends DataStructureImpl {
|
||||
return additionalSize;
|
||||
}
|
||||
|
||||
/****
|
||||
private byte[] getAdditionalInfo() {
|
||||
int additionalSize = getAdditionalInfoSize();
|
||||
byte rv[] = new byte[additionalSize];
|
||||
@ -322,7 +323,9 @@ public class DeliveryInstructions extends DataStructureImpl {
|
||||
throw new IllegalStateException("size mismatch, additionalSize = " + additionalSize + ", offset = " + offset);
|
||||
return rv;
|
||||
}
|
||||
****/
|
||||
|
||||
/** */
|
||||
private int getAdditionalInfo(byte rv[], int offset) {
|
||||
int origOffset = offset;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class PersistentKeyRing extends KeyRing {
|
||||
@Override
|
||||
public SessionKey remove(Object o) {
|
||||
SessionKey rv = super.remove(o);
|
||||
if (rv != null && o != null && o instanceof Hash) {
|
||||
if (rv != null && o instanceof Hash) {
|
||||
Hash h = (Hash) o;
|
||||
_ctx.router().saveConfig(PROP_PFX + h.toBase64().replace("=", "$"), null);
|
||||
}
|
||||
|
@ -612,10 +612,6 @@ public class NTCPTransport extends TransportImpl {
|
||||
/** queue up afterSend call, which can take some time w/ jobs, etc */
|
||||
void sendComplete(OutNetMessage msg) { _finisher.add(msg); }
|
||||
|
||||
private boolean isEstablished(RouterIdentity peer) {
|
||||
return isEstablished(peer.calculateHash());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEstablished(Hash dest) {
|
||||
NTCPConnection con = _conByIdent.get(dest);
|
||||
|
@ -407,14 +407,14 @@ class UDPPacket implements CDQEntry {
|
||||
* @param inbound unused
|
||||
*/
|
||||
public static UDPPacket acquire(RouterContext ctx, boolean inbound) {
|
||||
UDPPacket rv = null;
|
||||
UDPPacket rv;
|
||||
if (CACHE) {
|
||||
PacketFactory.context = ctx;
|
||||
rv = _packetCache.acquire();
|
||||
rv.init(ctx);
|
||||
}
|
||||
if (rv == null)
|
||||
} else {
|
||||
rv = new UDPPacket(ctx);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user