From 90b8aa7811d9fd91dd2053d0822a45e99721aa2f Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Fri, 8 Jul 2011 18:31:50 +0000
Subject: [PATCH] concurrent

---
 .../i2p/client/RequestLeaseSetMessageHandler.java | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/core/java/src/net/i2p/client/RequestLeaseSetMessageHandler.java b/core/java/src/net/i2p/client/RequestLeaseSetMessageHandler.java
index b9959573d8..663c01b7bb 100644
--- a/core/java/src/net/i2p/client/RequestLeaseSetMessageHandler.java
+++ b/core/java/src/net/i2p/client/RequestLeaseSetMessageHandler.java
@@ -9,8 +9,8 @@ package net.i2p.client;
  *
  */
 
-import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import net.i2p.I2PAppContext;
 import net.i2p.crypto.KeyGenerator;
@@ -38,7 +38,8 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
 
     public RequestLeaseSetMessageHandler(I2PAppContext context) {
         super(context, RequestLeaseSetMessage.MESSAGE_TYPE);
-        _existingLeaseSets = new HashMap(32);
+        // not clear why there would ever be more than one
+        _existingLeaseSets = new ConcurrentHashMap(4);
     }
     
     public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
@@ -58,16 +59,10 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
         leaseSet.setDestination(session.getMyDestination());
 
         // reuse the old keys for the client
-        LeaseInfo li = null;
-        synchronized (_existingLeaseSets) {
-            if (_existingLeaseSets.containsKey(session.getMyDestination()))
-                li = (LeaseInfo) _existingLeaseSets.get(session.getMyDestination());
-        }
+        LeaseInfo li = (LeaseInfo) _existingLeaseSets.get(session.getMyDestination());
         if (li == null) {
             li = new LeaseInfo(session.getMyDestination());
-            synchronized (_existingLeaseSets) {
-                _existingLeaseSets.put(session.getMyDestination(), li);
-            }
+            _existingLeaseSets.put(session.getMyDestination(), li);
             if (_log.shouldLog(Log.DEBUG))
                 _log.debug("Creating new leaseInfo keys for "  
                            + session.getMyDestination().calculateHash().toBase64());
-- 
GitLab