From 6822bf7978cc5ce1ceb9930575e3c5a7a3a7dc4c Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Wed, 5 Jan 2011 14:49:51 +0000
Subject: [PATCH] findbugs high-rank issues

---
 .../net/i2p/i2ptunnel/I2PTunnelClientBase.java   |  2 +-
 core/java/src/net/i2p/crypto/TrustedUpdate.java  | 16 ++++++++--------
 .../message/OutboundClientMessageOneShotJob.java |  2 +-
 .../networkdb/kademlia/FloodOnlySearchJob.java   |  1 -
 .../i2p/router/tunnel/PumpedTunnelGateway.java   |  1 -
 5 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java
index a98551b8c5..ae723661c6 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java
@@ -98,7 +98,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
         _clientId = clientId;
         this.localPort = localPort;
         this.l = l;
-        this.handlerName = handlerName + _clientId;
+        this.handlerName = localPort + " #" + _clientId;
         _ownDest = true; // == ! shared client
         _context = tunnel.getContext();
         _context.statManager().createRateStat("i2ptunnel.client.closeBacklog", "How many pending sockets remain when we close one due to backlog?", "I2PTunnel", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
diff --git a/core/java/src/net/i2p/crypto/TrustedUpdate.java b/core/java/src/net/i2p/crypto/TrustedUpdate.java
index fdf63697df..43ca162838 100644
--- a/core/java/src/net/i2p/crypto/TrustedUpdate.java
+++ b/core/java/src/net/i2p/crypto/TrustedUpdate.java
@@ -182,14 +182,6 @@ JXQAnA28vDmMMMH/WPbC5ixmJeGGNUiR
      *  @return true if successful
      */
     public boolean addKey(String key, String name) {
-        String oldName = _trustedKeys.get(key);
-        // already there?
-        if (name.equals(oldName))
-            return true;
-        if (oldName != null && !oldName.equals("")) {
-            _log.error("Key for " + name + " already stored for different name " + oldName + " : " + key);
-            return false;
-        }
         SigningPublicKey signingPublicKey = new SigningPublicKey();
         try {
             // fromBase64() will throw a DFE if length is not right
@@ -198,6 +190,14 @@ JXQAnA28vDmMMMH/WPbC5ixmJeGGNUiR
             _log.error("Invalid signing key for " + name + " : " + key, dfe);
             return false;
         }
+        String oldName = _trustedKeys.get(signingPublicKey);
+        // already there?
+        if (name.equals(oldName))
+            return true;
+        if (oldName != null && !oldName.equals("")) {
+            _log.error("Key for " + name + " already stored for different name " + oldName + " : " + key);
+            return false;
+        }
         if ((!name.equals("")) && _trustedKeys.containsValue(name)) {
             _log.error("Key mismatch for " + name + ", spoof attempt? : " + key);
             return false;
diff --git a/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java b/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java
index 5adadaae22..bfa0941993 100644
--- a/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java
+++ b/router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java
@@ -348,7 +348,7 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
                 }
                 if (_log.shouldLog(Log.INFO))
                     _log.info(getJobId() + ": Expired from cache - lease for " + _toString); 
-                _leaseCache.remove(_to);
+                _leaseCache.remove(hashPair());
             }
         }
 
diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/FloodOnlySearchJob.java b/router/java/src/net/i2p/router/networkdb/kademlia/FloodOnlySearchJob.java
index 9f21962c19..72c59ad839 100644
--- a/router/java/src/net/i2p/router/networkdb/kademlia/FloodOnlySearchJob.java
+++ b/router/java/src/net/i2p/router/networkdb/kademlia/FloodOnlySearchJob.java
@@ -37,7 +37,6 @@ import net.i2p.util.Log;
  *
  */
 class FloodOnlySearchJob extends FloodSearchJob {
-    protected volatile int _lookupsRemaining;
     private volatile boolean _dead;
     private long _created;
     private boolean _shouldProcessDSRM;
diff --git a/router/java/src/net/i2p/router/tunnel/PumpedTunnelGateway.java b/router/java/src/net/i2p/router/tunnel/PumpedTunnelGateway.java
index a761ef1208..b276737217 100644
--- a/router/java/src/net/i2p/router/tunnel/PumpedTunnelGateway.java
+++ b/router/java/src/net/i2p/router/tunnel/PumpedTunnelGateway.java
@@ -135,7 +135,6 @@ public class PumpedTunnelGateway extends TunnelGateway {
         if (_log.shouldLog(Log.DEBUG))
             _log.debug("Time to add " + queueBuf.size() + " messages to " + toString() + ": " + (complete-startAdd)
                        + " delayed? " + delayedFlush + " remaining: " + remaining
-                       + " prepare: " + (beforeLock-startAdd)
                        + " add: " + (afterAdded-beforeLock)
                        + " preprocess: " + (afterPreprocess-afterAdded)
                        + " expire: " + (afterExpire-afterPreprocess)
-- 
GitLab