From 20effe3a7f66a7ebaed014581a4a2b1321e43207 Mon Sep 17 00:00:00 2001 From: zzz Date: Sun, 19 Oct 2008 22:09:14 +0000 Subject: [PATCH] Big findbugs cleanup --- .../java/src/addressbook/ConfigParser.java | 16 +++-- .../java/src/addressbook/Daemon.java | 3 +- .../addressbook/java/src/addressbook/Log.java | 9 ++- .../java/src/net/i2p/i2ptunnel/I2PTunnel.java | 65 +++++++++---------- .../i2p/i2ptunnel/I2PTunnelClientBase.java | 5 +- .../net/i2p/i2ptunnel/I2PTunnelRunner.java | 4 +- .../net/i2p/i2ptunnel/I2PTunnelServer.java | 8 ++- .../i2p/client/streaming/I2PSocketImpl.java | 2 +- .../streaming/I2PSocketManagerFactory.java | 2 +- .../client/streaming/StreamSinkClient.java | 2 +- .../src/net/i2p/router/web/ReseedHandler.java | 1 - .../net/i2p/router/web/SummaryListener.java | 1 - .../streaming/ConnectionPacketHandler.java | 5 +- .../net/i2p/client/streaming/PacketLocal.java | 1 - .../client/streaming/SchedulerClosing.java | 5 +- .../src/i2p/susi/dns/AddressbookBean.java | 22 +++++-- .../src/java/src/i2p/susi/dns/ConfigBean.java | 10 ++- .../src/i2p/susi/dns/SubscriptionsBean.java | 17 +++-- .../src/src/i2p/susi/util/Config.java | 8 ++- .../src/src/i2p/susi/webmail/MailCache.java | 1 - .../src/src/i2p/susi/webmail/MailPart.java | 2 + .../src/i2p/susi/webmail/RequestWrapper.java | 2 +- .../src/src/i2p/susi/webmail/WebMail.java | 7 +- .../webmail/encoding/EncodingFactory.java | 2 +- .../i2p/susi/webmail/pop3/POP3MailBox.java | 16 ++--- .../src/net/i2p/apps/systray/ConfigFile.java | 12 ++-- .../src/net/i2p/apps/systray/UrlLauncher.java | 4 +- .../freenet/support/CPUInformation/CPUID.java | 2 +- .../crypto/prng/AsyncFortunaStandalone.java | 8 +-- .../src/net/i2p/client/I2PClientImpl.java | 5 +- .../src/net/i2p/client/I2PSessionImpl.java | 2 +- .../src/net/i2p/client/I2PSessionImpl2.java | 8 +-- .../client/MessagePayloadMessageHandler.java | 4 +- .../java/src/net/i2p/client/MessageState.java | 4 +- .../src/net/i2p/crypto/ElGamalAESEngine.java | 2 +- .../src/net/i2p/crypto/ElGamalEngine.java | 18 ++--- core/java/src/net/i2p/data/Base64.java | 16 ++++- core/java/src/net/i2p/data/DataHelper.java | 7 +- core/java/src/net/i2p/data/LeaseSet.java | 5 +- core/java/src/net/i2p/stat/Frequency.java | 4 +- core/java/src/net/i2p/time/NtpClient.java | 4 +- core/java/src/net/i2p/util/ByteCache.java | 2 +- core/java/src/net/i2p/util/EepGet.java | 6 +- core/java/src/net/i2p/util/EepPost.java | 2 +- history.txt | 14 ++++ .../net/i2p/data/i2np/I2NPMessageHandler.java | 2 +- .../net/i2p/data/i2np/I2NPMessageImpl.java | 10 +-- .../i2p/data/i2np/TunnelGatewayMessage.java | 2 +- .../src/net/i2p/router/InNetMessagePool.java | 2 +- router/java/src/net/i2p/router/JobQueue.java | 4 +- router/java/src/net/i2p/router/Router.java | 3 - .../src/net/i2p/router/RouterVersion.java | 2 +- .../src/net/i2p/router/RouterWatchdog.java | 2 +- .../src/net/i2p/router/StatisticsManager.java | 4 -- .../i2p/router/SubmitMessageHistoryJob.java | 3 - .../router/message/GarlicMessageParser.java | 1 - .../networkdb/kademlia/ExpireRoutersJob.java | 1 - .../networkdb/kademlia/KBucketImpl.java | 2 +- .../KademliaNetworkDatabaseFacade.java | 6 +- .../router/networkdb/kademlia/SearchJob.java | 8 +-- .../router/networkdb/kademlia/StoreJob.java | 4 -- .../peermanager/ReliabilityCalculator.java | 2 +- .../router/startup/CreateRouterInfoJob.java | 2 +- .../transport/OutboundMessageRegistry.java | 1 - .../transport/udp/EstablishmentManager.java | 28 ++++---- .../i2p/router/transport/udp/PeerState.java | 10 ++- .../i2p/router/transport/udp/UDPReceiver.java | 2 +- .../i2p/router/transport/udp/UDPSender.java | 10 +-- .../router/tunnel/BuildMessageGenerator.java | 2 +- .../i2p/router/tunnel/FragmentHandler.java | 4 +- .../tunnel/InboundEndpointProcessor.java | 2 +- .../router/tunnel/PumpedTunnelGateway.java | 3 - .../i2p/router/tunnel/TunnelDispatcher.java | 2 +- .../i2p/router/tunnel/pool/BuildHandler.java | 22 ++----- .../router/tunnel/pool/BuildRequestor.java | 2 +- .../tunnel/pool/TunnelPeerSelector.java | 9 +-- .../i2p/router/tunnel/pool/TunnelPool.java | 4 -- 77 files changed, 261 insertions(+), 245 deletions(-) diff --git a/apps/addressbook/java/src/addressbook/ConfigParser.java b/apps/addressbook/java/src/addressbook/ConfigParser.java index 8cdce6e260..5d5cd533f2 100644 --- a/apps/addressbook/java/src/addressbook/ConfigParser.java +++ b/apps/addressbook/java/src/addressbook/ConfigParser.java @@ -107,7 +107,11 @@ public class ConfigParser { FileInputStream fileStream = new FileInputStream(file); BufferedReader input = new BufferedReader(new InputStreamReader( fileStream)); - return ConfigParser.parse(input); + Map rv = ConfigParser.parse(input); + try { + fileStream.close(); + } catch (IOException ioe) {} + return rv; } /** @@ -138,7 +142,7 @@ public class ConfigParser { * cannot be read, map. */ public static Map parse(File file, Map map) { - Map result = new HashMap(); + Map result; try { result = ConfigParser.parse(file); } catch (IOException exp) { @@ -188,7 +192,11 @@ public class ConfigParser { FileInputStream fileStream = new FileInputStream(file); BufferedReader input = new BufferedReader(new InputStreamReader( fileStream)); - return ConfigParser.parseSubscriptions(input); + List rv = ConfigParser.parseSubscriptions(input); + try { + fileStream.close(); + } catch (IOException ioe) {} + return rv; } /** @@ -218,7 +226,7 @@ public class ConfigParser { * file cannot be read, list. */ public static List parseSubscriptions(File file, List list) { - List result = new LinkedList(); + List result; try { result = ConfigParser.parseSubscriptions(file); } catch (IOException exp) { diff --git a/apps/addressbook/java/src/addressbook/Daemon.java b/apps/addressbook/java/src/addressbook/Daemon.java index 2a4962b606..7b690eb172 100644 --- a/apps/addressbook/java/src/addressbook/Daemon.java +++ b/apps/addressbook/java/src/addressbook/Daemon.java @@ -125,7 +125,6 @@ public class Daemon { public void run(String[] args) { String settingsLocation = "config.txt"; - Map settings = new HashMap(); String home; if (args.length > 0) { home = args[0]; @@ -157,7 +156,7 @@ public class Daemon { File settingsFile = new File(homeFile, settingsLocation); - settings = ConfigParser.parse(settingsFile, defaultSettings); + Map settings = ConfigParser.parse(settingsFile, defaultSettings); // wait try { Thread.sleep(5*60*1000); diff --git a/apps/addressbook/java/src/addressbook/Log.java b/apps/addressbook/java/src/addressbook/Log.java index 3f9cfec382..f608b20e23 100644 --- a/apps/addressbook/java/src/addressbook/Log.java +++ b/apps/addressbook/java/src/addressbook/Log.java @@ -54,14 +54,17 @@ public class Log { * A String containing a message to append to the log. */ public void append(String entry) { + BufferedWriter bw = null; try { - BufferedWriter bw = new BufferedWriter(new FileWriter(this.file, + bw = new BufferedWriter(new FileWriter(this.file, true)); String timestamp = new Date().toString(); bw.write(timestamp + " -- " + entry); bw.newLine(); - bw.close(); } catch (IOException exp) { + } finally { + if (bw != null) + try { bw.close(); } catch (IOException ioe) {} } } @@ -73,4 +76,4 @@ public class Log { public File getFile() { return this.file; } -} \ No newline at end of file +} diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java index b96454b4e3..0f7c4f3c41 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java @@ -346,7 +346,7 @@ public class I2PTunnel implements Logging, EventDispatcher { } catch (UnknownHostException uhe) { l.log("unknown host"); _log.error(getPrefix() + "Error resolving " + args[0], uhe); - notifyEvent("serverTaskId", new Integer(-1)); + notifyEvent("serverTaskId", Integer.valueOf(-1)); return; } @@ -355,7 +355,7 @@ public class I2PTunnel implements Logging, EventDispatcher { } catch (NumberFormatException nfe) { l.log("invalid port"); _log.error(getPrefix() + "Port specified is not valid: " + args[1], nfe); - notifyEvent("serverTaskId", new Integer(-1)); + notifyEvent("serverTaskId", Integer.valueOf(-1)); return; } @@ -363,19 +363,19 @@ public class I2PTunnel implements Logging, EventDispatcher { if (!privKeyFile.canRead()) { l.log("private key file does not exist"); _log.error(getPrefix() + "Private key file does not exist or is not readable: " + args[2]); - notifyEvent("serverTaskId", new Integer(-1)); + notifyEvent("serverTaskId", Integer.valueOf(-1)); return; } I2PTunnelServer serv = new I2PTunnelServer(serverHost, portNum, privKeyFile, args[2], l, (EventDispatcher) this, this); serv.setReadTimeout(readTimeout); serv.startRunning(); addtask(serv); - notifyEvent("serverTaskId", new Integer(serv.getId())); + notifyEvent("serverTaskId", Integer.valueOf(serv.getId())); return; } else { l.log("server "); l.log(" creates a server that sends all incoming data\n" + " of its destination to host:port."); - notifyEvent("serverTaskId", new Integer(-1)); + notifyEvent("serverTaskId", Integer.valueOf(-1)); } } @@ -401,7 +401,7 @@ public class I2PTunnel implements Logging, EventDispatcher { } catch (UnknownHostException uhe) { l.log("unknown host"); _log.error(getPrefix() + "Error resolving " + args[0], uhe); - notifyEvent("serverTaskId", new Integer(-1)); + notifyEvent("serverTaskId", Integer.valueOf(-1)); return; } @@ -410,7 +410,7 @@ public class I2PTunnel implements Logging, EventDispatcher { } catch (NumberFormatException nfe) { l.log("invalid port"); _log.error(getPrefix() + "Port specified is not valid: " + args[1], nfe); - notifyEvent("serverTaskId", new Integer(-1)); + notifyEvent("serverTaskId", Integer.valueOf(-1)); return; } @@ -420,21 +420,21 @@ public class I2PTunnel implements Logging, EventDispatcher { if (!privKeyFile.canRead()) { l.log("private key file does not exist"); _log.error(getPrefix() + "Private key file does not exist or is not readable: " + args[3]); - notifyEvent("serverTaskId", new Integer(-1)); + notifyEvent("serverTaskId", Integer.valueOf(-1)); return; } I2PTunnelHTTPServer serv = new I2PTunnelHTTPServer(serverHost, portNum, privKeyFile, args[3], spoofedHost, l, (EventDispatcher) this, this); serv.setReadTimeout(readTimeout); serv.startRunning(); addtask(serv); - notifyEvent("serverTaskId", new Integer(serv.getId())); + notifyEvent("serverTaskId", Integer.valueOf(serv.getId())); return; } else { l.log("httpserver "); l.log(" creates an HTTP server that sends all incoming data\n" + " of its destination to host:port., filtering the HTTP\n" + " headers so it looks like the request is to the spoofed host."); - notifyEvent("serverTaskId", new Integer(-1)); + notifyEvent("serverTaskId", Integer.valueOf(-1)); } } @@ -458,7 +458,7 @@ public class I2PTunnel implements Logging, EventDispatcher { } catch (UnknownHostException uhe) { l.log("unknown host"); _log.error(getPrefix() + "Error resolving " + args[0], uhe); - notifyEvent("serverTaskId", new Integer(-1)); + notifyEvent("serverTaskId", Integer.valueOf(-1)); return; } @@ -467,7 +467,7 @@ public class I2PTunnel implements Logging, EventDispatcher { } catch (NumberFormatException nfe) { l.log("invalid port"); _log.error(getPrefix() + "Port specified is not valid: " + args[1], nfe); - notifyEvent("serverTaskId", new Integer(-1)); + notifyEvent("serverTaskId", Integer.valueOf(-1)); return; } @@ -475,11 +475,11 @@ public class I2PTunnel implements Logging, EventDispatcher { serv.setReadTimeout(readTimeout); serv.startRunning(); addtask(serv); - notifyEvent("serverTaskId", new Integer(serv.getId())); + notifyEvent("serverTaskId", Integer.valueOf(serv.getId())); } else { l.log("textserver "); l.log(" creates a server that sends all incoming data\n" + " of its destination to host:port."); - notifyEvent("textserverTaskId", new Integer(-1)); + notifyEvent("textserverTaskId", Integer.valueOf(-1)); } } @@ -507,7 +507,7 @@ public class I2PTunnel implements Logging, EventDispatcher { } catch (NumberFormatException nfe) { l.log("invalid port"); _log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe); - notifyEvent("clientTaskId", new Integer(-1)); + notifyEvent("clientTaskId", Integer.valueOf(-1)); return; } I2PTunnelTask task; @@ -515,11 +515,11 @@ public class I2PTunnel implements Logging, EventDispatcher { try { task = new I2PTunnelClient(portNum, args[1], l, ownDest, (EventDispatcher) this, this); addtask(task); - notifyEvent("clientTaskId", new Integer(task.getId())); + notifyEvent("clientTaskId", Integer.valueOf(task.getId())); } catch (IllegalArgumentException iae) { _log.error(getPrefix() + "Invalid I2PTunnel config to create a client [" + host + ":"+ port + "]", iae); l.log("Invalid I2PTunnel configuration [" + host + ":" + port + "]"); - notifyEvent("clientTaskId", new Integer(-1)); + notifyEvent("clientTaskId", Integer.valueOf(-1)); } } else { l.log("client [,]|file:[ ]"); @@ -528,7 +528,7 @@ public class I2PTunnel implements Logging, EventDispatcher { + " a comma delimited list of pubkeys, it will rotate among them\n" + " randomlyl. sharedClient indicates if this client shares \n" + " with other clients (true of false)"); - notifyEvent("clientTaskId", new Integer(-1)); + notifyEvent("clientTaskId", Integer.valueOf(-1)); } } @@ -550,7 +550,7 @@ public class I2PTunnel implements Logging, EventDispatcher { } catch (NumberFormatException nfe) { l.log("invalid port"); _log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe); - notifyEvent("httpclientTaskId", new Integer(-1)); + notifyEvent("httpclientTaskId", Integer.valueOf(-1)); return; } @@ -582,11 +582,11 @@ public class I2PTunnel implements Logging, EventDispatcher { try { task = new I2PTunnelHTTPClient(port, l, ownDest, proxy, (EventDispatcher) this, this); addtask(task); - notifyEvent("httpclientTaskId", new Integer(task.getId())); + notifyEvent("httpclientTaskId", Integer.valueOf(task.getId())); } catch (IllegalArgumentException iae) { _log.error(getPrefix() + "Invalid I2PTunnel config to create an httpclient [" + host + ":"+ port + "]", iae); l.log("Invalid I2PTunnel configuration [" + host + ":" + port + "]"); - notifyEvent("httpclientTaskId", new Integer(-1)); + notifyEvent("httpclientTaskId", Integer.valueOf(-1)); } } else { l.log("httpclient [] []"); @@ -595,7 +595,7 @@ public class I2PTunnel implements Logging, EventDispatcher { l.log(" (optional) indicates a proxy server to be used"); l.log(" when trying to access an address out of the .i2p domain"); l.log(" (the default proxy is squid.i2p)."); - notifyEvent("httpclientTaskId", new Integer(-1)); + notifyEvent("httpclientTaskId", Integer.valueOf(-1)); } } @@ -617,7 +617,7 @@ public class I2PTunnel implements Logging, EventDispatcher { } catch (NumberFormatException nfe) { l.log("invalid port"); _log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe); - notifyEvent("ircclientTaskId", new Integer(-1)); + notifyEvent("ircclientTaskId", Integer.valueOf(-1)); return; } @@ -639,17 +639,17 @@ public class I2PTunnel implements Logging, EventDispatcher { try { task = new I2PTunnelIRCClient(port, args[1],l, ownDest, (EventDispatcher) this, this); addtask(task); - notifyEvent("ircclientTaskId", new Integer(task.getId())); + notifyEvent("ircclientTaskId", Integer.valueOf(task.getId())); } catch (IllegalArgumentException iae) { _log.error(getPrefix() + "Invalid I2PTunnel config to create an ircclient [" + host + ":"+ port + "]", iae); l.log("Invalid I2PTunnel configuration [" + host + ":" + port + "]"); - notifyEvent("ircclientTaskId", new Integer(-1)); + notifyEvent("ircclientTaskId", Integer.valueOf(-1)); } } else { l.log("ircclient []"); l.log(" creates a client that filter IRC protocol."); l.log(" (optional) indicates if this client shares tunnels with other clients (true of false)"); - notifyEvent("ircclientTaskId", new Integer(-1)); + notifyEvent("ircclientTaskId", Integer.valueOf(-1)); } } @@ -672,18 +672,18 @@ public class I2PTunnel implements Logging, EventDispatcher { } catch (NumberFormatException nfe) { l.log("invalid port"); _log.error(getPrefix() + "Port specified is not valid: " + args[0], nfe); - notifyEvent("sockstunnelTaskId", new Integer(-1)); + notifyEvent("sockstunnelTaskId", Integer.valueOf(-1)); return; } I2PTunnelTask task; task = new I2PSOCKSTunnel(port, l, ownDest, (EventDispatcher) this, this); addtask(task); - notifyEvent("sockstunnelTaskId", new Integer(task.getId())); + notifyEvent("sockstunnelTaskId", Integer.valueOf(task.getId())); } else { l.log("sockstunnel "); l.log(" creates a tunnel that distributes SOCKS requests."); - notifyEvent("sockstunnelTaskId", new Integer(-1)); + notifyEvent("sockstunnelTaskId", Integer.valueOf(-1)); } } @@ -967,7 +967,6 @@ public class I2PTunnel implements Logging, EventDispatcher { l.log(" try to resolve the name into a destination key"); notifyEvent("lookupResult", "invalidUsage"); } else { - String target = args[0]; try { Destination dest = destFromName(args[0]); if (dest == null) { @@ -998,13 +997,13 @@ public class I2PTunnel implements Logging, EventDispatcher { // pings always use the main destination task = new I2Ping(allargs, l, false, (EventDispatcher) this, this); addtask(task); - notifyEvent("pingTaskId", new Integer(task.getId())); + notifyEvent("pingTaskId", Integer.valueOf(task.getId())); } else { l.log("ping "); l.log("ping -h"); l.log("ping -l "); l.log(" Tests communication with peers.\n" + " opts can be -ns (nosync) or not."); - notifyEvent("pingTaskId", new Integer(-1)); + notifyEvent("pingTaskId", Integer.valueOf(-1)); } } @@ -1083,7 +1082,6 @@ public class I2PTunnel implements Logging, EventDispatcher { public static void makeKey(OutputStream writeTo, OutputStream pubDest, Logging l) { try { l.log("Generating new keys..."); - ByteArrayOutputStream priv = new ByteArrayOutputStream(), pub = new ByteArrayOutputStream(); I2PClient client = I2PClientFactory.createClient(); Destination d = client.createDestination(writeTo); l.log("Secret key saved."); @@ -1107,7 +1105,6 @@ public class I2PTunnel implements Logging, EventDispatcher { */ public static void showKey(InputStream readFrom, OutputStream pubDest, Logging l) { try { - I2PClient client = I2PClientFactory.createClient(); Destination d = new Destination(); d.readBytes(readFrom); l.log("Public key: " + d.toBase64()); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java index 7ac922a598..d6e5bf9f93 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java @@ -217,10 +217,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna } protected static I2PSocketManager buildSocketManager(I2PTunnel tunnel) { Properties props = new Properties(); - if (tunnel == null) - props.putAll(System.getProperties()); - else - props.putAll(tunnel.getClientOptions()); + props.putAll(tunnel.getClientOptions()); int portNum = 7654; if (tunnel.port != null) { try { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java index 77e825e5fb..f237b97efb 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelRunner.java @@ -216,9 +216,7 @@ public class I2PTunnelRunner extends I2PThread implements I2PSocket.SocketErrorL private void removeRef() { if (sockList != null) { synchronized (slock) { - boolean removed = sockList.remove(i2ps); - //System.out.println("Removal of i2psocket " + i2ps + " successful? " - // + removed + " remaining: " + sockList.size()); + sockList.remove(i2ps); } } } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java index 5d0f2a9239..fa3478c71d 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java @@ -70,11 +70,16 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { _usePool = "true".equalsIgnoreCase(usePool); else _usePool = DEFAULT_USE_POOL; + FileInputStream fis = null; try { - init(host, port, new FileInputStream(privkey), privkeyname, l); + fis = new FileInputStream(privkey); + init(host, port, fis, privkeyname, l); } catch (IOException ioe) { _log.error("Error starting server", ioe); notifyEvent("openServerResult", "error"); + } finally { + if (fis != null) + try { fis.close(); } catch (IOException ioe) {} } } @@ -92,7 +97,6 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { this.l = l; this.remoteHost = host; this.remotePort = port; - I2PClient client = I2PClientFactory.createClient(); Properties props = new Properties(); props.putAll(getTunnel().getClientOptions()); int portNum = 7654; diff --git a/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketImpl.java b/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketImpl.java index 58349217b6..dc7a48fd46 100644 --- a/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketImpl.java +++ b/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketImpl.java @@ -384,7 +384,7 @@ class I2PSocketImpl implements I2PSocket { } } if (read.length > len) throw new RuntimeException("BUG"); - if ( (inStreamClosed) && ( (read == null) || (read.length <= 0) ) ) + if ( (inStreamClosed) && (read.length <= 0) ) return -1; System.arraycopy(read, 0, b, off, read.length); diff --git a/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java b/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java index ce18d68dfc..33477a4a80 100644 --- a/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java +++ b/apps/ministreaming/java/src/net/i2p/client/streaming/I2PSocketManagerFactory.java @@ -75,7 +75,7 @@ public class I2PSocketManagerFactory { I2PClient client = I2PClientFactory.createClient(); ByteArrayOutputStream keyStream = new ByteArrayOutputStream(512); try { - Destination dest = client.createDestination(keyStream); + client.createDestination(keyStream); ByteArrayInputStream in = new ByteArrayInputStream(keyStream.toByteArray()); return createManager(in, i2cpHost, i2cpPort, opts); } catch (IOException ioe) { diff --git a/apps/ministreaming/java/src/net/i2p/client/streaming/StreamSinkClient.java b/apps/ministreaming/java/src/net/i2p/client/streaming/StreamSinkClient.java index a5a6d4b638..2269e585a9 100644 --- a/apps/ministreaming/java/src/net/i2p/client/streaming/StreamSinkClient.java +++ b/apps/ministreaming/java/src/net/i2p/client/streaming/StreamSinkClient.java @@ -71,7 +71,7 @@ public class StreamSinkClient { _log.error("Peer destination is not valid in " + _peerDestFile, dfe); return; } finally { - if (fis == null) try { fis.close(); } catch (IOException ioe) {} + if (fis != null) try { fis.close(); } catch (IOException ioe) {} } if (_log.shouldLog(Log.DEBUG)) diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ReseedHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ReseedHandler.java index e8641fb3e0..066cb11443 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ReseedHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ReseedHandler.java @@ -226,7 +226,6 @@ public class ReseedHandler { /* Since we don't return a value, we should always throw an exception if something fails. */ private void fetchSeed(String seedURL, String peer) throws Exception { - Log log = I2PAppContext.getGlobalContext().logManager().getLog(ReseedHandler.class); URL url = new URL(seedURL + (seedURL.endsWith("/") ? "" : "/") + "routerInfo-" + peer + ".dat"); byte data[] = readURL(url); diff --git a/apps/routerconsole/java/src/net/i2p/router/web/SummaryListener.java b/apps/routerconsole/java/src/net/i2p/router/web/SummaryListener.java index c6e629b526..ef22745127 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/SummaryListener.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/SummaryListener.java @@ -156,7 +156,6 @@ class SummaryRenderer { public static synchronized void render(I2PAppContext ctx, OutputStream out, String filename) throws IOException { long end = ctx.clock().now() - 60*1000; long start = end - 60*1000*SummaryListener.PERIODS; - long begin = System.currentTimeMillis(); try { RrdGraphDefTemplate template = new RrdGraphDefTemplate(filename); RrdGraphDef def = template.getRrdGraphDef(); diff --git a/apps/streaming/java/src/net/i2p/client/streaming/ConnectionPacketHandler.java b/apps/streaming/java/src/net/i2p/client/streaming/ConnectionPacketHandler.java index 980ecd86ce..0753765d01 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/ConnectionPacketHandler.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/ConnectionPacketHandler.java @@ -261,10 +261,7 @@ public class ConnectionPacketHandler { _context.statManager().addRateData("stream.con.packetsAckedPerMessageReceived", acked.size(), highestRTT); } - if (packet != null) - return adjustWindow(con, isNew, packet.getSequenceNum(), numResends, (acked != null ? acked.size() : 0), choke); - else - return adjustWindow(con, false, -1, numResends, (acked != null ? acked.size() : 0), choke); + return adjustWindow(con, isNew, packet.getSequenceNum(), numResends, (acked != null ? acked.size() : 0), choke); } diff --git a/apps/streaming/java/src/net/i2p/client/streaming/PacketLocal.java b/apps/streaming/java/src/net/i2p/client/streaming/PacketLocal.java index e4604688f9..f0288df5fb 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/PacketLocal.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/PacketLocal.java @@ -177,7 +177,6 @@ public class PacketLocal extends Packet implements MessageOutputStream.WriteStat if (_connection == null) throw new IllegalStateException("Cannot wait for accept with no connection"); long before = _context.clock().now(); - long expiration = before+maxWaitMs; int queued = _connection.getUnackedPacketsSent(); int window = _connection.getOptions().getWindowSize(); boolean accepted = _connection.packetSendChoke(maxWaitMs); diff --git a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerClosing.java b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerClosing.java index 4ab4abb939..d3bc3d4471 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/SchedulerClosing.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/SchedulerClosing.java @@ -34,9 +34,10 @@ class SchedulerClosing extends SchedulerImpl { } public boolean accept(Connection con) { + if (con == null) + return false; long timeSinceClose = _context.clock().now() - con.getCloseSentOn(); - boolean ok = (con != null) && - (!con.getResetSent()) && + boolean ok = (!con.getResetSent()) && (!con.getResetReceived()) && ( (con.getCloseSentOn() > 0) || (con.getCloseReceivedOn() > 0) ) && (timeSinceClose < Connection.DISCONNECT_TIMEOUT) && diff --git a/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java b/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java index 8cdca45c6f..214e7e2925 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java @@ -85,9 +85,11 @@ public class AddressbookBean if( properties.size() > 0 && currentTime - configLastLoaded < 10000 ) return; + FileInputStream fis = null; try { properties.clear(); - properties.load( new FileInputStream( ConfigBean.configFileName ) ); + fis = new FileInputStream( ConfigBean.configFileName ); + properties.load( fis ); // added in 0.5, for compatibility with 0.4 config.txt if( properties.getProperty(PRIVATE_BOOK) == null) properties.setProperty(PRIVATE_BOOK, DEFAULT_PRIVATE_BOOK); @@ -95,6 +97,9 @@ public class AddressbookBean } catch (Exception e) { Debug.debug( e.getClass().getName() + ": " + e.getMessage() ); + } finally { + if (fis != null) + try { fis.close(); } catch (IOException ioe) {} } } public String getFileName() @@ -143,9 +148,10 @@ public class AddressbookBean addressbook = new Properties(); String message = ""; - + FileInputStream fis = null; try { - addressbook.load( new FileInputStream( getFileName() ) ); + fis = new FileInputStream( getFileName() ); + addressbook.load( fis ); LinkedList list = new LinkedList(); Enumeration e = addressbook.keys(); while( e.hasMoreElements() ) { @@ -182,8 +188,10 @@ public class AddressbookBean } catch (Exception e) { Debug.debug( e.getClass().getName() + ": " + e.getMessage() ); + } finally { + if (fis != null) + try { fis.close(); } catch (IOException ioe) {} } - if( message.length() > 0 ) message = "

" + message + "

"; return message; @@ -243,7 +251,11 @@ public class AddressbookBean { String filename = properties.getProperty( getBook() + "_addressbook" ); - addressbook.store( new FileOutputStream( ConfigBean.addressbookPrefix + filename ), null ); + FileOutputStream fos = new FileOutputStream( ConfigBean.addressbookPrefix + filename ); + addressbook.store( fos, null ); + try { + fos.close(); + } catch (IOException ioe) {} } public String getFilter() { return filter; diff --git a/apps/susidns/src/java/src/i2p/susi/dns/ConfigBean.java b/apps/susidns/src/java/src/i2p/susi/dns/ConfigBean.java index bfcac13ff5..85a4ffe6d1 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/ConfigBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/ConfigBean.java @@ -38,8 +38,8 @@ public class ConfigBean implements Serializable { /* * as this is not provided as constant in addressbook, we define it here */ - public static String addressbookPrefix = "addressbook/"; - public static String configFileName = addressbookPrefix + "config.txt"; + public static final String addressbookPrefix = "addressbook/"; + public static final String configFileName = addressbookPrefix + "config.txt"; private String action, config; private String serial, lastSerial; @@ -80,8 +80,9 @@ public class ConfigBean implements Serializable { File file = new File( configFileName ); if( file != null && file.isFile() ) { StringBuffer buf = new StringBuffer(); + BufferedReader br = null; try { - BufferedReader br = new BufferedReader( new FileReader( file ) ); + br = new BufferedReader( new FileReader( file ) ); String line; while( ( line = br.readLine() ) != null ) { buf.append( line ); @@ -95,6 +96,9 @@ public class ConfigBean implements Serializable { } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); + } finally { + if (br != null) + try { br.close(); } catch (IOException ioe) {} } } } diff --git a/apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java b/apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java index 45dd0fd6c7..5bcfa6d121 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java @@ -37,7 +37,6 @@ import java.util.Properties; public class SubscriptionsBean { private String action, fileName, content, serial, lastSerial; - private boolean saved; Properties properties; @@ -53,13 +52,18 @@ public class SubscriptionsBean if( properties.size() > 0 && currentTime - configLastLoaded < 10000 ) return; + FileInputStream fis = null; try { properties.clear(); - properties.load( new FileInputStream( ConfigBean.configFileName ) ); + fis = new FileInputStream( ConfigBean.configFileName ); + properties.load( fis ); configLastLoaded = currentTime; } catch (Exception e) { Debug.debug( e.getClass().getName() + ": " + e.getMessage() ); + } finally { + if (fis != null) + try { fis.close(); } catch (IOException ioe) {} } } public String getAction() { @@ -83,21 +87,24 @@ public class SubscriptionsBean File file = new File( getFileName() ); if( file != null && file.isFile() ) { StringBuffer buf = new StringBuffer(); + BufferedReader br = null; try { - BufferedReader br = new BufferedReader( new FileReader( file ) ); + br = new BufferedReader( new FileReader( file ) ); String line; while( ( line = br.readLine() ) != null ) { buf.append( line ); buf.append( "\n" ); } content = buf.toString(); - saved = true; } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); + } finally { + if (br != null) + try { br.close(); } catch (IOException ioe) {} } } } @@ -110,7 +117,6 @@ public class SubscriptionsBean out.print( content ); out.flush(); out.close(); - saved = true; } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -148,7 +154,6 @@ public class SubscriptionsBean } public void setContent(String content) { this.content = content; - this.saved = false; /* * as this is a property file we need a newline at the end of the last line! diff --git a/apps/susimail/src/src/i2p/susi/util/Config.java b/apps/susimail/src/src/i2p/susi/util/Config.java index e56bfef635..219ce71f34 100644 --- a/apps/susimail/src/src/i2p/susi/util/Config.java +++ b/apps/susimail/src/src/i2p/susi/util/Config.java @@ -26,6 +26,7 @@ package i2p.susi.util; import i2p.susi.debug.Debug; import java.io.FileInputStream; +import java.io.IOException; import java.util.Properties; /** @@ -78,10 +79,15 @@ public class Config { } catch (Exception e) { Debug.debug( Debug.DEBUG, "Could not open WEB-INF/classes/susimail.properties (possibly in jar), reason: " + e.getMessage() ); } + FileInputStream fis = null; try { - config.load( new FileInputStream( "susimail.config" ) ); + fis = new FileInputStream( "susimail.config" ); + config.load( fis ); } catch (Exception e) { Debug.debug( Debug.DEBUG, "Could not open susimail.config, reason: " + e.getMessage() ); + } finally { + if (fis != null) + try { fis.close(); } catch (IOException ioe) {} } } /** diff --git a/apps/susimail/src/src/i2p/susi/webmail/MailCache.java b/apps/susimail/src/src/i2p/susi/webmail/MailCache.java index 8052b4c447..05694f2bf5 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/MailCache.java +++ b/apps/susimail/src/src/i2p/susi/webmail/MailCache.java @@ -36,7 +36,6 @@ public class MailCache { public static final boolean FETCH_ALL = false; private POP3MailBox mailbox; - private String error; private Hashtable mails; private Object synchronizer; diff --git a/apps/susimail/src/src/i2p/susi/webmail/MailPart.java b/apps/susimail/src/src/i2p/susi/webmail/MailPart.java index 1c518784c2..0986c80e7c 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/MailPart.java +++ b/apps/susimail/src/src/i2p/susi/webmail/MailPart.java @@ -76,6 +76,8 @@ public class MailPart { catch (Exception e) { e.printStackTrace(); } + if (decodedHeaders == null) + return; headerLines = new String( decodedHeaders.content, decodedHeaders.offset, decodedHeaders.length ).split( "\r\n" ); for( int i = 0; i < headerLines.length; i++ ) diff --git a/apps/susimail/src/src/i2p/susi/webmail/RequestWrapper.java b/apps/susimail/src/src/i2p/susi/webmail/RequestWrapper.java index e04a9e6dbb..0cb20af2f6 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/RequestWrapper.java +++ b/apps/susimail/src/src/i2p/susi/webmail/RequestWrapper.java @@ -97,7 +97,7 @@ public class RequestWrapper { cachedParameterNames = new Hashtable(); String[] partNames = multiPartRequest.getPartNames(); for( int i = 0; i < partNames.length; i++ ) - cachedParameterNames.put( partNames[i], new Integer( i ) ); + cachedParameterNames.put( partNames[i], Integer.valueOf( i ) ); } return cachedParameterNames.keys(); } diff --git a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java index 015659ecd5..a80fdc5914 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java +++ b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java @@ -556,7 +556,6 @@ public class WebMail extends HttpServlet private void processLogin( SessionObject sessionObject, RequestWrapper request ) { if( sessionObject.state == STATE_AUTH ) { - String login = request.getParameter( LOGIN ); String user = request.getParameter( USER ); String pass = request.getParameter( PASS ); String host = request.getParameter( HOST ); @@ -1330,8 +1329,9 @@ public class WebMail extends HttpServlet } } if( content != null ) { + ZipOutputStream zip = null; try { - ZipOutputStream zip = new ZipOutputStream( response.getOutputStream() ); + zip = new ZipOutputStream( response.getOutputStream() ); String name; if( part.filename != null ) name = part.filename; @@ -1350,6 +1350,9 @@ public class WebMail extends HttpServlet } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); + } finally { + if ( zip != null) + try { zip.close(); } catch (IOException ioe) {} } } } diff --git a/apps/susimail/src/src/i2p/susi/webmail/encoding/EncodingFactory.java b/apps/susimail/src/src/i2p/susi/webmail/encoding/EncodingFactory.java index b7f002dc78..9fd5d97807 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/encoding/EncodingFactory.java +++ b/apps/susimail/src/src/i2p/susi/webmail/encoding/EncodingFactory.java @@ -35,7 +35,7 @@ import java.util.Set; */ public class EncodingFactory { - public static String CONFIG_ENCODING = "encodings"; + public static final String CONFIG_ENCODING = "encodings"; private static Hashtable encodings = null; diff --git a/apps/susimail/src/src/i2p/susi/webmail/pop3/POP3MailBox.java b/apps/susimail/src/src/i2p/susi/webmail/pop3/POP3MailBox.java index a8a1b05a66..6e266e2497 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/pop3/POP3MailBox.java +++ b/apps/susimail/src/src/i2p/susi/webmail/pop3/POP3MailBox.java @@ -102,7 +102,7 @@ public class POP3MailBox { private ReadBuffer getHeader( int id ) { synchronized( synchronizer ) { Debug.debug(Debug.DEBUG, "getHeader(" + id + ")"); - Integer idObj = new Integer(id); + Integer idObj = Integer.valueOf(id); ReadBuffer header = null; if (id >= 1 && id <= mails) { /* @@ -155,7 +155,7 @@ public class POP3MailBox { private ReadBuffer getBody(int id) { synchronized( synchronizer ) { Debug.debug(Debug.DEBUG, "getBody(" + id + ")"); - Integer idObj = new Integer(id); + Integer idObj = Integer.valueOf(id); ReadBuffer body = null; if (id >= 1 && id <= mails) { body = (ReadBuffer)bodyList.get(idObj); @@ -236,7 +236,7 @@ public class POP3MailBox { /* * find value in hashtable */ - Integer resultObj = (Integer) sizes.get(new Integer(id)); + Integer resultObj = (Integer) sizes.get(Integer.valueOf(id)); if (resultObj != null) result = resultObj.intValue(); return result; @@ -277,7 +277,7 @@ public class POP3MailBox { readBuffer = sendCmdNa( "UIDL", DEFAULT_BUFSIZE ); if( readBuffer != null ) { - String[] lines = new String( readBuffer.toString() ).split( "\r\n" ); + String[] lines = readBuffer.toString().split( "\r\n" ); for( int i = 0; i < lines.length; i++ ) { int j = lines[i].indexOf( " " ); @@ -285,7 +285,7 @@ public class POP3MailBox { try { int n = Integer.parseInt( lines[i].substring( 0, j ) ); String uidl = lines[i].substring( j+1 ); - uidlToID.put( uidl, new Integer( n ) ); + uidlToID.put( uidl, Integer.valueOf( n ) ); uidlList.add( n-1, uidl ); } catch( NumberFormatException nfe ) { @@ -319,7 +319,7 @@ public class POP3MailBox { if (j != -1) { int key = Integer.parseInt(lines[i].substring(0, j)); int value = Integer.parseInt(lines[i].substring(j + 1)); - sizes.put(new Integer(key), new Integer(value)); + sizes.put(Integer.valueOf(key), Integer.valueOf(value)); } } } @@ -389,7 +389,7 @@ public class POP3MailBox { updateSizes(); } else { - lastError = new String( lastLine ); + lastError = lastLine; close(); } } @@ -721,4 +721,4 @@ public class POP3MailBox { close(); connect(); } -} \ No newline at end of file +} diff --git a/apps/systray/java/src/net/i2p/apps/systray/ConfigFile.java b/apps/systray/java/src/net/i2p/apps/systray/ConfigFile.java index 02ab6a13ba..952ecba823 100644 --- a/apps/systray/java/src/net/i2p/apps/systray/ConfigFile.java +++ b/apps/systray/java/src/net/i2p/apps/systray/ConfigFile.java @@ -54,36 +54,36 @@ public class ConfigFile { private boolean readConfigFile() { FileInputStream fileInputStream = null; - + boolean rv = true; try { fileInputStream = new FileInputStream(_configFile); _properties.load(fileInputStream); } catch (Exception e) { - return false; + rv = false; } try { fileInputStream.close(); } catch (IOException e) { // No worries. } - return true; + return rv; } private boolean writeConfigFile() { FileOutputStream fileOutputStream = null; - + boolean rv = true; try { fileOutputStream = new FileOutputStream(_configFile); _properties.store(fileOutputStream, null); } catch (Exception e) { - return false; + rv = false; } try { fileOutputStream.close(); } catch (IOException e) { // No worries. } - return true; + return rv; } } diff --git a/apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java b/apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java index 19ab43f8af..7ccc5e2a2f 100644 --- a/apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java +++ b/apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java @@ -85,8 +85,10 @@ public class UrlLauncher { new File("browser.reg").delete(); } catch (Exception e) { // Defaults to IE. + } finally { + if (bufferedReader != null) + try { bufferedReader.close(); } catch (IOException ioe) {} } - if (_shellCommand.executeSilentAndWaitTimed(browserString + " " + url, 5)) return true; diff --git a/core/java/src/freenet/support/CPUInformation/CPUID.java b/core/java/src/freenet/support/CPUInformation/CPUID.java index da50de64b1..1d5c848828 100644 --- a/core/java/src/freenet/support/CPUInformation/CPUID.java +++ b/core/java/src/freenet/support/CPUInformation/CPUID.java @@ -164,7 +164,7 @@ public class CPUID { public boolean IsC3Compatible() { return false; } } protected static class VIAC3Impl extends CPUIDCPUInfo implements CPUInfo { - public boolean isC3Compatible() { return true; } + public boolean IsC3Compatible() { return true; } public String getCPUModelString() { return "VIA C3"; } } protected static class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo diff --git a/core/java/src/gnu/crypto/prng/AsyncFortunaStandalone.java b/core/java/src/gnu/crypto/prng/AsyncFortunaStandalone.java index e2c2202aa1..417d0fc721 100644 --- a/core/java/src/gnu/crypto/prng/AsyncFortunaStandalone.java +++ b/core/java/src/gnu/crypto/prng/AsyncFortunaStandalone.java @@ -150,10 +150,10 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl lastReseed = System.currentTimeMillis(); } generator.nextBytes(buf); - long now = System.currentTimeMillis(); - long diff = now-lastRefill; - lastRefill = now; - long refillTime = now-start; + //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); } diff --git a/core/java/src/net/i2p/client/I2PClientImpl.java b/core/java/src/net/i2p/client/I2PClientImpl.java index f65b26dccf..4783458a3a 100644 --- a/core/java/src/net/i2p/client/I2PClientImpl.java +++ b/core/java/src/net/i2p/client/I2PClientImpl.java @@ -48,9 +48,8 @@ class I2PClientImpl implements I2PClient { public Destination createDestination(OutputStream destKeyStream, Certificate cert) throws I2PException, IOException { Destination d = new Destination(); d.setCertificate(cert); - PublicKey publicKey = new PublicKey(); Object keypair[] = KeyGenerator.getInstance().generatePKIKeypair(); - publicKey = (PublicKey) keypair[0]; + PublicKey publicKey = (PublicKey) keypair[0]; PrivateKey privateKey = (PrivateKey) keypair[1]; Object signingKeys[] = KeyGenerator.getInstance().generateSigningKeypair(); SigningPublicKey signingPubKey = (SigningPublicKey) signingKeys[0]; @@ -80,4 +79,4 @@ class I2PClientImpl implements I2PClient { public I2PSession createSession(I2PAppContext context, InputStream destKeyStream, Properties options) throws I2PSessionException { return new I2PSessionImpl2(context, destKeyStream, options); // thread safe } -} \ No newline at end of file +} diff --git a/core/java/src/net/i2p/client/I2PSessionImpl.java b/core/java/src/net/i2p/client/I2PSessionImpl.java index 5dac3fd5e2..9d4d17733c 100644 --- a/core/java/src/net/i2p/client/I2PSessionImpl.java +++ b/core/java/src/net/i2p/client/I2PSessionImpl.java @@ -408,7 +408,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa public void available(long msgId, int size) { synchronized (AvailabilityNotifier.this) { _pendingIds.add(new Long(msgId)); - _pendingSizes.add(new Integer(size)); + _pendingSizes.add(Integer.valueOf(size)); AvailabilityNotifier.this.notifyAll(); } } diff --git a/core/java/src/net/i2p/client/I2PSessionImpl2.java b/core/java/src/net/i2p/client/I2PSessionImpl2.java index 0b60ef454d..f0307a341d 100644 --- a/core/java/src/net/i2p/client/I2PSessionImpl2.java +++ b/core/java/src/net/i2p/client/I2PSessionImpl2.java @@ -220,10 +220,10 @@ class I2PSessionImpl2 extends I2PSessionImpl { if (actuallyWait) state.waitFor(MessageStatusMessage.STATUS_SEND_ACCEPTED, _context.clock().now() + getTimeout()); - long afterWaitFor = _context.clock().now(); - long inRemovingSync = 0; + //long afterWaitFor = _context.clock().now(); + //long inRemovingSync = 0; synchronized (_sendingStates) { - inRemovingSync = _context.clock().now(); + //inRemovingSync = _context.clock().now(); _sendingStates.remove(state); } long afterRemovingSync = _context.clock().now(); @@ -352,4 +352,4 @@ class I2PSessionImpl2 extends I2PSessionImpl { _sendingStates.clear(); } } -} \ No newline at end of file +} diff --git a/core/java/src/net/i2p/client/MessagePayloadMessageHandler.java b/core/java/src/net/i2p/client/MessagePayloadMessageHandler.java index e38927933b..36121e67a1 100644 --- a/core/java/src/net/i2p/client/MessagePayloadMessageHandler.java +++ b/core/java/src/net/i2p/client/MessagePayloadMessageHandler.java @@ -35,7 +35,7 @@ class MessagePayloadMessageHandler extends HandlerImpl { try { MessagePayloadMessage msg = (MessagePayloadMessage) message; long id = msg.getMessageId(); - Payload payload = decryptPayload(msg, session); + decryptPayload(msg, session); session.addNewMessage(msg); ReceiveMessageEndMessage m = new ReceiveMessageEndMessage(); @@ -68,4 +68,4 @@ class MessagePayloadMessageHandler extends HandlerImpl { payload.setUnencryptedData(data); return payload; } -} \ No newline at end of file +} diff --git a/core/java/src/net/i2p/client/MessageState.java b/core/java/src/net/i2p/client/MessageState.java index 28ab4bdaa7..bae11d5fe8 100644 --- a/core/java/src/net/i2p/client/MessageState.java +++ b/core/java/src/net/i2p/client/MessageState.java @@ -50,7 +50,7 @@ class MessageState { public void receive(int status) { synchronized (_receivedStatus) { - _receivedStatus.add(new Integer(status)); + _receivedStatus.add(Integer.valueOf(status)); _receivedStatus.notifyAll(); } } @@ -275,4 +275,4 @@ class MessageState { _receivedStatus.notifyAll(); } } -} \ No newline at end of file +} diff --git a/core/java/src/net/i2p/crypto/ElGamalAESEngine.java b/core/java/src/net/i2p/crypto/ElGamalAESEngine.java index 9b129835e5..1d67918f78 100644 --- a/core/java/src/net/i2p/crypto/ElGamalAESEngine.java +++ b/core/java/src/net/i2p/crypto/ElGamalAESEngine.java @@ -448,7 +448,7 @@ public class ElGamalAESEngine { System.arraycopy(elgEncr, 0, rv, 0, elgEncr.length); System.arraycopy(aesEncr, 0, rv, elgEncr.length, aesEncr.length); //_log.debug("Return length: " + rv.length); - long finish = _context.clock().now(); + //long finish = _context.clock().now(); //if (_log.shouldLog(Log.DEBUG)) // _log.debug("after the elgEngine.encrypt took a total of " + (finish - after) + "ms"); return rv; diff --git a/core/java/src/net/i2p/crypto/ElGamalEngine.java b/core/java/src/net/i2p/crypto/ElGamalEngine.java index bb7585b26a..8733e26cf3 100644 --- a/core/java/src/net/i2p/crypto/ElGamalEngine.java +++ b/core/java/src/net/i2p/crypto/ElGamalEngine.java @@ -102,25 +102,25 @@ public class ElGamalEngine { System.arraycopy(hash.getData(), 0, d2, 1, Hash.HASH_LENGTH); System.arraycopy(data, 0, d2, 1+Hash.HASH_LENGTH, data.length); - long t0 = _context.clock().now(); + //long t0 = _context.clock().now(); BigInteger m = new NativeBigInteger(1, d2); - long t1 = _context.clock().now(); + //long t1 = _context.clock().now(); if (m.compareTo(CryptoConstants.elgp) >= 0) throw new IllegalArgumentException("ARGH. Data cannot be larger than the ElGamal prime. FIXME"); - long t2 = _context.clock().now(); + //long t2 = _context.clock().now(); BigInteger aalpha = new NativeBigInteger(1, publicKey.getData()); - long t3 = _context.clock().now(); + //long t3 = _context.clock().now(); BigInteger yk[] = getNextYK(); BigInteger k = yk[1]; BigInteger y = yk[0]; - long t7 = _context.clock().now(); + //long t7 = _context.clock().now(); BigInteger d = aalpha.modPow(k, CryptoConstants.elgp); - long t8 = _context.clock().now(); + //long t8 = _context.clock().now(); d = d.multiply(m); - long t9 = _context.clock().now(); + //long t9 = _context.clock().now(); d = d.mod(CryptoConstants.elgp); - long t10 = _context.clock().now(); + //long t10 = _context.clock().now(); byte[] ybytes = y.toByteArray(); byte[] dbytes = d.toByteArray(); @@ -273,4 +273,4 @@ public class ElGamalEngine { + " average decryption time: " + (dTime / numRuns) + " average key generation time: " + (gTime / numRuns)); } -} \ No newline at end of file +} diff --git a/core/java/src/net/i2p/data/Base64.java b/core/java/src/net/i2p/data/Base64.java index a74f53a9ed..58ec48d247 100644 --- a/core/java/src/net/i2p/data/Base64.java +++ b/core/java/src/net/i2p/data/Base64.java @@ -47,13 +47,13 @@ public class Base64 { return (source != null ? encode(source.getBytes()) : ""); } public static String encode(byte[] source) { - return (source != null ? encode(source, 0, (source != null ? source.length : 0)) : ""); + return (source != null ? encode(source, 0, source.length) : ""); } public static String encode(byte[] source, int off, int len) { return (source != null ? encode(source, off, len, false) : ""); } public static String encode(byte[] source, boolean useStandardAlphabet) { - return (source != null ? encode(source, 0, (source != null ? source.length : 0), useStandardAlphabet) : ""); + return (source != null ? encode(source, 0, source.length, useStandardAlphabet) : ""); } public static String encode(byte[] source, int off, int len, boolean useStandardAlphabet) { return (source != null ? safeEncode(source, off, len, useStandardAlphabet) : ""); @@ -241,9 +241,11 @@ public class Base64 { * @return four byte array in Base64 notation. * @since 1.3 */ +/***** unused private static byte[] encode3to4(byte[] threeBytes) { return encode3to4(threeBytes, 3); } // end encodeToBytes +******/ /** * Encodes up to the first three bytes of array threeBytes @@ -379,9 +381,11 @@ public class Base64 { * @param source The data to convert * @since 1.4 */ +/***** unused private static String encodeBytes(byte[] source) { return encodeBytes(source, false); // don't add newlines } // end encodeBytes +******/ /** * Same as encodeBytes, except uses a filesystem / URL friendly set of characters, @@ -435,9 +439,11 @@ public class Base64 { * @param len Length of data to convert * @since 1.4 */ +/***** unused private static String encodeBytes(byte[] source, int off, int len) { return encodeBytes(source, off, len, true); } // end encodeBytes +******/ private static String encodeBytes(byte[] source, int off, int len, boolean breakLines) { StringBuffer buf = new StringBuffer( (len*4)/3 ); @@ -455,7 +461,7 @@ public class Base64 { * @since 1.4 */ private static void encodeBytes(byte[] source, int off, int len, boolean breakLines, StringBuffer out, byte alpha[]) { - int len43 = len * 4 / 3; + //int len43 = len * 4 / 3; //byte[] outBuff = new byte[(len43) // Main 4:3 // + ((len % 3) > 0 ? 4 : 0) // Account for padding // + (breakLines ? (len43 / MAX_LINE_LENGTH) : 0)]; // New lines @@ -494,9 +500,11 @@ public class Base64 { * @return the encoded string * @since 1.3 */ +/***** unused private static String encodeString(String s) { return encodeString(s, true); } // end encodeString +******/ /** * Encodes a string in Base64 notation with line breaks @@ -525,6 +533,7 @@ public class Base64 { * @return array with decoded values * @since 1.3 */ +/***** unused private static byte[] decode4to3(byte[] fourBytes) { byte[] outBuff1 = new byte[3]; int count = decode4to3(fourBytes, 0, outBuff1, 0); @@ -535,6 +544,7 @@ public class Base64 { return outBuff2; } +******/ /** * Decodes four bytes from array source diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java index 40edfbab50..2f1cbd5b26 100644 --- a/core/java/src/net/i2p/data/DataHelper.java +++ b/core/java/src/net/i2p/data/DataHelper.java @@ -671,8 +671,6 @@ public class DataHelper { public final static byte[] xor(byte lhs[], byte rhs[]) { if ((lhs == null) || (rhs == null) || (lhs.length != rhs.length)) return null; - byte rv[] = new byte[lhs.length]; - byte diff[] = new byte[lhs.length]; xor(lhs, 0, rhs, 0, diff, 0, lhs.length); return diff; @@ -821,9 +819,8 @@ public class DataHelper { DataStructure struct = (DataStructure) iter.next(); tm.put(struct.calculateHash().toString(), struct); } - for (Iterator iter = tm.keySet().iterator(); iter.hasNext();) { - Object k = iter.next(); - rv.add(tm.get(k)); + for (Iterator iter = tm.values().iterator(); iter.hasNext();) { + rv.add(iter.next()); } return rv; } diff --git a/core/java/src/net/i2p/data/LeaseSet.java b/core/java/src/net/i2p/data/LeaseSet.java index 950f64b03a..411f5deb90 100644 --- a/core/java/src/net/i2p/data/LeaseSet.java +++ b/core/java/src/net/i2p/data/LeaseSet.java @@ -224,6 +224,8 @@ public class LeaseSet extends DataStructureImpl { } private byte[] getBytes() { + if ((_destination == null) || (_encryptionKey == null) || (_signingKey == null) || (_leases == null)) + return null; int len = PublicKey.KEYSIZE_BYTES // dest + SigningPublicKey.KEYSIZE_BYTES // dest + 4 // cert @@ -233,9 +235,6 @@ public class LeaseSet extends DataStructureImpl { + _leases.size() * 44; // leases ByteArrayOutputStream out = new ByteArrayOutputStream(len); try { - if ((_destination == null) || (_encryptionKey == null) || (_signingKey == null) || (_leases == null)) - return null; - _destination.writeBytes(out); _encryptionKey.writeBytes(out); _signingKey.writeBytes(out); diff --git a/core/java/src/net/i2p/stat/Frequency.java b/core/java/src/net/i2p/stat/Frequency.java index ef42108f20..74a3407cb5 100644 --- a/core/java/src/net/i2p/stat/Frequency.java +++ b/core/java/src/net/i2p/stat/Frequency.java @@ -76,7 +76,7 @@ public class Frequency { long duration = now() - _start; if ((duration <= 0) || (_count <= 0)) return 0; - return duration / _count; + return duration / (double) _count; } } @@ -167,4 +167,4 @@ public class Frequency { private final static long now() { return System.currentTimeMillis(); } -} \ No newline at end of file +} diff --git a/core/java/src/net/i2p/time/NtpClient.java b/core/java/src/net/i2p/time/NtpClient.java index 9e355ea847..5ab2e601f9 100644 --- a/core/java/src/net/i2p/time/NtpClient.java +++ b/core/java/src/net/i2p/time/NtpClient.java @@ -113,8 +113,8 @@ public class NtpClient { // Process response NtpMessage msg = new NtpMessage(packet.getData()); - double roundTripDelay = (destinationTimestamp-msg.originateTimestamp) - - (msg.receiveTimestamp-msg.transmitTimestamp); + //double roundTripDelay = (destinationTimestamp-msg.originateTimestamp) - + // (msg.receiveTimestamp-msg.transmitTimestamp); double localClockOffset = ((msg.receiveTimestamp - msg.originateTimestamp) + (msg.transmitTimestamp - destinationTimestamp)) / 2; socket.close(); diff --git a/core/java/src/net/i2p/util/ByteCache.java b/core/java/src/net/i2p/util/ByteCache.java index 19c6f5b9d5..aadc721aa4 100644 --- a/core/java/src/net/i2p/util/ByteCache.java +++ b/core/java/src/net/i2p/util/ByteCache.java @@ -24,7 +24,7 @@ public final class ByteCache { * @param size how large should the objects cached be? */ public static ByteCache getInstance(int cacheSize, int size) { - Integer sz = new Integer(size); + Integer sz = Integer.valueOf(size); ByteCache cache = null; synchronized (_caches) { if (!_caches.containsKey(sz)) diff --git a/core/java/src/net/i2p/util/EepGet.java b/core/java/src/net/i2p/util/EepGet.java index 62acbfadc3..468fefa79d 100644 --- a/core/java/src/net/i2p/util/EepGet.java +++ b/core/java/src/net/i2p/util/EepGet.java @@ -508,8 +508,6 @@ public class EepGet { _actualURL = "http://" + url.getHost() + ":" + url.getPort() + "/" + _redirectLocation; if ( (_actualURL.indexOf('?') < 0) && (query.length() > 0) ) _actualURL = _actualURL + "?" + query; - else - _actualURL = _actualURL; } } catch (MalformedURLException mue) { throw new IOException("Redirected from an invalid URL"); @@ -772,7 +770,7 @@ public class EepGet { _log.warn("ERR: status "+ line); return -1; } - String protocol = tok.nextToken(); // ignored + tok.nextToken(); // ignored (protocol) if (!tok.hasMoreTokens()) { if (_log.shouldLog(Log.WARN)) _log.warn("ERR: status "+ line); @@ -874,7 +872,7 @@ public class EepGet { timeout.setSocket(_proxy); - _proxyOut.write(DataHelper.getUTF8(req.toString())); + _proxyOut.write(DataHelper.getUTF8(req)); _proxyOut.flush(); if (_log.shouldLog(Log.DEBUG)) diff --git a/core/java/src/net/i2p/util/EepPost.java b/core/java/src/net/i2p/util/EepPost.java index 7f5bd2ca31..50929f3cf5 100644 --- a/core/java/src/net/i2p/util/EepPost.java +++ b/core/java/src/net/i2p/util/EepPost.java @@ -162,7 +162,7 @@ public class EepPost { } private void sendFile(OutputStream out, String separator, String field, File file) throws IOException { - long len = file.length(); + //long len = file.length(); out.write(("--" + separator + CRLF).getBytes()); out.write(("Content-Disposition: form-data; name=\"" + field + "\"; filename=\"" + file.getName() + "\"" + CRLF).getBytes()); //out.write(("Content-length: " + len + "\n").getBytes()); diff --git a/history.txt b/history.txt index 667dc945b4..2fdb42637a 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,17 @@ +2008-10-20 zzz + * configclients.jsp: Handle clients with no args + * index.jsp: Add readme_nl.html (thanks mathiasdm!), + readme_sv.html (thanks hottuna!) + * Big findbugs cleanup + * Client: Prevent a race causing session reconnect + * FloodfillMonitor: + - Don't become ff if clock skew is high + - Rebuild routerinfo immediately when ff status changes + * FloodOnlySearchJob: Recover better if the floodfills + you know are no longer floodfill or are gone + * Installer: Bump min JRE to 1.5 + * ShellCommand: Fix main() + 2008-10-14 zzz * index.jsp: Add multilanguage support for readme.html; add readme_de.html (thanks devzero!) diff --git a/router/java/src/net/i2p/data/i2np/I2NPMessageHandler.java b/router/java/src/net/i2p/data/i2np/I2NPMessageHandler.java index 4243f83955..814443cb01 100644 --- a/router/java/src/net/i2p/data/i2np/I2NPMessageHandler.java +++ b/router/java/src/net/i2p/data/i2np/I2NPMessageHandler.java @@ -86,7 +86,7 @@ public class I2NPMessageHandler { * message - if it is an unknown type or has improper formatting, etc. */ public I2NPMessage readMessage(byte data[]) throws IOException, I2NPMessageException { - int offset = readMessage(data, 0); + readMessage(data, 0); return lastRead(); } public int readMessage(byte data[], int offset) throws IOException, I2NPMessageException { diff --git a/router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java b/router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java index 8c1de62d5e..b745db9c0d 100644 --- a/router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java +++ b/router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java @@ -41,7 +41,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM /** unsynchronized as its pretty much read only (except at startup) */ private static final Map _builders = new HashMap(8); - public static final void registerBuilder(Builder builder, int type) { _builders.put(new Integer(type), builder); } + public static final void registerBuilder(Builder builder, int type) { _builders.put(Integer.valueOf(type), builder); } /** interface for extending the types of messages handled */ public interface Builder { /** instantiate a new I2NPMessage to be populated shortly */ @@ -103,7 +103,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM if (_log.shouldLog(Log.DEBUG)) _log.debug("Reading bytes: type = " + type + " / uniqueId : " + _uniqueId + " / expiration : " + _expiration); readMessage(buffer, 0, size, type); - long time = _context.clock().now() - start; + //long time = _context.clock().now() - start; //if (time > 50) // _context.statManager().addRateData("i2np.readTime", time, time); _read = true; @@ -148,7 +148,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM _log.debug("Reading bytes: type = " + type + " / uniqueId : " + _uniqueId + " / expiration : " + _expiration); readMessage(data, cur, size, type); cur += size; - long time = _context.clock().now() - start; + //long time = _context.clock().now() - start; //if (time > 50) // _context.statManager().addRateData("i2np.readTime", time, time); _read = true; @@ -228,7 +228,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM off += 2; System.arraycopy(h.getData(), 0, buffer, off, CHECKSUM_LENGTH); - long time = _context.clock().now() - start; + //long time = _context.clock().now() - start; //if (time > 50) // _context.statManager().addRateData("i2np.writeTime", time, time); @@ -370,7 +370,7 @@ public abstract class I2NPMessageImpl extends DataStructureImpl implements I2NPM case TunnelBuildReplyMessage.MESSAGE_TYPE: return new TunnelBuildReplyMessage(context); default: - Builder builder = (Builder)_builders.get(new Integer(type)); + Builder builder = (Builder)_builders.get(Integer.valueOf(type)); if (builder == null) return null; else diff --git a/router/java/src/net/i2p/data/i2np/TunnelGatewayMessage.java b/router/java/src/net/i2p/data/i2np/TunnelGatewayMessage.java index bf97dc10c2..f611c32138 100644 --- a/router/java/src/net/i2p/data/i2np/TunnelGatewayMessage.java +++ b/router/java/src/net/i2p/data/i2np/TunnelGatewayMessage.java @@ -95,7 +95,7 @@ public class TunnelGatewayMessage extends I2NPMessageImpl { if (_tunnelId.getTunnelId() <= 0) throw new I2NPMessageException("Invalid tunnel Id " + _tunnelId); - int size = (int)DataHelper.fromLong(data, curIndex, 2); + DataHelper.fromLong(data, curIndex, 2); curIndex += 2; curIndex = handler.readMessage(data, curIndex); _msg = handler.lastRead(); diff --git a/router/java/src/net/i2p/router/InNetMessagePool.java b/router/java/src/net/i2p/router/InNetMessagePool.java index 9741f9d446..4ab5c77b41 100644 --- a/router/java/src/net/i2p/router/InNetMessagePool.java +++ b/router/java/src/net/i2p/router/InNetMessagePool.java @@ -209,7 +209,7 @@ public class InNetMessagePool implements Service { } else { if (_log.shouldLog(Log.WARN)) _log.warn("Message expiring on " - + (messageBody != null ? (messageBody.getMessageExpiration()+"") : " [unknown]") + + messageBody.getMessageExpiration() + " was not handled by a HandlerJobBuilder - DROPPING: " + messageBody, new Exception("f00!")); _context.statManager().addRateData("inNetPool.dropped", 1, 0); diff --git a/router/java/src/net/i2p/router/JobQueue.java b/router/java/src/net/i2p/router/JobQueue.java index 400c68dfee..915288cc66 100644 --- a/router/java/src/net/i2p/router/JobQueue.java +++ b/router/java/src/net/i2p/router/JobQueue.java @@ -369,7 +369,7 @@ public class JobQueue { + _queueRunners.size() + " to " + numThreads); for (int i = _queueRunners.size(); i < numThreads; i++) { JobQueueRunner runner = new JobQueueRunner(_context, i); - _queueRunners.put(new Integer(i), runner); + _queueRunners.put(Integer.valueOf(i), runner); Thread t = new I2PThread(runner); t.setName("JobQueue"+(_runnerId++)); //t.setPriority(I2PThread.MAX_PRIORITY-1); @@ -390,7 +390,7 @@ public class JobQueue { } } - void removeRunner(int id) { _queueRunners.remove(new Integer(id)); } + void removeRunner(int id) { _queueRunners.remove(Integer.valueOf(id)); } /** * Responsible for moving jobs from the timed queue to the ready queue, diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java index 4fcb9364ea..c7c61245e2 100644 --- a/router/java/src/net/i2p/router/Router.java +++ b/router/java/src/net/i2p/router/Router.java @@ -289,7 +289,6 @@ public class Router { log.debug("Config file: " + filename, new Exception("location")); } Properties props = new Properties(); - FileInputStream fis = null; try { File f = new File(filename); if (f.canRead()) { @@ -303,8 +302,6 @@ public class Router { } catch (Exception ioe) { if (log != null) log.error("Error loading the router configuration from " + filename, ioe); - } finally { - if (fis != null) try { fis.close(); } catch (IOException ioe) {} } return props; } diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 02d26488b9..9071577cac 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -17,7 +17,7 @@ import net.i2p.CoreVersion; public class RouterVersion { public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $"; public final static String VERSION = "0.6.4"; - public final static long BUILD = 5; + public final static long BUILD = 6; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("Router ID: " + RouterVersion.ID); diff --git a/router/java/src/net/i2p/router/RouterWatchdog.java b/router/java/src/net/i2p/router/RouterWatchdog.java index da1ee1e05a..3f4965e13c 100644 --- a/router/java/src/net/i2p/router/RouterWatchdog.java +++ b/router/java/src/net/i2p/router/RouterWatchdog.java @@ -52,8 +52,8 @@ class RouterWatchdog implements Runnable { private void dumpStatus() { if (_log.shouldLog(Log.ERROR)) { - Job cur = _context.jobQueue().getLastJob(); /* + Job cur = _context.jobQueue().getLastJob(); if (cur != null) _log.error("Most recent job: " + cur); _log.error("Last job began: " diff --git a/router/java/src/net/i2p/router/StatisticsManager.java b/router/java/src/net/i2p/router/StatisticsManager.java index 3109dacdef..274f438376 100644 --- a/router/java/src/net/i2p/router/StatisticsManager.java +++ b/router/java/src/net/i2p/router/StatisticsManager.java @@ -214,9 +214,6 @@ public class StatisticsManager implements Service { return stats; } - private void includeRate(String rateName, Properties stats) { - includeRate(rateName, stats, null); - } private void includeRate(String rateName, Properties stats, long selectedPeriods[]) { includeRate(rateName, stats, selectedPeriods, false); } @@ -272,7 +269,6 @@ public class StatisticsManager implements Service { buf.append(num(rate.getLastEventCount())).append(';'); if (numPeriods > 0) { double avgFrequency = rate.getLifetimeEventCount() / (double)numPeriods; - double peakFrequency = rate.getExtremeEventCount(); buf.append(num(avgFrequency)).append(';'); buf.append(num(rate.getExtremeEventCount())).append(';'); buf.append(num((double)rate.getLifetimeEventCount())).append(';'); diff --git a/router/java/src/net/i2p/router/SubmitMessageHistoryJob.java b/router/java/src/net/i2p/router/SubmitMessageHistoryJob.java index 2cd3f3b502..19c8173b72 100644 --- a/router/java/src/net/i2p/router/SubmitMessageHistoryJob.java +++ b/router/java/src/net/i2p/router/SubmitMessageHistoryJob.java @@ -84,9 +84,6 @@ public class SubmitMessageHistoryJob extends JobImpl { return; } long size = dataFile.length(); - int expectedSend = 512; // 512 for HTTP overhead - if (size > 0) - expectedSend += (int)size/10; // compression FileInputStream fin = new FileInputStream(dataFile); BandwidthLimitedInputStream in = new BandwidthLimitedInputStream(getContext(), fin, null, true); boolean sent = HTTPSendData.postData(url, size, in); diff --git a/router/java/src/net/i2p/router/message/GarlicMessageParser.java b/router/java/src/net/i2p/router/message/GarlicMessageParser.java index ce06df0125..3e99e07316 100644 --- a/router/java/src/net/i2p/router/message/GarlicMessageParser.java +++ b/router/java/src/net/i2p/router/message/GarlicMessageParser.java @@ -61,7 +61,6 @@ public class GarlicMessageParser { } private CloveSet readCloveSet(byte data[]) throws DataFormatException { - Set cloves = new HashSet(); int offset = 0; CloveSet set = new CloveSet(); diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/ExpireRoutersJob.java b/router/java/src/net/i2p/router/networkdb/kademlia/ExpireRoutersJob.java index 91732bf4b2..e5957eaff8 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/ExpireRoutersJob.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/ExpireRoutersJob.java @@ -69,7 +69,6 @@ class ExpireRoutersJob extends JobImpl { private Set selectKeysToExpire() { Set possible = getNotInUse(); Set expiring = new HashSet(16); - long earliestPublishDate = getContext().clock().now() - EXPIRE_DELAY; for (Iterator iter = possible.iterator(); iter.hasNext(); ) { Hash key = (Hash)iter.next(); diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/KBucketImpl.java b/router/java/src/net/i2p/router/networkdb/kademlia/KBucketImpl.java index 538deea43e..1e795db8e6 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KBucketImpl.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KBucketImpl.java @@ -58,7 +58,7 @@ class KBucketImpl implements KBucket { // we want to make sure we've got the cache in place before calling cachedXor _local.prepareCache(); if (_log.shouldLog(Log.DEBUG)) - _log.debug("Local hash reset to " + (local == null ? "null" : DataHelper.toHexString(local.getData()))); + _log.debug("Local hash reset to " + DataHelper.toHexString(local.getData())); } private byte[] distanceFromLocal(Hash key) { diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java index 0e19e3273c..eb5796a20a 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java @@ -777,7 +777,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { } if (o == null) { - boolean removed = _kb.remove(dbEntry); + _kb.remove(dbEntry); _context.peerManager().removeCapabilities(dbEntry); // if we dont know the key, lets make sure it isn't a now-dead peer } @@ -1054,9 +1054,9 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade { } Integer val = (Integer)routerVersions.get(routerVersion); if (val == null) - routerVersions.put(routerVersion, new Integer(1)); + routerVersions.put(routerVersion, Integer.valueOf(1)); else - routerVersions.put(routerVersion, new Integer(val.intValue() + 1)); + routerVersions.put(routerVersion, Integer.valueOf(val.intValue() + 1)); } } } diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/SearchJob.java b/router/java/src/net/i2p/router/networkdb/kademlia/SearchJob.java index 8b7c97e0ad..6cd7c9abb6 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/SearchJob.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/SearchJob.java @@ -284,7 +284,7 @@ class SearchJob extends JobImpl { } else if (!(ds instanceof RouterInfo)) { if (_log.shouldLog(Log.WARN)) _log.warn(getJobId() + ": Error selecting closest hash that wasnt a router! " - + peer + " : " + (ds == null ? "null" : ds.getClass().getName())); + + peer + " : " + ds.getClass().getName()); _state.replyTimeout(peer); } else { RouterInfo ri = (RouterInfo)ds; @@ -375,10 +375,10 @@ class SearchJob extends JobImpl { getContext().statManager().addRateData("netDb.searchMessageCount", 1, 0); - if (_isLease || true) // always send searches out tunnels + //if (_isLease || true) // always send searches out tunnels sendLeaseSearch(router); - else - sendRouterSearch(router); + //else + // sendRouterSearch(router); } diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java b/router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java index 7713eb269b..18d18f13e2 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java @@ -308,10 +308,6 @@ class StoreJob extends JobImpl { return; } TunnelId replyTunnelId = replyTunnel.getReceiveTunnelId(0); - if (replyTunnel == null) { - _log.warn("No reply inbound tunnels available!"); - return; - } msg.setReplyToken(token); msg.setReplyTunnel(replyTunnelId); msg.setReplyGateway(replyTunnel.getPeer(0)); diff --git a/router/java/src/net/i2p/router/peermanager/ReliabilityCalculator.java b/router/java/src/net/i2p/router/peermanager/ReliabilityCalculator.java index 000561ee0b..674b2fd915 100644 --- a/router/java/src/net/i2p/router/peermanager/ReliabilityCalculator.java +++ b/router/java/src/net/i2p/router/peermanager/ReliabilityCalculator.java @@ -67,7 +67,7 @@ public class ReliabilityCalculator extends Calculator { val -= profile.getCommError().getRate(24*60*60*1000).getCurrentEventCount() * 1; - long now = _context.clock().now(); + //long now = _context.clock().now(); long timeSinceRejection = 61*60*1000; // now - profile.getTunnelHistory().getLastRejected(); if (timeSinceRejection > 60*60*1000) { diff --git a/router/java/src/net/i2p/router/startup/CreateRouterInfoJob.java b/router/java/src/net/i2p/router/startup/CreateRouterInfoJob.java index de84fa49bb..92b176c30f 100644 --- a/router/java/src/net/i2p/router/startup/CreateRouterInfoJob.java +++ b/router/java/src/net/i2p/router/startup/CreateRouterInfoJob.java @@ -41,7 +41,7 @@ public class CreateRouterInfoJob extends JobImpl { public void runJob() { _log.debug("Creating the new router info"); // create a new router info and store it where LoadRouterInfoJob looks - RouterInfo info = createRouterInfo(); + createRouterInfo(); getContext().jobQueue().addJob(_next); } diff --git a/router/java/src/net/i2p/router/transport/OutboundMessageRegistry.java b/router/java/src/net/i2p/router/transport/OutboundMessageRegistry.java index 4ddcd44a00..c5ca48f57a 100644 --- a/router/java/src/net/i2p/router/transport/OutboundMessageRegistry.java +++ b/router/java/src/net/i2p/router/transport/OutboundMessageRegistry.java @@ -63,7 +63,6 @@ public class OutboundMessageRegistry { public List getOriginalMessages(I2NPMessage message) { ArrayList matchedSelectors = null; ArrayList removedSelectors = null; - long beforeSync = _context.clock().now(); synchronized (_selectors) { for (int i = 0; i < _selectors.size(); i++) { MessageSelector sel = (MessageSelector)_selectors.get(i); diff --git a/router/java/src/net/i2p/router/transport/udp/EstablishmentManager.java b/router/java/src/net/i2p/router/transport/udp/EstablishmentManager.java index 884947b11e..45f82b461f 100644 --- a/router/java/src/net/i2p/router/transport/udp/EstablishmentManager.java +++ b/router/java/src/net/i2p/router/transport/udp/EstablishmentManager.java @@ -168,10 +168,10 @@ public class EstablishmentManager { if (_outboundStates.size() >= getMaxConcurrentEstablish()) { List queued = (List)_queuedOutbound.get(to); if (queued == null) { + queued = new ArrayList(1); if (_queuedOutbound.size() > MAX_QUEUED_OUTBOUND) { rejected = true; } else { - queued = new ArrayList(1); _queuedOutbound.put(to, queued); } } @@ -336,11 +336,11 @@ public class EstablishmentManager { */ PeerState receiveData(OutboundEstablishState state) { state.dataReceived(); - int active = 0; - int admitted = 0; - int remaining = 0; + //int active = 0; + //int admitted = 0; + //int remaining = 0; synchronized (_outboundStates) { - active = _outboundStates.size(); + //active = _outboundStates.size(); _outboundStates.remove(state.getRemoteHostId()); if (_queuedOutbound.size() > 0) { // there shouldn't have been queued messages for this active state, but just in case... @@ -350,9 +350,9 @@ public class EstablishmentManager { state.addMessage((OutNetMessage)queued.get(i)); } - admitted = locked_admitQueued(); + //admitted = locked_admitQueued(); } - remaining = _queuedOutbound.size(); + //remaining = _queuedOutbound.size(); } //if (admitted > 0) // _log.log(Log.CRIT, "Admitted " + admitted + " with " + remaining + " remaining queued and " + active + " active"); @@ -598,7 +598,6 @@ public class EstablishmentManager { } private void sendRequest(OutboundEstablishState state) { - long now = _context.clock().now(); if (_log.shouldLog(Log.DEBUG)) _log.debug("Send request to: " + state.getRemoteHostId().toString()); UDPPacket packet = _builder.buildSessionRequestPacket(state); @@ -703,7 +702,6 @@ public class EstablishmentManager { } private void sendConfirmation(OutboundEstablishState state) { - long now = _context.clock().now(); boolean valid = state.validateSessionCreated(); if (!valid) // validate clears fields on failure return; @@ -841,11 +839,11 @@ public class EstablishmentManager { long now = _context.clock().now(); long nextSendTime = -1; OutboundEstablishState outboundState = null; - int admitted = 0; - int remaining = 0; - int active = 0; + //int admitted = 0; + //int remaining = 0; + //int active = 0; synchronized (_outboundStates) { - active = _outboundStates.size(); + //active = _outboundStates.size(); //if (_log.shouldLog(Log.DEBUG)) // _log.debug("# outbound states: " + _outboundStates.size()); for (Iterator iter = _outboundStates.values().iterator(); iter.hasNext(); ) { @@ -891,8 +889,8 @@ public class EstablishmentManager { } } - admitted = locked_admitQueued(); - remaining = _queuedOutbound.size(); + //admitted = locked_admitQueued(); + //remaining = _queuedOutbound.size(); } //if (admitted > 0) diff --git a/router/java/src/net/i2p/router/transport/udp/PeerState.java b/router/java/src/net/i2p/router/transport/udp/PeerState.java index 3b9973f53a..f3cd1e2691 100644 --- a/router/java/src/net/i2p/router/transport/udp/PeerState.java +++ b/router/java/src/net/i2p/router/transport/udp/PeerState.java @@ -903,9 +903,10 @@ public class PeerState { /** we are resending a packet, so lets jack up the rto */ public void messageRetransmitted(int packets) { - long now = _context.clock().now(); - if (true || _retransmissionPeriodStart + 1000 <= now) { + //long now = _context.clock().now(); + //if (true || _retransmissionPeriodStart + 1000 <= now) { _packetsRetransmitted += packets; + /***** } else { _packetRetransmissionRate = (int)((float)(0.9f*_packetRetransmissionRate) + (float)(0.1f*_packetsRetransmitted)); //_packetsPeriodTransmitted = _packetsTransmitted - _retransmissionPeriodStart; @@ -913,21 +914,24 @@ public class PeerState { _retransmissionPeriodStart = now; _packetsRetransmitted = packets; } + *****/ congestionOccurred(); _context.statManager().addRateData("udp.congestedRTO", _rto, _rttDeviation); adjustMTU(); //_rto *= 2; } public void packetsTransmitted(int packets) { - long now = _context.clock().now(); + //long now = _context.clock().now(); _packetsTransmitted += packets; //_packetsPeriodTransmitted += packets; + /***** if (false && _retransmissionPeriodStart + 1000 <= now) { _packetRetransmissionRate = (int)((float)(0.9f*_packetRetransmissionRate) + (float)(0.1f*_packetsRetransmitted)); _retransmissionPeriodStart = 0; _packetsPeriodRetransmitted = (int)_packetsRetransmitted; _packetsRetransmitted = 0; } + *****/ } /** how long does it usually take to get a message ACKed? */ public int getRTT() { return _rtt; } diff --git a/router/java/src/net/i2p/router/transport/udp/UDPReceiver.java b/router/java/src/net/i2p/router/transport/udp/UDPReceiver.java index bdb04a95a2..10876a0e7d 100644 --- a/router/java/src/net/i2p/router/transport/udp/UDPReceiver.java +++ b/router/java/src/net/i2p/router/transport/udp/UDPReceiver.java @@ -34,7 +34,7 @@ public class UDPReceiver { public UDPReceiver(RouterContext ctx, UDPTransport transport, DatagramSocket socket, String name) { _context = ctx; _log = ctx.logManager().getLog(UDPReceiver.class); - _id = ++_id; + _id++; _name = name; _inboundQueue = new ArrayList(128); _socket = socket; diff --git a/router/java/src/net/i2p/router/transport/udp/UDPSender.java b/router/java/src/net/i2p/router/transport/udp/UDPSender.java index 5339587992..141b878928 100644 --- a/router/java/src/net/i2p/router/transport/udp/UDPSender.java +++ b/router/java/src/net/i2p/router/transport/udp/UDPSender.java @@ -101,13 +101,13 @@ public class UDPSender { * @return number of packets queued */ public int add(UDPPacket packet, int blockTime) { - long expiration = _context.clock().now() + blockTime; + //long expiration = _context.clock().now() + blockTime; int remaining = -1; long lifetime = -1; boolean added = false; int removed = 0; while ( (_keepRunning) && (remaining < 0) ) { - try { + //try { synchronized (_outboundQueue) { // clear out any too-old packets UDPPacket head = null; @@ -123,12 +123,13 @@ public class UDPSender { } } - if (true || (_outboundQueue.size() < MAX_QUEUED)) { + //if (true || (_outboundQueue.size() < MAX_QUEUED)) { lifetime = packet.getLifetime(); _outboundQueue.add(packet); added = true; remaining = _outboundQueue.size(); _outboundQueue.notifyAll(); + /***** } else { long remainingTime = expiration - _context.clock().now(); if (remainingTime > 0) { @@ -139,8 +140,9 @@ public class UDPSender { } lifetime = packet.getLifetime(); } + *****/ } - } catch (InterruptedException ie) {} + //} catch (InterruptedException ie) {} } _context.statManager().addRateData("udp.sendQueueSize", remaining, lifetime); if (!added) diff --git a/router/java/src/net/i2p/router/tunnel/BuildMessageGenerator.java b/router/java/src/net/i2p/router/tunnel/BuildMessageGenerator.java index b6349ccecb..ec33678e9a 100644 --- a/router/java/src/net/i2p/router/tunnel/BuildMessageGenerator.java +++ b/router/java/src/net/i2p/router/tunnel/BuildMessageGenerator.java @@ -23,7 +23,7 @@ import net.i2p.util.Log; public class BuildMessageGenerator { // cached, rather than creating lots of temporary Integer objects whenever we build a tunnel public static final Integer ORDER[] = new Integer[TunnelBuildMessage.RECORD_COUNT]; - static { for (int i = 0; i < ORDER.length; i++) ORDER[i] = new Integer(i); } + static { for (int i = 0; i < ORDER.length; i++) ORDER[i] = Integer.valueOf(i); } /** return null if it is unable to find a router's public key (etc) */ public TunnelBuildMessage createInbound(RouterContext ctx, TunnelCreatorConfig cfg) { diff --git a/router/java/src/net/i2p/router/tunnel/FragmentHandler.java b/router/java/src/net/i2p/router/tunnel/FragmentHandler.java index 85aa7d05ef..0637440016 100644 --- a/router/java/src/net/i2p/router/tunnel/FragmentHandler.java +++ b/router/java/src/net/i2p/router/tunnel/FragmentHandler.java @@ -362,6 +362,8 @@ public class FragmentHandler { } private void receiveComplete(FragmentedMessage msg) { + if (msg == null) + return; _completed++; String stringified = null; if (_log.shouldLog(Log.DEBUG)) @@ -370,8 +372,6 @@ public class FragmentHandler { int fragmentCount = msg.getFragmentCount(); // toByteArray destroys the contents of the message completely byte data[] = msg.toByteArray(); - if (msg == null) - return; if (_log.shouldLog(Log.DEBUG)) _log.debug("RECV(" + data.length + "): " + Base64.encode(data) + " " + _context.sha().calculateHash(data).toBase64()); diff --git a/router/java/src/net/i2p/router/tunnel/InboundEndpointProcessor.java b/router/java/src/net/i2p/router/tunnel/InboundEndpointProcessor.java index 0635afc0e2..6c572cb426 100644 --- a/router/java/src/net/i2p/router/tunnel/InboundEndpointProcessor.java +++ b/router/java/src/net/i2p/router/tunnel/InboundEndpointProcessor.java @@ -77,7 +77,7 @@ public class InboundEndpointProcessor { RouterContext ctx = null; if (_context instanceof RouterContext) ctx = (RouterContext)_context; - if ( (ctx != null) && (_config != null) && (_config.getLength() > 0) ) { + if ( (ctx != null) && (_config.getLength() > 0) ) { int rtt = 0; // dunno... may not be related to an rtt if (_log.shouldLog(Log.DEBUG)) _log.debug("Received a " + length + "byte message through tunnel " + _config); diff --git a/router/java/src/net/i2p/router/tunnel/PumpedTunnelGateway.java b/router/java/src/net/i2p/router/tunnel/PumpedTunnelGateway.java index 2356028eee..a2cac90bb9 100644 --- a/router/java/src/net/i2p/router/tunnel/PumpedTunnelGateway.java +++ b/router/java/src/net/i2p/router/tunnel/PumpedTunnelGateway.java @@ -60,13 +60,10 @@ public class PumpedTunnelGateway extends TunnelGateway { */ public void add(I2NPMessage msg, Hash toRouter, TunnelId toTunnel) { _messagesSent++; - long startAdd = System.currentTimeMillis(); Pending cur = new PendingImpl(msg, toRouter, toTunnel); long beforeLock = System.currentTimeMillis(); - long afterAdded = -1; synchronized (_prequeue) { _prequeue.add(cur); - afterAdded = System.currentTimeMillis(); } _pumper.wantsPumping(this); if (_log.shouldLog(Log.DEBUG)) diff --git a/router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java b/router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java index 18bb6273c0..8bb4781fef 100644 --- a/router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java +++ b/router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java @@ -510,7 +510,7 @@ public class TunnelDispatcher implements Service { + (before-msg.getMessageExpiration()) + "ms ago? " + msg, new Exception("cause")); } - long tid1 = (outboundTunnel != null ? outboundTunnel.getTunnelId() : -1); + long tid1 = outboundTunnel.getTunnelId(); long tid2 = (targetTunnel != null ? targetTunnel.getTunnelId() : -1); _context.messageHistory().tunnelDispatched(msg.getUniqueId(), tid1, tid2, targetPeer, "outbound gateway"); gw.add(msg, targetPeer, targetTunnel); diff --git a/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java b/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java index 96f01a210a..9dcf1e5e8a 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java +++ b/router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java @@ -245,7 +245,7 @@ class BuildHandler { // For each peer in the tunnel for (int i = 0; i < cfg.getLength(); i++) { Hash peer = cfg.getPeer(i); - int record = order.indexOf(new Integer(i)); + int record = order.indexOf(Integer.valueOf(i)); if (record < 0) { _log.error("Bad status index " + i); return; @@ -483,7 +483,7 @@ class BuildHandler { int proactiveDrops = countProactiveDrops(); long recvDelay = System.currentTimeMillis()-state.recvTime; if (response == 0) { - float pDrop = recvDelay / (BuildRequestor.REQUEST_TIMEOUT*3); + float pDrop = ((float) recvDelay) / (float) (BuildRequestor.REQUEST_TIMEOUT*3); pDrop = (float)Math.pow(pDrop, 16); if (_context.random().nextFloat() < pDrop) { // || (proactiveDrops > MAX_PROACTIVE_DROPS) ) ) { _context.statManager().addRateData("tunnel.rejectOverloaded", recvDelay, proactiveDrops); @@ -648,7 +648,7 @@ class BuildHandler { + ", waiting ids: " + ids + ", found matching tunnel? " + (cfg != null), null);//new Exception("source")); if (cfg != null) { - BuildEndMessageState state = new BuildEndMessageState(cfg, receivedMessage, from, fromHash); + BuildEndMessageState state = new BuildEndMessageState(cfg, receivedMessage); if (HANDLE_REPLIES_INLINE) { handleRequestAsInboundEndpoint(state); } else { @@ -737,10 +737,10 @@ class BuildHandler { _log.debug("Receive tunnel build reply message " + receivedMessage.getUniqueId() + " from " + (fromHash != null ? fromHash.toBase64() : from != null ? from.calculateHash().toBase64() : "a tunnel")); if (HANDLE_REPLIES_INLINE) { - handleReply(new BuildReplyMessageState(receivedMessage, from, fromHash)); + handleReply(new BuildReplyMessageState(receivedMessage)); } else { synchronized (_inboundBuildReplyMessages) { - _inboundBuildReplyMessages.add(new BuildReplyMessageState(receivedMessage, from, fromHash)); + _inboundBuildReplyMessages.add(new BuildReplyMessageState(receivedMessage)); } _exec.repoll(); } @@ -764,13 +764,9 @@ class BuildHandler { /** replies for outbound tunnels that we have created */ private class BuildReplyMessageState { TunnelBuildReplyMessage msg; - RouterIdentity from; - Hash fromHash; long recvTime; - public BuildReplyMessageState(I2NPMessage m, RouterIdentity f, Hash h) { + public BuildReplyMessageState(I2NPMessage m) { msg = (TunnelBuildReplyMessage)m; - from = f; - fromHash = h; recvTime = System.currentTimeMillis(); } } @@ -778,14 +774,10 @@ class BuildHandler { private class BuildEndMessageState { TunnelBuildMessage msg; PooledTunnelCreatorConfig cfg; - RouterIdentity from; - Hash fromHash; long recvTime; - public BuildEndMessageState(PooledTunnelCreatorConfig c, I2NPMessage m, RouterIdentity f, Hash h) { + public BuildEndMessageState(PooledTunnelCreatorConfig c, I2NPMessage m) { cfg = c; msg = (TunnelBuildMessage)m; - from = f; - fromHash = h; recvTime = System.currentTimeMillis(); } } diff --git a/router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java b/router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java index c33a213de8..a4917772fa 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java +++ b/router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java @@ -25,7 +25,7 @@ class BuildRequestor { private static final List ORDER = new ArrayList(BuildMessageGenerator.ORDER.length); static { for (int i = 0; i < BuildMessageGenerator.ORDER.length; i++) - ORDER.add(new Integer(i)); + ORDER.add(Integer.valueOf(i)); } private static final int PRIORITY = 500; static final int REQUEST_TIMEOUT = 10*1000; diff --git a/router/java/src/net/i2p/router/tunnel/pool/TunnelPeerSelector.java b/router/java/src/net/i2p/router/tunnel/pool/TunnelPeerSelector.java index 2bd6ee7aa8..1e0247c022 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/TunnelPeerSelector.java +++ b/router/java/src/net/i2p/router/tunnel/pool/TunnelPeerSelector.java @@ -103,7 +103,6 @@ public abstract class TunnelPeerSelector { Log log = ctx.logManager().getLog(ClientPeerSelector.class); List rv = new ArrayList(); StringTokenizer tok = new StringTokenizer(peers, ","); - Hash h = new Hash(); while (tok.hasMoreTokens()) { String peerStr = tok.nextToken(); Hash peer = new Hash(); @@ -307,7 +306,6 @@ public abstract class TunnelPeerSelector { private static char[] getExcludeCaps(RouterContext ctx) { String excludeCaps = ctx.getProperty("router.excludePeerCaps", String.valueOf(Router.CAPABILITY_BW12)); - Set peers = new HashSet(); if (excludeCaps != null) { char excl[] = excludeCaps.toCharArray(); return excl; @@ -342,7 +340,6 @@ public abstract class TunnelPeerSelector { String val = peer.getOption("stat_uptime"); if (val != null) { long uptimeMs = 0; - if (val != null) { long factor = 1; if (val.endsWith("ms")) { factor = 1; @@ -362,10 +359,6 @@ public abstract class TunnelPeerSelector { } try { uptimeMs = Long.parseLong(val); } catch (NumberFormatException nfe) {} uptimeMs *= factor; - } else { - // not publishing an uptime, so exclude it - return true; - } long infoAge = ctx.clock().now() - peer.getPublished(); if (infoAge < 0) { @@ -391,7 +384,7 @@ public abstract class TunnelPeerSelector { } } } else { - // not publishing stats, so exclude it + // not publishing an uptime, so exclude it return true; } } diff --git a/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java b/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java index 57d08d8593..0fca44cc42 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java +++ b/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java @@ -336,13 +336,11 @@ public class TunnelPool { public void tunnelFailed(PooledTunnelCreatorConfig cfg) { if (_log.shouldLog(Log.WARN)) _log.warn(toString() + ": Tunnel failed: " + cfg); - int remaining = 0; LeaseSet ls = null; synchronized (_tunnels) { _tunnels.remove(cfg); if (_settings.isInbound() && (_settings.getDestination() != null) ) ls = locked_buildNewLeaseSet(); - remaining = _tunnels.size(); if (_lastSelected == cfg) { _lastSelected = null; _lastSelectionPeriod = 0; @@ -403,12 +401,10 @@ public class TunnelPool { void refreshLeaseSet() { if (_log.shouldLog(Log.DEBUG)) _log.debug(toString() + ": refreshing leaseSet on tunnel expiration (but prior to grace timeout)"); - int remaining = 0; LeaseSet ls = null; if (_settings.isInbound() && (_settings.getDestination() != null) ) { synchronized (_tunnels) { ls = locked_buildNewLeaseSet(); - remaining = _tunnels.size(); } if (ls != null) { _context.clientManager().requestLeaseSet(_settings.getDestination(), ls);