Changeset bacce17


Ignore:
Timestamp:
Nov 20, 2013 2:46:24 AM (7 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
89dccee
Parents:
e61e950
Message:

Router: type arguments, unused imports

Location:
router/java/src/net/i2p
Files:
140 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/data/i2np/DatabaseLookupMessage.java

    re61e950 rbacce17  
    213213        if (_dontIncludePeers == null)
    214214            return null;
    215         return new HashSet(_dontIncludePeers);
     215        return new HashSet<Hash>(_dontIncludePeers);
    216216    }
    217217
     
    226226        _hasChecksum = false;
    227227        if (peers != null)
    228             _dontIncludePeers = new ArrayList(peers);
     228            _dontIncludePeers = new ArrayList<Hash>(peers);
    229229        else
    230230            _dontIncludePeers = null;
     
    240240    public void addDontIncludePeer(Hash peer) {
    241241        if (_dontIncludePeers == null)
    242             _dontIncludePeers = new ArrayList();
     242            _dontIncludePeers = new ArrayList<Hash>();
    243243        else if (_dontIncludePeers.contains(peer))
    244244            return;
     
    257257        _hasChecksum = false;
    258258        if (_dontIncludePeers == null) {
    259             _dontIncludePeers = new ArrayList(peers);
     259            _dontIncludePeers = new ArrayList<Hash>(peers);
    260260        } else {
    261261            for (Hash peer : peers) {
     
    298298        if ( (numPeers < 0) || (numPeers > MAX_NUM_PEERS) )
    299299            throw new I2NPMessageException("Invalid number of peers - " + numPeers);
    300         List<Hash> peers = new ArrayList(numPeers);
     300        List<Hash> peers = new ArrayList<Hash>(numPeers);
    301301        for (int i = 0; i < numPeers; i++) {
    302302            //byte peer[] = new byte[Hash.HASH_LENGTH];
  • router/java/src/net/i2p/data/i2np/DatabaseSearchReplyMessage.java

    re61e950 rbacce17  
    3434        //_context.statManager().createRateStat("netDb.searchReplyMessageSend", "How many search reply messages we send", "NetworkDatabase", new long[] { 60*1000, 5*60*1000, 10*60*1000, 60*60*1000 });
    3535        //_context.statManager().createRateStat("netDb.searchReplyMessageReceive", "How many search reply messages we receive", "NetworkDatabase", new long[] { 60*1000, 5*60*1000, 10*60*1000, 60*60*1000 });
    36         _peerHashes = new ArrayList(3);
     36        _peerHashes = new ArrayList<Hash>(3);
    3737    }
    3838   
  • router/java/src/net/i2p/data/i2np/I2NPMessageException.java

    re61e950 rbacce17  
    1010
    1111import net.i2p.I2PException;
    12 import net.i2p.util.Log;
    1312
    1413/**
  • router/java/src/net/i2p/data/i2np/I2NPMessageImpl.java

    re61e950 rbacce17  
    4949   
    5050    /** unused */
    51     private static final Map<Integer, Builder> _builders = new ConcurrentHashMap(1);
     51    private static final Map<Integer, Builder> _builders = new ConcurrentHashMap<Integer, Builder>(1);
    5252
    5353    /** @deprecated unused */
  • router/java/src/net/i2p/router/Banlist.java

    re61e950 rbacce17  
    5959        _context = context;
    6060        _log = context.logManager().getLog(Banlist.class);
    61         _entries = new ConcurrentHashMap(16);
     61        _entries = new ConcurrentHashMap<Hash, Entry>(16);
    6262        _context.jobQueue().addJob(new Cleanup(_context));
    6363    }
     
    6767        public Cleanup(RouterContext ctx) {
    6868            super(ctx);
    69             _toUnbanlist = new ArrayList(4);
     69            _toUnbanlist = new ArrayList<Hash>(4);
    7070            getTiming().setStartAfter(ctx.clock().now() + BANLIST_CLEANER_START_DELAY);
    7171        }
     
    7575            long now = getContext().clock().now();
    7676            try {
    77                 for (Iterator iter = _entries.entrySet().iterator(); iter.hasNext(); ) {
    78                     Map.Entry<Hash, Entry> e = (Map.Entry) iter.next();
     77                for (Iterator<Map.Entry<Hash, Entry>> iter = _entries.entrySet().iterator(); iter.hasNext(); ) {
     78                    Map.Entry<Hash, Entry> e = iter.next();
    7979                    if (e.getValue().expireOn <= now) {
    8080                        iter.remove();
     
    170170        e.transports = null;
    171171        if (transport != null) {
    172             e.transports = new ConcurrentHashSet(2);
     172            e.transports = new ConcurrentHashSet<String>(2);
    173173            e.transports.add(transport);
    174174        }
  • router/java/src/net/i2p/router/Blocklist.java

    re61e950 rbacce17  
    7676    private final Object _lock = new Object();
    7777    private Entry _wrapSave;
    78     private final Set<Hash> _inProcess = new HashSet(4);
    79     private Map<Hash, String> _peerBlocklist = new HashMap(4);
     78    private final Set<Hash> _inProcess = new HashSet<Hash>(4);
     79    private Map<Hash, String> _peerBlocklist = new HashMap<Hash, String>(4);
    8080
    8181    /**
     
    8787    private static final int MAX_IPV6_SINGLES = 512;
    8888
    89     private final Set<Integer> _singleIPBlocklist = new ConcurrentHashSet(4);
    90     private final Map<BigInteger, Object> _singleIPv6Blocklist = new LHMCache(MAX_IPV6_SINGLES);
     89    private final Set<Integer> _singleIPBlocklist = new ConcurrentHashSet<Integer>(4);
     90    private final Map<BigInteger, Object> _singleIPv6Blocklist = new LHMCache<BigInteger, Object>(MAX_IPV6_SINGLES);
    9191
    9292    private static final Object DUMMY = Integer.valueOf(0);   
     
    519519        RouterInfo pinfo = _context.netDb().lookupRouterInfoLocally(peer);
    520520        if (pinfo == null)
    521             return Collections.EMPTY_LIST;
    522         List<byte[]> rv = new ArrayList(4);
     521            return Collections.emptyList();
     522        List<byte[]> rv = new ArrayList<byte[]>(4);
    523523        // for each peer address
    524524        for (RouterAddress pa : pinfo.getAddresses()) {
     
    754754     * Although could this clog up the job queue runners? Yes.
    755755     * So we also stagger these jobs.
    756      *
     756     *(Map.Entry)
    757757     */
    758758    private synchronized void banlistForever(Hash peer, List<byte[]> ips) {
     
    819819        // move to the jsp
    820820        //out.write("<h2>Banned IPs</h2>");
    821         Set<Integer> singles = new TreeSet();
     821        Set<Integer> singles = new TreeSet<Integer>();
    822822        singles.addAll(_singleIPBlocklist);
    823823        if (!(singles.isEmpty() && _singleIPv6Blocklist.isEmpty())) {
     
    847847                List<BigInteger> s6;
    848848                synchronized(_singleIPv6Blocklist) {
    849                     s6 = new ArrayList(_singleIPv6Blocklist.keySet());
     849                    s6 = new ArrayList<BigInteger>(_singleIPv6Blocklist.keySet());
    850850                }
    851851                Collections.sort(s6);
  • router/java/src/net/i2p/router/ClientManagerFacade.java

    re61e950 rbacce17  
    9090     * @return set of Destination objects
    9191     */
    92     public Set<Destination> listClients() { return Collections.EMPTY_SET; }
     92    public Set<Destination> listClients() { return Collections.emptySet(); }
    9393   
    9494    /**
  • router/java/src/net/i2p/router/CommSystemFacade.java

    re61e950 rbacce17  
    1313import java.util.Collections;
    1414import java.util.List;
    15 import java.util.Set;
    16 
    1715import net.i2p.data.Hash;
    1816import net.i2p.data.RouterAddress;
     
    3028   
    3129    /** Create the list of RouterAddress structures based on the router's config */
    32     public List<RouterAddress> createAddresses() { return Collections.EMPTY_LIST; }
     30    public List<RouterAddress> createAddresses() { return Collections.emptyList(); }
    3331   
    3432    public int countActivePeers() { return 0; }
     
    3735    public boolean haveOutboundCapacity(int pct) { return true; }
    3836    public boolean haveHighOutboundCapacity() { return true; }
    39     public List getMostRecentErrorMessages() { return Collections.EMPTY_LIST; }
     37    public List getMostRecentErrorMessages() { return Collections.emptyList(); }
    4038   
    4139    /**
  • router/java/src/net/i2p/router/InNetMessagePool.java

    re61e950 rbacce17  
    3737
    3838    /** following 5 unused unless DISPATCH_DIRECT == false */
    39     private final List _pendingDataMessages;
    40     private final List _pendingDataMessagesFrom;
    41     private final List _pendingGatewayMessages;
     39    private final List<I2NPMessage> _pendingDataMessages;
     40    private final List<Hash> _pendingDataMessagesFrom;
     41    private final List<I2NPMessage> _pendingGatewayMessages;
    4242    private SharedShortCircuitDataJob _shortCircuitDataJob;
    4343    private SharedShortCircuitGatewayJob _shortCircuitGatewayJob;
     
    5757     *
    5858     */
    59     public static final String PROP_DISPATCH_THREADED = "router.dispatchThreaded";
     59    public static final String PROP_DISPATCH_THREADED = "router.dispatchTemptyList()hreaded";
    6060    public static final boolean DEFAULT_DISPATCH_THREADED = false;
    6161    /**
     
    7676            _pendingGatewayMessages = null;
    7777        } else {
    78             _pendingDataMessages = new ArrayList(16);
    79             _pendingDataMessagesFrom = new ArrayList(16);
    80             _pendingGatewayMessages = new ArrayList(16);
     78            _pendingDataMessages = new ArrayList<I2NPMessage>(16);
     79            _pendingDataMessagesFrom = new ArrayList<Hash>(16);
     80            _pendingGatewayMessages = new ArrayList<I2NPMessage>(16);
    8181            _shortCircuitDataJob = new SharedShortCircuitDataJob(context);
    8282            _shortCircuitGatewayJob = new SharedShortCircuitGatewayJob(context);
  • router/java/src/net/i2p/router/KeyManager.java

    re61e950 rbacce17  
    1313import java.io.File;
    1414import java.io.FileInputStream;
    15 import java.io.FileOutputStream;
    1615import java.io.InputStream;
    1716import java.io.IOException;
     
    2827import net.i2p.data.SigningPrivateKey;
    2928import net.i2p.data.SigningPublicKey;
    30 import net.i2p.util.Clock;
    3129import net.i2p.util.Log;
    3230import net.i2p.util.SecureDirectory;
     
    5856        _context = context;
    5957        _log = _context.logManager().getLog(KeyManager.class); 
    60         _leaseSetKeys = new ConcurrentHashMap();
     58        _leaseSetKeys = new ConcurrentHashMap<Hash, LeaseSetKeys>();
    6159    }
    6260   
  • router/java/src/net/i2p/router/MessageHistory.java

    re61e950 rbacce17  
    5757         _fmt = new SimpleDateFormat("yy/MM/dd.HH:mm:ss.SSS");
    5858        _fmt.setTimeZone(TimeZone.getTimeZone("GMT"));
    59         _unwrittenEntries = new LinkedBlockingQueue();
     59        _unwrittenEntries = new LinkedBlockingQueue<String>();
    6060        _reinitializeJob = new ReinitializeJob();
    6161        _writeJob = new WriteJob();
  • router/java/src/net/i2p/router/MultiRouter.java

    re61e950 rbacce17  
    22
    33import java.io.File;
    4 import java.io.FileInputStream;
    54import java.io.IOException;
    65import java.io.PrintStream;
     
    1413import net.i2p.data.RouterInfo;
    1514import net.i2p.router.Router;
    16 import net.i2p.util.Log;
    1715
    1816/**
  • router/java/src/net/i2p/router/NetworkDatabaseFacade.java

    re61e950 rbacce17  
    7878    public void renderStatusHTML(Writer out) throws IOException {}
    7979    /** public for NetDbRenderer in routerconsole */
    80     public Set<LeaseSet> getLeases() { return Collections.EMPTY_SET; }
     80    public Set<LeaseSet> getLeases() { return Collections.emptySet(); }
    8181    /** public for NetDbRenderer in routerconsole */
    82     public Set<RouterInfo> getRouters() { return Collections.EMPTY_SET; }
     82    public Set<RouterInfo> getRouters() { return Collections.emptySet(); }
    8383
    8484    /** @since 0.9 */
  • router/java/src/net/i2p/router/OutNetMessage.java

    re61e950 rbacce17  
    155155            }
    156156        }
    157         return Collections.EMPTY_MAP;
     157        return Collections.emptyMap();
    158158    }
    159159
     
    171171    private void locked_initTimestamps() {
    172172        if (_timestamps == null) {
    173             _timestamps = new HashMap(8);
    174             _timestampOrder = new ArrayList(8);
     173            _timestamps = new HashMap<String, Long>(8);
     174            _timestampOrder = new ArrayList<String>(8);
    175175        }
    176176    }
     
    280280    public synchronized void transportFailed(String transportStyle) {
    281281        if (_failedTransports == null)
    282             _failedTransports = new HashSet(2);
     282            _failedTransports = new HashSet<String>(2);
    283283        _failedTransports.add(transportStyle);
    284284    }
  • router/java/src/net/i2p/router/Router.java

    re61e950 rbacce17  
    1212import java.io.File;
    1313import java.io.FileInputStream;
    14 import java.io.FileOutputStream;
    1514import java.io.InputStreamReader;
    1615import java.io.IOException;
    1716import java.util.Collection;
    1817import java.util.Collections;
    19 import java.util.Date;
    20 import java.util.Iterator;
    2118import java.util.List;
    2219import java.util.Locale;
     
    2522import java.util.Set;
    2623import java.util.TimeZone;
    27 import java.util.TreeSet;
    2824import java.util.concurrent.ConcurrentHashMap;
    2925
     
    5450import net.i2p.util.SecureFileOutputStream;
    5551import net.i2p.util.SimpleByteCache;
    56 import net.i2p.util.SimpleScheduler;
    5752import net.i2p.util.SystemVersion;
    5853import net.i2p.util.Translate;
     
    148143    public Router(String configFilename, Properties envProps) {
    149144        _gracefulExitCode = -1;
    150         _config = new ConcurrentHashMap();
     145        _config = new ConcurrentHashMap<String, String>();
    151146
    152147        if (configFilename == null) {
     
    10291024     * @since 0.8.13
    10301025     */
    1031     public boolean saveConfig(Map toAdd, Collection<String> toRemove) {
     1026    public boolean saveConfig(Map<String, String> toAdd, Collection<String> toRemove) {
    10321027        synchronized(_configFileLock) {
    10331028            if (toAdd != null)
  • router/java/src/net/i2p/router/RouterClock.java

    re61e950 rbacce17  
    5858        _lastStratum = WORST_STRATUM;
    5959        _lastSlewed = System.currentTimeMillis();
    60         _shiftListeners = new CopyOnWriteArraySet();
     60        _shiftListeners = new CopyOnWriteArraySet<ClockShiftListener>();
    6161        _lastShiftNanos = System.nanoTime();
    6262        _timeStamper = new RouterTimestamper(context, this);
  • router/java/src/net/i2p/router/RouterContext.java

    re61e950 rbacce17  
    11package net.i2p.router;
    22
    3 import java.util.ArrayList;
    43import java.util.Collections;
    54import java.util.List;
     
    7069    private final Object _lock1 = new Object(), _lock2 = new Object(), _lock3 = new Object();
    7170
    72     private static final List<RouterContext> _contexts = new CopyOnWriteArrayList();
     71    private static final List<RouterContext> _contexts = new CopyOnWriteArrayList<RouterContext>();
    7372   
    7473    /**
     
    9089        if (!_contexts.isEmpty())
    9190            System.err.println("Warning - More than one router in this JVM");
    92         _finalShutdownTasks = new CopyOnWriteArraySet();
     91        _finalShutdownTasks = new CopyOnWriteArraySet<Runnable>();
    9392        _contexts.add(this);
    9493    }
  • router/java/src/net/i2p/router/client/ClientConnectionRunner.java

    re61e950 rbacce17  
    4747import net.i2p.util.I2PThread;
    4848import net.i2p.util.Log;
    49 import net.i2p.util.RandomSource;
    50 import net.i2p.util.SimpleScheduler;
    5149import net.i2p.util.SimpleTimer;
    5250
     
    120118        _socket = socket;
    121119        // unused for fastReceive
    122         _messages = new ConcurrentHashMap();
    123         _alreadyProcessed = new ArrayList();
    124         _acceptedPending = new ConcurrentHashSet();
     120        _messages = new ConcurrentHashMap<MessageId, Payload>();
     121        _alreadyProcessed = new ArrayList<MessageId>();
     122        _acceptedPending = new ConcurrentHashSet<MessageId>();
    125123        _messageId = new AtomicInteger(_context.random().nextInt());
    126124    }
  • router/java/src/net/i2p/router/client/ClientManager.java

    re61e950 rbacce17  
    1212import java.io.Writer;
    1313import java.util.Collections;
    14 import java.util.HashMap;
    1514import java.util.HashSet;
    1615import java.util.Iterator;
     
    7978        //                                      "ClientMessages",
    8079        //                                      new long[] { 60*1000l, 60*60*1000l, 24*60*60*1000l });
    81         _runners = new ConcurrentHashMap();
    82         _runnersByHash = new ConcurrentHashMap();
    83         _pendingRunners = new HashSet();
     80        _runners = new ConcurrentHashMap<Destination, ClientConnectionRunner>();
     81        _runnersByHash = new ConcurrentHashMap<Hash, ClientConnectionRunner>();
     82        _pendingRunners = new HashSet<ClientConnectionRunner>();
    8483        _port = port;
    8584        // following are for RequestLeaseSetJob
     
    125124        if (_listener != null)
    126125            _listener.stopListening();
    127         Set<ClientConnectionRunner> runners = new HashSet();
     126        Set<ClientConnectionRunner> runners = new HashSet<ClientConnectionRunner>();
    128127        synchronized (_runners) {
    129128            for (Iterator<ClientConnectionRunner> iter = _runners.values().iterator(); iter.hasNext();) {
     
    154153        if (!_isStarted)
    155154            throw new I2PSessionException("Router client manager is shut down");
    156         LinkedBlockingQueue<I2CPMessage> in = new LinkedBlockingQueue(INTERNAL_QUEUE_SIZE);
    157         LinkedBlockingQueue<I2CPMessage> out = new LinkedBlockingQueue(INTERNAL_QUEUE_SIZE);
     155        LinkedBlockingQueue<I2CPMessage> in = new LinkedBlockingQueue<I2CPMessage>(INTERNAL_QUEUE_SIZE);
     156        LinkedBlockingQueue<I2CPMessage> out = new LinkedBlockingQueue<I2CPMessage>(INTERNAL_QUEUE_SIZE);
    158157        I2CPMessageQueue myQueue = new I2CPMessageQueueImpl(in, out);
    159158        I2CPMessageQueue hisQueue = new I2CPMessageQueueImpl(out, in);
     
    345344     */
    346345    public Set<Destination> listClients() {
    347         Set<Destination> rv = new HashSet();
     346        Set<Destination> rv = new HashSet<Destination>();
    348347        rv.addAll(_runners.keySet());
    349348        return rv;
  • router/java/src/net/i2p/router/client/ClientManagerFacadeImpl.java

    re61e950 rbacce17  
    1212import java.io.Writer;
    1313import java.util.Collections;
    14 import java.util.Iterator;
    1514import java.util.Set;
    1615
     
    240239            return _manager.listClients();
    241240        else
    242             return Collections.EMPTY_SET;
     241            return Collections.emptySet();
    243242    }
    244243
  • router/java/src/net/i2p/router/client/ClientWriterRunner.java

    re61e950 rbacce17  
    2929    public ClientWriterRunner(RouterContext context, ClientConnectionRunner runner) {
    3030        //_log = context.logManager().getLog(ClientWriterRunner.class);
    31         _messagesToWrite = new LinkedBlockingQueue(QUEUE_SIZE);
     31        _messagesToWrite = new LinkedBlockingQueue<I2CPMessage>(QUEUE_SIZE);
    3232        _runner = runner;
    3333        //_id = ++__id;
  • router/java/src/net/i2p/router/client/QueuedClientConnectionRunner.java

    re61e950 rbacce17  
    77import net.i2p.internal.QueuedI2CPMessageReader;
    88import net.i2p.router.RouterContext;
    9 import net.i2p.util.Log;
    109
    1110/**
  • router/java/src/net/i2p/router/client/RequestLeaseSetJob.java

    re61e950 rbacce17  
    1717import net.i2p.data.i2cp.RequestLeaseSetMessage;
    1818import net.i2p.data.i2cp.RequestVariableLeaseSetMessage;
    19 import net.i2p.router.Job;
    2019import net.i2p.router.JobImpl;
    2120import net.i2p.router.RouterContext;
  • router/java/src/net/i2p/router/client/SSLClientListenerRunner.java

    re61e950 rbacce17  
    55import java.io.IOException;
    66import java.io.InputStream;
    7 import java.io.OutputStream;
    8 import java.io.PrintWriter;
    97import java.net.InetAddress;
    108import java.net.Socket;
     
    1210import java.security.KeyStore;
    1311import java.security.GeneralSecurityException;
    14 import java.security.cert.Certificate;
    15 import java.security.cert.CertificateEncodingException;
    1612import java.util.HashMap;
    1713import java.util.Map;
     
    2218
    2319import net.i2p.client.I2PClient;
    24 import net.i2p.crypto.CertUtil;
    2520import net.i2p.crypto.KeyStoreUtil;
    26 import net.i2p.data.Base32;
    2721import net.i2p.router.RouterContext;
    2822import net.i2p.util.Log;
     
    9589            success = ks.exists();
    9690            if (success) {
    97                 Map<String, String> changes = new HashMap();
     91                Map<String, String> changes = new HashMap<String, String>();
    9892                changes.put(PROP_KEYSTORE_PASSWORD, DEFAULT_KEYSTORE_PASSWORD);
    9993                changes.put(PROP_KEY_PASSWORD, keyPassword);
  • router/java/src/net/i2p/router/dummy/DummyNetworkDatabaseFacade.java

    re61e950 rbacce17  
    2424
    2525public class DummyNetworkDatabaseFacade extends NetworkDatabaseFacade {
    26     private Map _routers;
     26    private Map<Hash, RouterInfo> _routers;
    2727    private RouterContext _context;
    2828   
    2929    public DummyNetworkDatabaseFacade(RouterContext ctx) {
    30         _routers = Collections.synchronizedMap(new HashMap());
     30        _routers = Collections.synchronizedMap(new HashMap<Hash, RouterInfo>());
    3131        _context = ctx;
    3232    }
     
    6262    }
    6363   
    64     public Set<Hash> getAllRouters() { return new HashSet(_routers.keySet()); }
     64    public Set<Hash> getAllRouters() { return new HashSet<Hash>(_routers.keySet()); }
    6565    public Set<Hash> findNearestRouters(Hash key, int maxNumRouters, Set<Hash> peersToIgnore) { return new HashSet(_routers.values()); }
    6666}
  • router/java/src/net/i2p/router/dummy/VMCommSystem.java

    re61e950 rbacce17  
    3030     * Mapping from Hash to VMCommSystem for all routers hooked together
    3131     */
    32     private static Map _commSystemFacades = Collections.synchronizedMap(new HashMap(16));
     32    private static Map<Hash, VMCommSystem> _commSystemFacades = Collections.synchronizedMap(new HashMap<Hash, VMCommSystem>(16));
    3333   
    3434    public VMCommSystem(RouterContext context) {
  • router/java/src/net/i2p/router/message/CloveSet.java

    re61e950 rbacce17  
    2626   
    2727    public CloveSet() {
    28         _cloves = new ArrayList(4);
     28        _cloves = new ArrayList<GarlicClove>(4);
    2929        _msgId = -1;
    3030        _expiration = -1;
  • router/java/src/net/i2p/router/message/GarlicConfig.java

    re61e950 rbacce17  
    4242        _id = -1;
    4343        _expiration = -1;
    44         _cloveConfigs = new ArrayList(4);
     44        _cloveConfigs = new ArrayList<GarlicConfig>(4);
    4545        //_replyBlockMessageId = -1;
    4646        //_replyBlockExpiration = -1;
  • router/java/src/net/i2p/router/message/GarlicMessageBuilder.java

    re61e950 rbacce17  
    6666        Log log = ctx.logManager().getLog(GarlicMessageBuilder.class);
    6767        log.error("buildMessage 2 args, using router SKM", new Exception("who did it"));
    68         return buildMessage(ctx, config, new SessionKey(), new HashSet(), ctx.sessionKeyManager());
     68        return buildMessage(ctx, config, new SessionKey(), new HashSet<SessionTag>(), ctx.sessionKeyManager());
    6969    }
    7070
  • router/java/src/net/i2p/router/message/OutboundCache.java

    re61e950 rbacce17  
    1212import net.i2p.router.RouterContext;
    1313import net.i2p.router.TunnelInfo;
    14 import net.i2p.util.SimpleScheduler;
    1514import net.i2p.util.SimpleTimer;
    1615
     
    4443     * NOT concurrent.
    4544     */
    46     final Map<HashPair, TunnelInfo> tunnelCache = new HashMap(64);
     45    final Map<HashPair, TunnelInfo> tunnelCache = new HashMap<HashPair, TunnelInfo>(64);
    4746
    4847    /*
    4948     * NOT concurrent.
    5049     */
    51     final Map<HashPair, TunnelInfo> backloggedTunnelCache = new HashMap(64);
     50    final Map<HashPair, TunnelInfo> backloggedTunnelCache = new HashMap<HashPair, TunnelInfo>(64);
    5251
    5352    /**
     
    6968      * Concurrent.
    7069      */
    71     final Map<HashPair, LeaseSet> leaseSetCache = new ConcurrentHashMap(64);
     70    final Map<HashPair, LeaseSet> leaseSetCache = new ConcurrentHashMap<HashPair, LeaseSet>(64);
    7271
    7372    /**
     
    8584     * Concurrent.
    8685     */
    87     final ConcurrentHashMap<HashPair, Lease> leaseCache = new ConcurrentHashMap(64);
     86    final ConcurrentHashMap<HashPair, Lease> leaseCache = new ConcurrentHashMap<HashPair, Lease>(64);
    8887
    8988    /**
     
    9594     * Concurrent.
    9695     */
    97     final Map<HashPair, Long> lastReplyRequestCache = new ConcurrentHashMap(64);
     96    final Map<HashPair, Long> lastReplyRequestCache = new ConcurrentHashMap<HashPair, Long>(64);
    9897
    9998    private final RouterContext _context;
  • router/java/src/net/i2p/router/message/OutboundClientMessageOneShotJob.java

    re61e950 rbacce17  
    55import java.util.HashSet;
    66import java.util.List;
    7 import java.util.Properties;
    87import java.util.Set;
    98import java.util.concurrent.atomic.AtomicBoolean;
     
    323322
    324323        // get the possible leases
    325         List<Lease> leases = new ArrayList(_leaseSet.getLeaseCount());
     324        List<Lease> leases = new ArrayList<Lease>(_leaseSet.getLeaseCount());
    326325        for (int i = 0; i < _leaseSet.getLeaseCount(); i++) {
    327326            Lease lease = _leaseSet.getLease(i);
     
    455454        PublicKey key = _leaseSet.getEncryptionKey();
    456455        SessionKey sessKey = new SessionKey();
    457         Set<SessionTag> tags = new HashSet();
     456        Set<SessionTag> tags = new HashSet<SessionTag>();
    458457
    459458        LeaseSet replyLeaseSet;
  • router/java/src/net/i2p/router/networkdb/HandleDatabaseLookupMessageJob.java

    re61e950 rbacce17  
    1010
    1111import java.util.Collections;
    12 import java.util.HashSet;
    1312import java.util.Set;
    1413
  • router/java/src/net/i2p/router/networkdb/kademlia/ExpireLeasesJob.java

    re61e950 rbacce17  
    5959     */
    6060    private Set<Hash> selectKeysToExpire() {
    61         Set<Hash> toExpire = new HashSet(128);
     61        Set<Hash> toExpire = new HashSet<Hash>(128);
    6262        for (Map.Entry<Hash, DatabaseEntry> entry : _facade.getDataStore().getMapEntries()) {
    6363            DatabaseEntry obj = entry.getValue();
  • router/java/src/net/i2p/router/networkdb/kademlia/ExpireRoutersJob.java

    re61e950 rbacce17  
    99 */
    1010
    11 import java.util.Collections;
    1211import java.util.Set;
    1312
  • router/java/src/net/i2p/router/networkdb/kademlia/ExploreJob.java

    re61e950 rbacce17  
    118118            // We're just exploring, but this could give things away, and tie our exploratory tunnels to our router,
    119119            // so let's not put our hash in there.
    120             Set<Hash> dontInclude = new HashSet(dontIncludePeers);
     120            Set<Hash> dontInclude = new HashSet<Hash>(dontIncludePeers);
    121121            List<Hash> peers = _peerSelector.selectNearestExplicit(rkey, available, dontInclude, ks);
    122122            dontIncludePeers.addAll(peers);
  • router/java/src/net/i2p/router/networkdb/kademlia/ExploreKeySelectorJob.java

    re61e950 rbacce17  
    4343            return;
    4444        }
    45         Set toExplore = selectKeysToExplore();
     45        Set<Hash> toExplore = selectKeysToExplore();
    4646        _log.info("Filling the explorer pool with: " + toExplore);
    4747        if (toExplore != null)
     
    5555     *
    5656     */
    57     private Set selectKeysToExplore() {
    58         Set alreadyQueued = _facade.getExploreKeys();
     57    private Set<Hash> selectKeysToExplore() {
     58        Set<Hash> alreadyQueued = _facade.getExploreKeys();
    5959        if (alreadyQueued.size() > KBucketSet.NUM_BUCKETS) return null;
    60         Set toExplore = new HashSet(KBucketSet.NUM_BUCKETS - alreadyQueued.size());
     60        Set<Hash> toExplore = new HashSet<Hash>(KBucketSet.NUM_BUCKETS - alreadyQueued.size());
    6161        for (int i = 0; i < KBucketSet.NUM_BUCKETS; i++) {
    6262            KBucket bucket = _facade.getKBuckets().getBucket(i);
    6363            if (bucket.getKeyCount() < KBucketSet.BUCKET_SIZE) {
    6464                boolean already = false;
    65                 for (Iterator iter = alreadyQueued.iterator(); iter.hasNext(); ) {
    66                     Hash key = (Hash)iter.next();
     65                for (Iterator<Hash> iter = alreadyQueued.iterator(); iter.hasNext(); ) {
     66                    Hash key = iter.next();
    6767                    if (bucket.shouldContain(key)) {
    6868                        already = true;
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodOnlySearchJob.java

    re61e950 rbacce17  
    5656        _timeoutMs = Math.min(timeoutMs, SearchJob.PER_FLOODFILL_PEER_TIMEOUT);
    5757        _expiration = _timeoutMs + ctx.clock().now();
    58         _unheardFrom = new HashSet(CONCURRENT_SEARCHES);
     58        _unheardFrom = new HashSet<Hash>(CONCURRENT_SEARCHES);
    5959        _replySelector = new FloodOnlyLookupSelector(getContext(), this);
    6060        _onReply = new FloodOnlyLookupMatchJob(getContext(), this);
     
    7878            floodfillPeers = ((FloodfillPeerSelector)_facade.getPeerSelector()).selectFloodfillParticipants(rkey, MIN_FOR_NO_DSRM, ks);
    7979        } else {
    80             floodfillPeers = Collections.EMPTY_LIST;
     80            floodfillPeers = Collections.emptyList();
    8181        }
    8282
     
    9292            if (_log.shouldLog(Log.WARN))
    9393                _log.warn("Running netDb searches against the floodfill peers, but we don't know any");
    94             floodfillPeers = new ArrayList(_facade.getAllRouters());
     94            floodfillPeers = new ArrayList<Hash>(_facade.getAllRouters());
    9595            if (floodfillPeers.isEmpty()) {
    9696                if (_log.shouldLog(Log.ERROR))
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodSearchJob.java

    re61e950 rbacce17  
    4444        _facade = facade;
    4545        _key = key;
    46         _onFind = new CopyOnWriteArrayList();
     46        _onFind = new CopyOnWriteArrayList<Job>();
    4747        if (onFind != null)
    4848            _onFind.add(onFind);
    49         _onFailed = new CopyOnWriteArrayList();
     49        _onFailed = new CopyOnWriteArrayList<Job>();
    5050        if (onFailed != null)
    5151            _onFailed.add(onFailed);
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodThrottler.java

    re61e950 rbacce17  
    1818
    1919    FloodThrottler() {
    20         this.counter = new ObjectCounter();
     20        this.counter = new ObjectCounter<Hash>();
    2121        SimpleScheduler.getInstance().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
    2222    }
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillNetworkDatabaseFacade.java

    re61e950 rbacce17  
    88
    99import net.i2p.data.DatabaseEntry;
    10 import net.i2p.data.DataFormatException;
    1110import net.i2p.data.Hash;
    1211import net.i2p.data.RouterInfo;
     
    4847    public FloodfillNetworkDatabaseFacade(RouterContext context) {
    4948        super(context);
    50         _activeFloodQueries = new HashMap();
    51          _verifiesInProgress = new ConcurrentHashSet(8);
     49        _activeFloodQueries = new HashMap<Hash, FloodSearchJob>();
     50         _verifiesInProgress = new ConcurrentHashSet<Hash>(8);
    5251
    5352        _context.statManager().createRequiredRateStat("netDb.successTime", "Time for successful lookup (ms)", "NetworkDatabase", new long[] { 60*60*1000l, 24*60*60*1000l });
     
    141140   
    142141    @Override
    143     public void sendStore(Hash key, DatabaseEntry ds, Job onSuccess, Job onFailure, long sendTimeout, Set toIgnore) {
     142    public void sendStore(Hash key, DatabaseEntry ds, Job onSuccess, Job onFailure, long sendTimeout, Set<Hash> toIgnore) {
    144143        // if we are a part of the floodfill netDb, don't send out our own leaseSets as part
    145144        // of the flooding - instead, send them to a random floodfill peer so *they* can flood 'em out.
     
    269268
    270269    public List<RouterInfo> getKnownRouterData() {
    271         List<RouterInfo> rv = new ArrayList();
     270        List<RouterInfo> rv = new ArrayList<RouterInfo>();
    272271        DataStore ds = getDataStore();
    273272        if (ds != null) {
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillPeerSelector.java

    re61e950 rbacce17  
    8989        // TODO this is very slow
    9090        FloodfillSelectionCollector matches = new FloodfillSelectionCollector(key, peersToIgnore, maxNumRouters);
    91         if (kbuckets == null) return new ArrayList();
     91        if (kbuckets == null) return new ArrayList<Hash>();
    9292        kbuckets.getAll(matches);
    9393        List<Hash> rv = matches.get(maxNumRouters, preferConnected);
     
    127127      *****/
    128128        Set<Hash> set = _context.peerManager().getPeersByCapability(FloodfillNetworkDatabaseFacade.CAPABILITY_FLOODFILL);
    129         List<Hash> rv = new ArrayList(set.size());
     129        List<Hash> rv = new ArrayList<Hash>(set.size());
    130130        for (Hash h : set) {
    131131            if ((toIgnore != null && toIgnore.contains(h)) ||
     
    181181        } else if (!toIgnore.contains(_context.routerHash())) {
    182182            // copy the Set so we don't confuse StoreJob
    183             toIgnore = new HashSet(toIgnore);
     183            toIgnore = new HashSet<Hash>(toIgnore);
    184184            toIgnore.add(_context.routerHash());
    185185        }
     
    196196    private List<Hash> selectFloodfillParticipantsIncludingUs(Hash key, int howMany, Set<Hash> toIgnore, KBucketSet kbuckets) {
    197197        List<Hash> ffs = selectFloodfillParticipants(toIgnore, kbuckets);
    198         TreeSet<Hash> sorted = new TreeSet(new XORComparator(key));
     198        TreeSet<Hash> sorted = new TreeSet<Hash>(new XORComparator(key));
    199199        sorted.addAll(ffs);
    200200
    201         List<Hash> rv = new ArrayList(howMany);
    202         List<Hash> okff = new ArrayList(ffs.size());
    203         List<Hash> badff = new ArrayList(ffs.size());
     201        List<Hash> rv = new ArrayList<Hash>(howMany);
     202        List<Hash> okff = new ArrayList<Hash>(ffs.size());
     203        List<Hash> badff = new ArrayList<Hash>(ffs.size());
    204204        int found = 0;
    205205        long now = _context.clock().now();
     
    220220        int limit = Math.max(5, howMany);
    221221        limit = Math.min(limit, ffs.size());
    222         Set<Integer> maskedIPs = new HashSet(limit + 4);
     222        Set<Integer> maskedIPs = new HashSet<Integer>(limit + 4);
    223223        // split sorted list into 3 sorted lists
    224224        for (int i = 0; found < howMany && i < limit; i++) {
     
    304304      */
    305305    private Set<Integer> maskedIPSet(Hash peer, RouterInfo pinfo, int mask) {
    306         Set<Integer> rv = new HashSet(4);
     306        Set<Integer> rv = new HashSet<Integer>(4);
    307307        byte[] commIP = _context.commSystem().getIP(peer);
    308308        if (commIP != null)
     
    355355        public FloodfillSelectionCollector(Hash key, Set<Hash> toIgnore, int wanted) {
    356356            _key = key;
    357             _sorted = new TreeSet(new XORComparator(key));
    358             _floodfillMatches = new ArrayList(8);
     357            _sorted = new TreeSet<Hash>(new XORComparator(key));
     358            _floodfillMatches = new ArrayList<Hash>(8);
    359359            _toIgnore = toIgnore;
    360360            _wanted = wanted;
     
    411411         */
    412412        public List<Hash> get(int howMany, boolean preferConnected) {
    413             List<Hash> rv = new ArrayList(howMany);
    414             List<Hash> badff = new ArrayList(howMany);
    415             List<Hash> unconnectedff = new ArrayList(howMany);
     413            List<Hash> rv = new ArrayList<Hash>(howMany);
     414            List<Hash> badff = new ArrayList<Hash>(howMany);
     415            List<Hash> unconnectedff = new ArrayList<Hash>(howMany);
    416416            int found = 0;
    417417            long now = _context.clock().now();
     
    419419            // Let's say published in last 3h and no failed sends in last 30m
    420420            // (Forever banlisted ones are excluded in add() above)
    421             for (Iterator<Hash> iter = new RandomIterator(_floodfillMatches); (found < howMany) && iter.hasNext(); ) {
     421            for (Iterator<Hash> iter = new RandomIterator<Hash>(_floodfillMatches); (found < howMany) && iter.hasNext(); ) {
    422422                Hash entry = iter.next();
    423423                RouterInfo info = _context.netDb().lookupRouterInfoLocally(entry);
  • router/java/src/net/i2p/router/networkdb/kademlia/FloodfillVerifyStoreJob.java

    re61e950 rbacce17  
    5656        _sentTo = sentTo;
    5757        _facade = facade;
    58         _ignore = new HashSet(MAX_PEERS_TO_TRY);
     58        _ignore = new HashSet<Hash>(MAX_PEERS_TO_TRY);
    5959        if (sentTo != null) {
    6060            _ignore.add(_sentTo);
     
    278278        DatabaseEntry ds = _facade.lookupLocally(_key);
    279279        if (ds != null) {
    280             Set<Hash> toSkip = new HashSet(2);
     280            Set<Hash> toSkip = new HashSet<Hash>(2);
    281281            if (_sentTo != null)
    282282                toSkip.add(_sentTo);
  • router/java/src/net/i2p/router/networkdb/kademlia/HarvesterJob.java

    re61e950 rbacce17  
    5858    public void runJob() {
    5959        if (shouldHarvest()) {
    60             List peers = selectPeersToUpdate();
     60            List<Hash> peers = selectPeersToUpdate();
    6161            for (int i = 0; i < peers.size(); i++) {
    62                 Hash peer= (Hash)peers.get(i);
     62                Hash peer= peers.get(i);
    6363                harvest(peer);
    6464            }
     
    7676     *
    7777     */
    78     private List selectPeersToUpdate() {
    79         Map routersByAge = new TreeMap();
    80         Set peers = _facade.getAllRouters();
     78    private List<Hash> selectPeersToUpdate() {
     79        Map<Long, Hash> routersByAge = new TreeMap<Long, Hash>();
     80        Set<Hash> peers = _facade.getAllRouters();
    8181        long now = getContext().clock().now();
    82         for (Iterator iter = peers.iterator(); iter.hasNext(); ) {
    83             Hash peer = (Hash)iter.next();
     82        for (Iterator<Hash> iter = peers.iterator(); iter.hasNext(); ) {
     83            Hash peer = iter.next();
    8484            RouterInfo info = _facade.lookupRouterInfoLocally(peer);
    8585            if (info != null) {
     
    9696        // ignoring peers that are new, so lets grab the oldest MAX_PER_RUN
    9797        // entries
    98         List rv = new ArrayList();
    99         for (Iterator iter = routersByAge.values().iterator(); iter.hasNext(); ) {
    100             Hash peer = (Hash)iter.next();
     98        List<Hash> rv = new ArrayList<Hash>();
     99        for (Iterator<Hash> iter = routersByAge.values().iterator(); iter.hasNext(); ) {
     100            Hash peer = iter.next();
    101101            rv.add(peer);
    102102            if (rv.size() >= MAX_PER_RUN)
  • router/java/src/net/i2p/router/networkdb/kademlia/IterativeSearchJob.java

    re61e950 rbacce17  
    2626import net.i2p.router.util.RandomIterator;
    2727import net.i2p.util.Log;
    28 import net.i2p.util.VersionComparator;
    2928
    3029/**
     
    9594        _expiration = _timeoutMs + ctx.clock().now();
    9695        _rkey = ctx.routingKeyGenerator().getRoutingKey(key);
    97         _toTry = new TreeSet(new XORComparator(_rkey));
    98         _unheardFrom = new HashSet(CONCURRENT_SEARCHES);
    99         _failedPeers = new HashSet(TOTAL_SEARCH_LIMIT);
    100         _sentTime = new ConcurrentHashMap(TOTAL_SEARCH_LIMIT);
     96        _toTry = new TreeSet<Hash>(new XORComparator(_rkey));
     97        _unheardFrom = new HashSet<Hash>(CONCURRENT_SEARCHES);
     98        _failedPeers = new HashSet<Hash>(TOTAL_SEARCH_LIMIT);
     99        _sentTime = new ConcurrentHashMap<Hash, Long>(TOTAL_SEARCH_LIMIT);
    101100    }
    102101
     
    117116            floodfillPeers = ((FloodfillPeerSelector)_facade.getPeerSelector()).selectFloodfillParticipants(_rkey, TOTAL_SEARCH_LIMIT, ks);
    118117        } else {
    119             floodfillPeers = new ArrayList(TOTAL_SEARCH_LIMIT);
     118            floodfillPeers = new ArrayList<Hash>(TOTAL_SEARCH_LIMIT);
    120119        }
    121120
     
    138137            if (_log.shouldLog(Log.WARN))
    139138                _log.warn("Running netDb searches against the floodfill peers, but we don't know any");
    140             List<Hash> all = new ArrayList(_facade.getAllRouters());
     139            List<Hash> all = new ArrayList<Hash>(_facade.getAllRouters());
    141140            if (all.isEmpty()) {
    142141                if (_log.shouldLog(Log.ERROR))
     
    145144                return;
    146145            }
    147             Iterator<Hash> iter = new RandomIterator(all);
     146            Iterator<Hash> iter = new RandomIterator<Hash>(all);
    148147            // Limit non-FF to 3, because we don't sort the FFs ahead of the non-FFS,
    149148            // so once we get some FFs we want to be sure to query them
  • router/java/src/net/i2p/router/networkdb/kademlia/KBucketImpl.java

    re61e950 rbacce17  
    5050        _context = context;
    5151        _log = context.logManager().getLog(KBucketImpl.class);
    52         _entries = new ConcurrentHashSet(2); //all but the last 1 or 2 buckets will be empty
     52        _entries = new ConcurrentHashSet<Hash>(2); //all but the last 1 or 2 buckets will be empty
    5353        _lastShuffle = context.clock().now();
    5454        setLocal(local);
     
    220220     *  @deprecated makes a copy, remove toIgnore in KBS instead
    221221     */
    222     public Set<Hash> getEntries(Set toIgnoreHashes) {
    223         Set<Hash> entries = new HashSet(_entries);
     222    public Set<Hash> getEntries(Set<Hash> toIgnoreHashes) {
     223        Set<Hash> entries = new HashSet<Hash>(_entries);
    224224        entries.removeAll(toIgnoreHashes);
    225225        return entries;
  • router/java/src/net/i2p/router/networkdb/kademlia/KBucketSet.java

    re61e950 rbacce17  
    9595    public void clear() {
    9696        for (int i = 0; i < _buckets.length; i++) {
    97             _buckets[i].setEntries(Collections.EMPTY_SET);
     97            _buckets[i].setEntries(Collections.<Hash> emptySet());
    9898        }
    9999        _size.set(0);
     
    101101    }
    102102   
    103     public Set<Hash> getAll() { return getAll(Collections.EMPTY_SET); };
     103    public Set<Hash> getAll() { return getAll(Collections.<Hash> emptySet()); };
    104104
    105105    public Set<Hash> getAll(Set<Hash> toIgnore) {
    106         Set<Hash> all = new HashSet(1024);
     106        Set<Hash> all = new HashSet<Hash>(1024);
    107107        for (int i = 0; i < _buckets.length; i++) {
    108108            all.addAll(_buckets[i].getEntries());
  • router/java/src/net/i2p/router/networkdb/kademlia/KademliaNetworkDatabaseFacade.java

    re61e950 rbacce17  
    4747    private String _dbDir;
    4848    // set of Hash objects that we should search on (to fill up a bucket, not to get data)
    49     private final Set<Hash> _exploreKeys = new ConcurrentHashSet(64);
     49    private final Set<Hash> _exploreKeys = new ConcurrentHashSet<Hash>(64);
    5050    private boolean _initialized;
    5151    /** Clock independent time of when we started up */
     
    139139        _log = _context.logManager().getLog(getClass());
    140140        _peerSelector = createPeerSelector();
    141         _publishingLeaseSets = new HashMap(8);
    142         _activeRequests = new HashMap(8);
     141        _publishingLeaseSets = new HashMap<Hash, RepublishLeaseSetJob>(8);
     142        _activeRequests = new HashMap<Hash, SearchJob>(8);
    143143        _reseedChecker = new ReseedChecker(context);
    144144        context.statManager().createRateStat("netDb.lookupDeferred", "how many lookups are deferred?", "NetworkDatabase", new long[] { 60*60*1000 });
     
    182182    public Set<Hash> getExploreKeys() {
    183183        if (!_initialized)
    184             return Collections.EMPTY_SET;
     184            return Collections.emptySet();
    185185        return Collections.unmodifiableSet(_exploreKeys);
    186186    }
     
    324324     */
    325325    public Set<Hash> findNearestRouters(Hash key, int maxNumRouters, Set<Hash> peersToIgnore) {
    326         if (!_initialized) return Collections.EMPTY_SET;
    327         return new HashSet(_peerSelector.selectNearest(key, maxNumRouters, peersToIgnore, _kb));
     326        if (!_initialized) return Collections.emptySet();
     327        return new HashSet<Hash>(_peerSelector.selectNearest(key, maxNumRouters, peersToIgnore, _kb));
    328328    }
    329329   
     
    350350    /** get the hashes for all known routers */
    351351    public Set<Hash> getAllRouters() {
    352         if (!_initialized) return Collections.EMPTY_SET;
     352        if (!_initialized) return Collections.emptySet();
    353353        Set<Map.Entry<Hash, DatabaseEntry>> entries = _ds.getMapEntries();
    354         Set<Hash> rv = new HashSet(entries.size());
     354        Set<Hash> rv = new HashSet<Hash>(entries.size());
    355355        for (Map.Entry<Hash, DatabaseEntry> entry : entries) {
    356356            if (entry.getValue().getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
     
    989989    public Set<LeaseSet> getLeases() {
    990990        if (!_initialized) return null;
    991         Set leases = new HashSet();
     991        Set<LeaseSet> leases = new HashSet<LeaseSet>();
    992992        for (DatabaseEntry o : getDataStore().getEntries()) {
    993993            if (o.getType() == DatabaseEntry.KEY_TYPE_LEASESET)
    994                 leases.add(o);
     994                leases.add((LeaseSet)o);
    995995        }
    996996        return leases;
     
    10011001    public Set<RouterInfo> getRouters() {
    10021002        if (!_initialized) return null;
    1003         Set routers = new HashSet();
     1003        Set<RouterInfo> routers = new HashSet<RouterInfo>();
    10041004        for (DatabaseEntry o : getDataStore().getEntries()) {
    10051005            if (o.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO)
    1006                 routers.add(o);
     1006                routers.add((RouterInfo)o);
    10071007        }
    10081008        return routers;
     
    10351035
    10361036    /** unused (overridden in FNDF) */
    1037     public void sendStore(Hash key, DatabaseEntry ds, Job onSuccess, Job onFailure, long sendTimeout, Set toIgnore) {
     1037    public void sendStore(Hash key, DatabaseEntry ds, Job onSuccess, Job onFailure, long sendTimeout, Set<Hash> toIgnore) {
    10381038        if ( (ds == null) || (key == null) ) {
    10391039            if (onFailure != null)
  • router/java/src/net/i2p/router/networkdb/kademlia/LocalHash.java

    re61e950 rbacce17  
    4949        synchronized (this) {
    5050            if (_xorCache == null)
    51                 _xorCache = new HashMap(MAX_CACHED_XOR);
     51                _xorCache = new HashMap<Hash, byte[]>(MAX_CACHED_XOR);
    5252        }
    5353    }
     
    7171                int toRemove = _xorCache.size() + 1 - MAX_CACHED_XOR;
    7272                if (toRemove > 0) {
    73                     Set keys = new HashSet(toRemove);
     73                    Set<Hash> keys = new HashSet<Hash>(toRemove);
    7474                    // this removes essentially random keys - we dont maintain any sort
    7575                    // of LRU or age.  perhaps we should?
    7676                    int removed = 0;
    77                     for (Iterator iter = _xorCache.keySet().iterator(); iter.hasNext() && removed < toRemove; removed++)
     77                    for (Iterator<Hash> iter = _xorCache.keySet().iterator(); iter.hasNext() && removed < toRemove; removed++)
    7878                        keys.add(iter.next());
    79                     for (Iterator iter = keys.iterator(); iter.hasNext(); )
     79                    for (Iterator<Hash> iter = keys.iterator(); iter.hasNext(); )
    8080                        _xorCache.remove(iter.next());
    8181                }
  • router/java/src/net/i2p/router/networkdb/kademlia/LookupThrottler.java

    re61e950 rbacce17  
    2525
    2626    LookupThrottler() {
    27         this.counter = new ObjectCounter();
     27        this.counter = new ObjectCounter<ReplyTunnel>();
    2828        SimpleScheduler.getInstance().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
    2929    }
  • router/java/src/net/i2p/router/networkdb/kademlia/MessageWrapper.java

    re61e950 rbacce17  
    6060            return null;
    6161        SessionKey sentKey = new SessionKey();
    62         Set<SessionTag> sentTags = new HashSet();
     62        Set<SessionTag> sentTags = new HashSet<SessionTag>();
    6363        GarlicMessage msg = GarlicMessageBuilder.buildMessage(ctx, payload, sentKey, sentTags,
    6464                                                              NETDB_TAGS_TO_DELIVER, NETDB_LOW_THRESHOLD, skm);
     
    193193        SessionKey key = ctx.keyGenerator().generateSessionKey();
    194194        SessionTag tag = new SessionTag(true);
    195         Set<SessionTag> tags = new RemovableSingletonSet(tag);
     195        Set<SessionTag> tags = new RemovableSingletonSet<SessionTag>(tag);
    196196        skm.tagsReceived(key, tags, 2*60*1000);
    197197        return new OneTimeSession(key, tag);
  • router/java/src/net/i2p/router/networkdb/kademlia/NegativeLookupCache.java

    re61e950 rbacce17  
    1717
    1818    public NegativeLookupCache() {
    19         this.counter = new ObjectCounter();
     19        this.counter = new ObjectCounter<Hash>();
    2020        SimpleScheduler.getInstance().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
    2121    }
  • router/java/src/net/i2p/router/networkdb/kademlia/PeerSelector.java

    re61e950 rbacce17  
    9797    List<Hash> selectNearestExplicitThin(Hash key, int maxNumRouters, Set<Hash> peersToIgnore, KBucketSet kbuckets) {
    9898        if (peersToIgnore == null)
    99             peersToIgnore = new HashSet(1);
     99            peersToIgnore = new HashSet<Hash>(1);
    100100        peersToIgnore.add(_context.routerHash());
    101101        MatchSelectionCollector matches = new MatchSelectionCollector(key, peersToIgnore);
    102102        kbuckets.getAll(matches);
    103         List rv = matches.get(maxNumRouters);
     103        List<Hash> rv = matches.get(maxNumRouters);
    104104        if (_log.shouldLog(Log.DEBUG))
    105105            _log.debug("Searching for " + maxNumRouters + " peers close to " + key + ": "
     
    117117        public MatchSelectionCollector(Hash key, Set<Hash> toIgnore) {
    118118            _key = key;
    119             _sorted = new TreeMap();
     119            _sorted = new TreeMap<BigInteger, Hash>();
    120120            _toIgnore = toIgnore;
    121121            _matches = 0;
     
    139139        /** get the first $howMany entries matching */
    140140        public List<Hash> get(int howMany) {
    141             List<Hash> rv = new ArrayList(howMany);
     141            List<Hash> rv = new ArrayList<Hash>(howMany);
    142142            for (int i = 0; i < howMany; i++) {
    143143                if (_sorted.isEmpty())
  • router/java/src/net/i2p/router/networkdb/kademlia/PersistentDataStore.java

    re61e950 rbacce17  
    197197
    198198        public Writer() {
    199             _keys = new ConcurrentHashMap(64);
     199            _keys = new ConcurrentHashMap<Hash, DatabaseEntry>(64);
    200200            _waitLock = new Object();
    201201        }
  • router/java/src/net/i2p/router/networkdb/kademlia/SearchJob.java

    re61e950 rbacce17  
    5050    private Job _pendingRequeueJob;
    5151    private final PeerSelector _peerSelector;
    52     private final List _deferredSearches;
     52    private final List<Search> _deferredSearches;
    5353    private boolean _deferredCleared;
    5454    private long _startedOn;
     
    100100        _timeoutMs = timeoutMs;
    101101        _keepStats = keepStats;
    102         _deferredSearches = new ArrayList(0);
     102        _deferredSearches = new ArrayList<Search>(0);
    103103        _peerSelector = facade.getPeerSelector();
    104104        _startedOn = -1;
     
    261261        }
    262262        int sent = 0;
    263         Set attempted = _state.getAttempted();
     263        Set<Hash> attempted = _state.getAttempted();
    264264        while (sent <= 0) {
    265265            //boolean onlyFloodfill = onlyQueryFloodfillPeers(getContext());
     
    272272                return;
    273273            }
    274             List closestHashes = getClosestRouters(_state.getTarget(), toCheck, attempted);
     274            List<Hash> closestHashes = getClosestRouters(_state.getTarget(), toCheck, attempted);
    275275            if ( (closestHashes == null) || (closestHashes.isEmpty()) ) {
    276276                if (_state.getPending().isEmpty()) {
     
    291291            } else {
    292292                attempted.addAll(closestHashes);
    293                 for (Iterator iter = closestHashes.iterator(); iter.hasNext(); ) {
    294                     Hash peer = (Hash)iter.next();
     293                for (Iterator<Hash> iter = closestHashes.iterator(); iter.hasNext(); ) {
     294                    Hash peer = iter.next();
    295295                    DatabaseEntry ds = _facade.getDataStore().get(peer);
    296296                    if (ds == null) {
     
    366366     * @return ordered list of Hash objects
    367367     */
    368     private List getClosestRouters(Hash key, int numClosest, Set alreadyChecked) {
     368    private List<Hash> getClosestRouters(Hash key, int numClosest, Set<Hash> alreadyChecked) {
    369369        Hash rkey = getContext().routingKeyGenerator().getRoutingKey(key);
    370370        if (_log.shouldLog(Log.DEBUG))
     
    628628            }
    629629        } else {
    630             Set sendTo = _state.getRepliedPeers(); // _state.getFailed();
     630            Set<Hash> sendTo = _state.getRepliedPeers(); // _state.getFailed();
    631631            sendTo.addAll(_state.getPending());
    632632            int numSent = 0;
    633             for (Iterator iter = sendTo.iterator(); iter.hasNext(); ) {
    634                 Hash peer = (Hash)iter.next();
     633            for (Iterator<Hash> iter = sendTo.iterator(); iter.hasNext(); ) {
     634                Hash peer = iter.next();
    635635                RouterInfo peerInfo = _facade.lookupRouterInfoLocally(peer);
    636636                if (peerInfo == null) continue;
     
    727727   
    728728    private void handleDeferred(boolean success) {
    729         List deferred = null;
     729        List<Search> deferred = null;
    730730        synchronized (_deferredSearches) {
    731731            if (!_deferredSearches.isEmpty()) {
    732                 deferred = new ArrayList(_deferredSearches);
     732                deferred = new ArrayList<Search>(_deferredSearches);
    733733                _deferredSearches.clear();
    734734            }
     
    738738            long now = getContext().clock().now();
    739739            for (int i = 0; i < deferred.size(); i++) {
    740                 Search cur = (Search)deferred.get(i);
     740                Search cur = deferred.get(i);
    741741                if (cur.getExpiration() < now)
    742742                    getContext().jobQueue().addJob(cur.getOnFail());
  • router/java/src/net/i2p/router/networkdb/kademlia/SearchState.java

    re61e950 rbacce17  
    3232        _context = context;
    3333        _searchKey = key;
    34         _pendingPeers = new HashSet(16);
    35         _attemptedPeers = new HashSet(16);
    36         _failedPeers = new HashSet(16);
    37         _successfulPeers = new HashSet(16);
    38         _pendingPeerTimes = new HashMap(16);
    39         _repliedPeers = new HashSet(16);
     34        _pendingPeers = new HashSet<Hash>(16);
     35        _attemptedPeers = new HashSet<Hash>(16);
     36        _failedPeers = new HashSet<Hash>(16);
     37        _successfulPeers = new HashSet<Hash>(16);
     38        _pendingPeerTimes = new HashMap<Hash, Long>(16);
     39        _repliedPeers = new HashSet<Hash>(16);
    4040        _completed = -1;
    4141        _started = _context.clock().now();
     
    4545    public Set<Hash> getPending() {
    4646        synchronized (_pendingPeers) {
    47             return (Set)_pendingPeers.clone();
     47            return (Set<Hash>)_pendingPeers.clone();
    4848        }
    4949    }
    5050    public Set<Hash> getAttempted() {
    5151        synchronized (_attemptedPeers) {
    52             return (Set)_attemptedPeers.clone();
     52            return (Set<Hash>)_attemptedPeers.clone();
    5353        }
    5454    }
     
    6161    private Set<Hash> locked_getClosest(Set<Hash> peers, int max, Hash target) {
    6262        if (_attemptedPeers.size() <= max)
    63             return new HashSet(_attemptedPeers);
    64         TreeSet closest = new TreeSet(new XORComparator(target));
     63            return new HashSet<Hash>(_attemptedPeers);
     64        TreeSet<Hash> closest = new TreeSet<Hash>(new XORComparator(target));
    6565        closest.addAll(_attemptedPeers);
    66         Set<Hash> rv = new HashSet(max);
     66        Set<Hash> rv = new HashSet<Hash>(max);
    6767        int i = 0;
    6868        for (Iterator<Hash> iter = closest.iterator(); iter.hasNext() && i < max; i++) {
     
    7979    public Set<Hash> getSuccessful() {
    8080        synchronized (_successfulPeers) {
    81             return (Set)_successfulPeers.clone();
     81            return (Set<Hash>)_successfulPeers.clone();
    8282        }
    8383    }
    8484    public Set<Hash> getFailed() {
    8585        synchronized (_failedPeers) {
    86             return (Set)_failedPeers.clone();
     86            return (Set<Hash>)_failedPeers.clone();
    8787        }
    8888    }
     
    156156    }
    157157   
    158     public Set getRepliedPeers() { synchronized (_repliedPeers) { return (Set)_repliedPeers.clone(); } }
     158    public Set<Hash> getRepliedPeers() { synchronized (_repliedPeers) { return (Set<Hash>)_repliedPeers.clone(); } }
    159159   
    160160    public void replyTimeout(Hash peer) {
  • router/java/src/net/i2p/router/networkdb/kademlia/StartExplorersJob.java

    re61e950 rbacce17  
    134134        if (_log.shouldLog(Log.DEBUG))
    135135            _log.debug("Keys waiting for exploration: " + queued.size());
    136         Set<Hash> rv = new HashSet(num);
     136        Set<Hash> rv = new HashSet<Hash>(num);
    137137        for (Hash key : queued) {
    138138            if (rv.size() >= num) break;
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreJob.java

    re61e950 rbacce17  
    235235        Hash rkey = getContext().routingKeyGenerator().getRoutingKey(key);
    236236        KBucketSet ks = _facade.getKBuckets();
    237         if (ks == null) return new ArrayList();
     237        if (ks == null) return new ArrayList<Hash>();
    238238        return ((FloodfillPeerSelector)_peerSelector).selectFloodfillParticipants(rkey, numClosest, alreadyChecked, ks);
    239239    }
  • router/java/src/net/i2p/router/networkdb/kademlia/StoreState.java

    re61e950 rbacce17  
    1313import net.i2p.data.Hash;
    1414import net.i2p.router.RouterContext;
     15import net.i2p.router.networkdb.kademlia.MessageWrapper.WrappedMessage;
    1516
    1617/**
     
    3940        _key = key;
    4041        _data = data;
    41         _pendingPeers = new HashSet(4);
    42         _pendingPeerTimes = new HashMap(4);
    43         _pendingMessages = new ConcurrentHashMap(4);
    44         _attemptedPeers = new HashSet(8);
     42        _pendingPeers = new HashSet<Hash>(4);
     43        _pendingPeerTimes = new HashMap<Hash, Long>(4);
     44        _pendingMessages = new ConcurrentHashMap<Hash, WrappedMessage>(4);
     45        _attemptedPeers = new HashSet<Hash>(8);
    4546        if (toSkip != null) {
    4647            _attemptedPeers.addAll(toSkip);
    4748            _completeCount = toSkip.size();
    4849        }
    49         _failedPeers = new HashSet(8);
    50         _successfulPeers = new HashSet(4);
     50        _failedPeers = new HashSet<Hash>(8);
     51        _successfulPeers = new HashSet<Hash>(4);
    5152        //_successfulExploratoryPeers = new HashSet(16);
    5253        _completed = -1;
  • router/java/src/net/i2p/router/networkdb/kademlia/TransientDataStore.java

    re61e950 rbacce17  
    3434        _context = ctx;
    3535        _log = ctx.logManager().getLog(getClass());
    36         _data = new ConcurrentHashMap(1024);
     36        _data = new ConcurrentHashMap<Hash, DatabaseEntry>(1024);
    3737        if (_log.shouldLog(Log.INFO))
    3838            _log.info("Data Store initialized");
  • router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java

    re61e950 rbacce17  
    252252        */
    253253        private int reseed(boolean echoStatus) {
    254             List<String> URLList = new ArrayList();
     254            List<String> URLList = new ArrayList<String>();
    255255            String URLs = _context.getProperty(PROP_RESEED_URL);
    256256            boolean defaulted = URLs == null;
     
    268268            if (defaulted && !SSLDisable) {
    269269                // put the non-SSL at the end of the SSL
    270                 List<String> URLList2 = new ArrayList();
     270                List<String> URLList2 = new ArrayList<String>();
    271271                tok = new StringTokenizer(DEFAULT_SEED_URL, " ,");
    272272                while (tok.hasMoreTokens())
     
    335335                // This isn't really URLs, but Base64 hashes
    336336                // but they may include % encoding
    337                 Set<String> urls = new HashSet(1024);
     337                Set<String> urls = new HashSet<String>(1024);
    338338                Hash ourHash = _context.routerHash();
    339339                String ourB64 = ourHash != null ? ourHash.toBase64() : null;
     
    371371                }
    372372
    373                 List<String> urlList = new ArrayList(urls);
     373                List<String> urlList = new ArrayList<String>(urls);
    374374                Collections.shuffle(urlList, _context.random());
    375375                int fetched = 0;
  • router/java/src/net/i2p/router/peermanager/PeerManager.java

    re61e950 rbacce17  
    7474        _organizer = context.profileOrganizer();
    7575        _organizer.setUs(context.routerHash());
    76         _capabilitiesByPeer = new ConcurrentHashMap(256);
    77         _peersByCapability = new HashMap(TRACKED_CAPS.length());
     76        _capabilitiesByPeer = new ConcurrentHashMap<Hash, String>(256);
     77        _peersByCapability = new HashMap<Character, Set<Hash>>(TRACKED_CAPS.length());
    7878        for (int i = 0; i < TRACKED_CAPS.length(); i++)
    79             _peersByCapability.put(Character.valueOf(Character.toLowerCase(TRACKED_CAPS.charAt(i))), new ConcurrentHashSet());
     79            _peersByCapability.put(Character.valueOf(Character.toLowerCase(TRACKED_CAPS.charAt(i))), new ConcurrentHashSet<Hash>());
    8080        loadProfilesInBackground();
    8181        ////_context.jobQueue().addJob(new EvaluateProfilesJob(_context));
     
    120120        _organizer.clearProfiles();
    121121        _capabilitiesByPeer.clear();
    122         for (Set p : _peersByCapability.values())
     122        for (Set<Hash> p : _peersByCapability.values())
    123123            p.clear();
    124124    }
     
    178178     */
    179179    List<Hash> selectPeers(PeerSelectionCriteria criteria) {
    180         Set<Hash> peers = new HashSet(criteria.getMinimumRequired());
     180        Set<Hash> peers = new HashSet<Hash>(criteria.getMinimumRequired());
    181181        // not a singleton, SANFP adds to it
    182         Set<Hash> exclude = new HashSet(1);
     182        Set<Hash> exclude = new HashSet<Hash>(1);
    183183        exclude.add(_context.routerHash());
    184184        switch (criteria.getPurpose()) {
     
    222222        if (_log.shouldLog(Log.INFO))
    223223            _log.info("Peers selected: " + peers);
    224         return new ArrayList(peers);
     224        return new ArrayList<Hash>(peers);
    225225    }
    226226   
     
    301301            if (peers != null)
    302302                return Collections.unmodifiableSet(peers);
    303             return Collections.EMPTY_SET;
     303            return Collections.emptySet();
    304304    }
    305305}
  • router/java/src/net/i2p/router/peermanager/PeerManagerFacadeImpl.java

    re61e950 rbacce17  
    9090     */
    9191    public Set<Hash> getPeersByCapability(char capability) {
    92         if (_manager == null) return Collections.EMPTY_SET;
     92        if (_manager == null) return Collections.emptySet();
    9393        return _manager.getPeersByCapability(capability);
    9494    }
  • router/java/src/net/i2p/router/peermanager/PeerProfile.java

    re61e950 rbacce17  
    7474     *  Yes this is an arbitrary cutoff.
    7575     */
    76     private static final Set<String> _bigCountries = new HashSet();
     76    private static final Set<String> _bigCountries = new HashSet<String>();
    7777
    7878    static {
  • router/java/src/net/i2p/router/peermanager/PeerTestJob.java

    re61e950 rbacce17  
    7070    public void runJob() {
    7171        if (!_keepTesting) return;
    72         Set peers = selectPeersToTest();
     72        Set<RouterInfo> peers = selectPeersToTest();
    7373        if (_log.shouldLog(Log.DEBUG))
    7474            _log.debug("Testing " + peers.size() + " peers");
    7575       
    76         for (Iterator iter = peers.iterator(); iter.hasNext(); ) {
    77             RouterInfo peer = (RouterInfo)iter.next();
     76        for (Iterator<RouterInfo> iter = peers.iterator(); iter.hasNext(); ) {
     77            RouterInfo peer = iter.next();
    7878            if (_log.shouldLog(Log.DEBUG))
    7979                _log.debug("Testing peer " + peer.getIdentity().getHash().toBase64());
     
    8888     * @return set of RouterInfo structures
    8989     */
    90     private Set selectPeersToTest() {
     90    private Set<RouterInfo> selectPeersToTest() {
    9191        PeerSelectionCriteria criteria = new PeerSelectionCriteria();
    9292        criteria.setMinimumRequired(getTestConcurrency());
    9393        criteria.setMaximumRequired(getTestConcurrency());
    9494        criteria.setPurpose(PeerSelectionCriteria.PURPOSE_TEST);
    95         List peerHashes = _manager.selectPeers(criteria);
     95        List<Hash> peerHashes = _manager.selectPeers(criteria);
    9696       
    9797        if (_log.shouldLog(Log.DEBUG))
    9898            _log.debug("Peer selection found " + peerHashes.size() + " peers");
    9999       
    100         Set peers = new HashSet(peerHashes.size());
    101         for (Iterator iter = peerHashes.iterator(); iter.hasNext(); ) {
    102             Hash peer = (Hash)iter.next();
     100        Set<RouterInfo> peers = new HashSet<RouterInfo>(peerHashes.size());
     101        for (Iterator<Hash> iter = peerHashes.iterator(); iter.hasNext(); ) {
     102            Hash peer = iter.next();
    103103            RouterInfo peerInfo = getContext().netDb().lookupRouterInfoLocally(peer);
    104104            if (peerInfo != null) {
  • router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java

    re61e950 rbacce17  
    33import java.io.IOException;
    44import java.io.OutputStream;
    5 import java.net.InetAddress;
    6 import java.net.UnknownHostException;
    75import java.text.DecimalFormat;
    86import java.text.DecimalFormatSymbols;
    97import java.util.ArrayList;
    108import java.util.Collection;
    11 import java.util.Collections;
    129import java.util.HashMap;
    1310import java.util.HashSet;
     
    9895        _log = context.logManager().getLog(ProfileOrganizer.class);
    9996        _comp = new InverseCapacityComparator();
    100         _fastPeers = new HashMap(32);
    101         _highCapacityPeers = new HashMap(64);
    102         _wellIntegratedPeers = new HashMap(128);
    103         _notFailingPeers = new HashMap(256);
    104         _notFailingPeersList = new ArrayList(256);
    105         _failingPeers = new HashMap(16);
    106         _strictCapacityOrder = new TreeSet(_comp);
     97        _fastPeers = new HashMap<Hash, PeerProfile>(32);
     98        _highCapacityPeers = new HashMap<Hash, PeerProfile>(64);
     99        _wellIntegratedPeers = new HashMap<Hash, PeerProfile>(128);
     100        _notFailingPeers = new HashMap<Hash, PeerProfile>(256);
     101        _notFailingPeersList = new ArrayList<Hash>(256);
     102        _failingPeers = new HashMap<Hash, PeerProfile>(16);
     103        _strictCapacityOrder = new TreeSet<PeerProfile>(_comp);
    107104        _persistenceHelper = new ProfilePersistenceHelper(_context);
    108105       
     
    220217    }
    221218   
    222     private int count(Map m) {
     219    private int count(Map<? extends Object, ? extends Object> m) {
    223220        getReadLock();
    224221        try {
     
    568565    private void selectActiveNotFailingPeers2(int howMany, Set<Hash> exclude, Set<Hash> matches, int mask) {
    569566        if (matches.size() < howMany) {
    570             Map<Hash, PeerProfile> activePeers = new HashMap();
     567            Map<Hash, PeerProfile> activePeers = new HashMap<Hash, PeerProfile>();
    571568            getReadLock();
    572569            try {
     
    605602            int orig = matches.size();
    606603            int needed = howMany - orig;
    607             List selected = new ArrayList(needed);
     604            List<Hash> selected = new ArrayList<Hash>(needed);
    608605            getReadLock();
    609606            try {
    610607                // use RandomIterator to avoid shuffling the whole thing
    611                 for (Iterator<Hash> iter = new RandomIterator(_notFailingPeersList); (selected.size() < needed) && iter.hasNext(); ) {
     608                for (Iterator<Hash> iter = new RandomIterator<Hash>(_notFailingPeersList); (selected.size() < needed) && iter.hasNext(); ) {
    612609                    Hash cur = iter.next();
    613610                    if (matches.contains(cur) ||
     
    667664        try {
    668665            count = _notFailingPeers.size();
    669             n = new ArrayList(_notFailingPeers.keySet());
     666            n = new ArrayList<Hash>(_notFailingPeers.keySet());
    670667        } finally { releaseReadLock(); }
    671         List<Hash> l = new ArrayList(count / 4);
     668        List<Hash> l = new ArrayList<Hash>(count / 4);
    672669        for (Iterator<Hash> iter = n.iterator(); iter.hasNext(); ) {
    673670            Hash peer = iter.next();
     
    720717            long cutoff = _context.clock().now() - (20*1000);
    721718            int count = _notFailingPeers.size();
    722             List<Hash> l = new ArrayList(count / 128);
     719            List<Hash> l = new ArrayList<Hash>(count / 128);
    723720            for (Iterator<PeerProfile> iter = _notFailingPeers.values().iterator(); iter.hasNext(); ) {
    724721                PeerProfile prof = iter.next();
     
    737734        getReadLock();
    738735        try {
    739             Set<Hash> allPeers = new HashSet(_failingPeers.size() + _notFailingPeers.size() + _highCapacityPeers.size() + _fastPeers.size());
     736            Set<Hash> allPeers = new HashSet<Hash>(_failingPeers.size() + _notFailingPeers.size() + _highCapacityPeers.size() + _fastPeers.size());
    740737            allPeers.addAll(_failingPeers.keySet());
    741738            allPeers.addAll(_notFailingPeers.keySet());
     
    807804            //allPeers.addAll(_fastPeers.values());
    808805
    809             Set<PeerProfile> reordered = new TreeSet(_comp);
     806            Set<PeerProfile> reordered = new TreeSet<PeerProfile>(_comp);
    810807            long sortStart = System.currentTimeMillis();
    811808            for (Iterator<PeerProfile> iter = _strictCapacityOrder.iterator(); iter.hasNext(); ) {
     
    933930                _log.info("Need to explicitly demote " + numToDemote + " peers from the fast group");
    934931            // sort by speed, slowest-first
    935             Set<PeerProfile> sorted = new TreeSet(new SpeedComparator());
     932            Set<PeerProfile> sorted = new TreeSet<PeerProfile>(new SpeedComparator());
    936933            sorted.addAll(_fastPeers.values());
    937934            Iterator<PeerProfile> iter = sorted.iterator();
     
    10251022        double totalCapacity = 0;
    10261023        double totalIntegration = 0;
    1027         Set<PeerProfile> reordered = new TreeSet(_comp);
     1024        Set<PeerProfile> reordered = new TreeSet<PeerProfile>(_comp);
    10281025        for (Iterator<PeerProfile> iter = allPeers.iterator(); iter.hasNext(); ) {
    10291026            PeerProfile profile = iter.next();
     
    12181215     */
    12191216    private void locked_selectPeers(Map<Hash, PeerProfile> peers, int howMany, Set<Hash> toExclude, Set<Hash> matches, int mask) {
    1220         List<Hash> all = new ArrayList(peers.keySet());
    1221         Set<Integer> IPSet = new HashSet(8);
     1217        List<Hash> all = new ArrayList<Hash>(peers.keySet());
     1218        Set<Integer> IPSet = new HashSet<Integer>(8);
    12221219        // use RandomIterator to avoid shuffling the whole thing
    1223         for (Iterator<Hash> iter = new RandomIterator(all); (matches.size() < howMany) && iter.hasNext(); ) {
     1220        for (Iterator<Hash> iter = new RandomIterator<Hash>(all); (matches.size() < howMany) && iter.hasNext(); ) {
    12241221            Hash peer = iter.next();
    12251222            if (toExclude != null && toExclude.contains(peer))
     
    12631260      */
    12641261    private Set<Integer> maskedIPSet(Hash peer, int mask) {
    1265         Set<Integer> rv = new HashSet(4);
     1262        Set<Integer> rv = new HashSet<Integer>(4);
    12661263        byte[] commIP = _context.commSystem().getIP(peer);
    12671264        if (commIP != null)
     
    13001297
    13011298    /** does a contain any of the elements in b? */
    1302     private static boolean containsAny(Set a, Set b) {
     1299    private static boolean containsAny(Set<? extends Object> a, Set<? extends Object> b) {
    13031300        for (Object o : b) {
    13041301            if (a.contains(o))
     
    13211318     */
    13221319    private void locked_selectPeers(Map<Hash, PeerProfile> peers, int howMany, Set<Hash> toExclude, Set<Hash> matches, Hash randomKey, int subTierMode) {
    1323         List<Hash> all = new ArrayList(peers.keySet());
     1320        List<Hash> all = new ArrayList<Hash>(peers.keySet());
    13241321        // use RandomIterator to avoid shuffling the whole thing
    1325         for (Iterator<Hash> iter = new RandomIterator(all); (matches.size() < howMany) && iter.hasNext(); ) {
     1322        for (Iterator<Hash> iter = new RandomIterator<Hash>(all); (matches.size() < howMany) && iter.hasNext(); ) {
    13261323            Hash peer = iter.next();
    13271324            if (toExclude != null && toExclude.contains(peer))
  • router/java/src/net/i2p/router/peermanager/ProfilePersistenceHelper.java

    re61e950 rbacce17  
    179179        long start = _context.clock().now();
    180180        List<File> files = selectFiles();
    181         Set<PeerProfile> profiles = new HashSet(files.size());
     181        Set<PeerProfile> profiles = new HashSet<PeerProfile>(files.size());
    182182        for (File f :  files) {
    183183            PeerProfile profile = readProfile(f);
     
    203203        if (files != null && files.length > 0)
    204204            migrate(files);
    205         List rv = new ArrayList(1024);
     205        List<File> rv = new ArrayList<File>(1024);
    206206        for (int j = 0; j < B64.length(); j++) {
    207207            File subdir = new File(_profileDir, DIR_PREFIX + B64.charAt(j));
  • router/java/src/net/i2p/router/startup/ClientAppConfig.java

    re61e950 rbacce17  
    152152            DataHelper.loadProps(clientApps, cfgFile);
    153153        } catch (IOException ioe) {
    154             return Collections.EMPTY_LIST;
     154            return Collections.emptyList();
    155155        }
    156156        return getClientApps(clientApps);
     
    163163     */
    164164    private static List<ClientAppConfig> getClientApps(Properties clientApps) {
    165         List<ClientAppConfig> rv = new ArrayList(8);
     165        List<ClientAppConfig> rv = new ArrayList<ClientAppConfig>(8);
    166166        int i = 0;
    167167        while (true) {
  • router/java/src/net/i2p/router/startup/CreateRouterInfoJob.java

    re61e950 rbacce17  
    1111import java.io.BufferedOutputStream;
    1212import java.io.File;
    13 import java.io.FileOutputStream;
    1413import java.io.IOException;
    1514import java.io.OutputStream;
  • router/java/src/net/i2p/router/startup/LoadClientAppsJob.java

    re61e950 rbacce17  
    3737            _loaded = true;
    3838        }
    39         List apps = ClientAppConfig.getClientApps(getContext());
     39        List<ClientAppConfig> apps = ClientAppConfig.getClientApps(getContext());
    4040        if (apps.isEmpty()) {
    4141            _log.error("Warning - No client apps or router console configured - we are just a router");
     
    107107     */
    108108    public static String[] parseArgs(String args) {
    109         List<String> argList = new ArrayList(4);
     109        List<String> argList = new ArrayList<String>(4);
    110110        if (args != null) {
    111111            char data[] = args.toCharArray();
  • router/java/src/net/i2p/router/startup/LoadRouterInfoJob.java

    re61e950 rbacce17  
    1616import java.util.concurrent.atomic.AtomicBoolean;
    1717
    18 import net.i2p.crypto.KeyGenerator;
    1918import net.i2p.data.DataFormatException;
    2019import net.i2p.data.PrivateKey;
  • router/java/src/net/i2p/router/startup/RouterAppManager.java

    re61e950 rbacce17  
    3636        _context = ctx;
    3737        _log = ctx.logManager().getLog(RouterAppManager.class);
    38         _clients = new ConcurrentHashMap(16);
    39         _registered = new ConcurrentHashMap(8);
     38        _clients = new ConcurrentHashMap<ClientApp, String[]>(16);
     39        _registered = new ConcurrentHashMap<String, ClientApp>(8);
    4040        ctx.addShutdownTask(new Shutdown());
    4141    }
     
    176176     */
    177177    public synchronized void shutdown() {
    178         Set<ClientApp> apps = new HashSet(_clients.keySet());
     178        Set<ClientApp> apps = new HashSet<ClientApp>(_clients.keySet());
    179179        for (ClientApp app : apps) {
    180180            ClientAppState state = app.getState();
     
    215215     */
    216216    private void toString1(StringBuilder buf) {
    217         List<String> list = new ArrayList(_clients.size());
     217        List<String> list = new ArrayList<String>(_clients.size());
    218218        for (Map.Entry<ClientApp, String[]> entry : _clients.entrySet()) {
    219219            ClientApp key = entry.getKey();
     
    232232     */
    233233    private void toString2(StringBuilder buf) {
    234         List<String> list = new ArrayList(_registered.size());
     234        List<String> list = new ArrayList<String>(_registered.size());
    235235        for (Map.Entry<String, ClientApp> entry : _registered.entrySet()) {
    236236            String key = entry.getKey();
  • router/java/src/net/i2p/router/tasks/RouterWatchdog.java

    re61e950 rbacce17  
    11package net.i2p.router.tasks;
    2 
    3 import java.io.File;
    42
    53import net.i2p.data.DataHelper;
     
    119import net.i2p.stat.Rate;
    1210import net.i2p.stat.RateStat;
    13 import net.i2p.util.ShellCommand;
    1411import net.i2p.util.Log;
    1512import net.i2p.util.SystemVersion;
  • router/java/src/net/i2p/router/time/NtpClient.java

    re61e950 rbacce17  
    6666        if (serverNames == null)
    6767            throw new IllegalArgumentException("No NTP servers specified");
    68         ArrayList names = new ArrayList(serverNames.length);
     68        ArrayList<String> names = new ArrayList<String>(serverNames.length);
    6969        for (int i = 0; i < serverNames.length; i++)
    7070            names.add(serverNames[i]);
     
    8888        if (serverNames == null)
    8989            throw new IllegalArgumentException("No NTP servers specified");
    90         ArrayList names = new ArrayList(serverNames.length);
     90        ArrayList<String> names = new ArrayList<String>(serverNames.length);
    9191        for (int i = 0; i < serverNames.length; i++)
    9292            names.add(serverNames[i]);
  • router/java/src/net/i2p/router/time/RouterTimestamper.java

    re61e950 rbacce17  
    6262        super();
    6363        // moved here to prevent problems with synchronized statements.
    64         _servers = new ArrayList(3);
    65         _listeners = new CopyOnWriteArrayList();
     64        _servers = new ArrayList<String>(3);
     65        _listeners = new CopyOnWriteArrayList<UpdateListener>();
    6666        _context = ctx;
    6767        _daemon = daemon;
     
    179179                        } catch (IllegalArgumentException iae) {
    180180                            if ( (!_initialized) && (_log.shouldLog(Log.ERROR)) ) {
    181                                 List<String> all = new ArrayList();
     181                                List<String> all = new ArrayList<String>();
    182182                                if (_priorityServers != null)
    183183                                    all.addAll(_priorityServers);
     
    300300            }
    301301            if (country != null &&  country.length() > 0) {
    302                 _priorityServers = new ArrayList(3);
     302                _priorityServers = new ArrayList<String>(3);
    303303                for (int i = 0; i < 3; i++)
    304304                     _priorityServers.add(i + "." + country + ".pool.ntp.org");
  • router/java/src/net/i2p/router/transport/BadCountries.java

    re61e950 rbacce17  
    5757            /* Yemen */ "YE"
    5858        };
    59         _countries = new HashSet(Arrays.asList(c));
     59        _countries = new HashSet<String>(Arrays.asList(c));
    6060    }
    6161
  • router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java

    re61e950 rbacce17  
    1313import java.util.ArrayList;
    1414import java.util.Collections;
    15 import java.util.HashMap;
    1615import java.util.Iterator;
    1716import java.util.List;
    1817import java.util.Locale;
    19 import java.util.Map;
    20 import java.util.Properties;
    2118import java.util.Vector;
    2219
     
    3128import net.i2p.util.Addresses;
    3229import net.i2p.util.Log;
    33 import net.i2p.util.SimpleScheduler;
    3430import net.i2p.util.SimpleTimer;
    3531import net.i2p.util.SimpleTimer2;
     
    192188        //if (_context.router().isHidden())
    193189        //    return Collections.EMPTY_SET;
    194         List<RouterAddress> addresses = new ArrayList(_manager.getAddresses());
     190        List<RouterAddress> addresses = new ArrayList<RouterAddress>(_manager.getAddresses());
    195191        if (_log.shouldLog(Log.INFO))
    196192            _log.info("Creating addresses: " + addresses, new Exception("creator"));
  • router/java/src/net/i2p/router/transport/FIFOBandwidthLimiter.java

    re61e950 rbacce17  
    9292        _context.statManager().createRateStat("bwLimiter.outboundDelayedTime", "How long it takes to honor an outbound request (ignoring ones with that go instantly)?", "BandwidthLimiter", new long[] { 5*60*1000l, 60*60*1000l });
    9393        _context.statManager().createRateStat("bwLimiter.inboundDelayedTime", "How long it takes to honor an inbound request (ignoring ones with that go instantly)?", "BandwidthLimiter", new long[] { 5*60*1000l, 60*60*1000l });
    94         _pendingInboundRequests = new ArrayList(16);
    95         _pendingOutboundRequests = new ArrayList(16);
     94        _pendingInboundRequests = new ArrayList<Request>(16);
     95        _pendingOutboundRequests = new ArrayList<Request>(16);
    9696        _lastTotalSent = _totalAllocatedOutboundBytes.get();
    9797        _lastTotalReceived = _totalAllocatedInboundBytes.get();
     
    797797         */
    798798        public SimpleRequest(int bytes, int priority) {
    799             satisfiedBuffer = new ArrayList(1);
     799            satisfiedBuffer = new ArrayList<Request>(1);
    800800            _total = bytes;
    801801            _priority = priority;
  • router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java

    re61e950 rbacce17  
    88import net.i2p.I2PAppContext;
    99import net.i2p.data.DataHelper;
     10import net.i2p.router.transport.FIFOBandwidthLimiter.Request;
    1011import net.i2p.util.Log;
    1112
     
    9394        // bootstrap 'em with nothing
    9495        _lastRefillTime = _limiter.now();
    95         List<FIFOBandwidthLimiter.Request> buffer = new ArrayList(2);
     96        List<FIFOBandwidthLimiter.Request> buffer = new ArrayList<Request>(2);
    9697        while (_isRunning) {
    9798            long now = _limiter.now();
  • router/java/src/net/i2p/router/transport/GeoIP.java

    re61e950 rbacce17  
    99import java.io.File;
    1010import java.io.FileInputStream;
    11 import java.net.InetAddress;
    1211import java.io.InputStreamReader;
    13 import java.net.UnknownHostException;
    1412import java.util.Arrays;
    1513import java.util.Locale;
     
    6361        _context = context;
    6462        _log = context.logManager().getLog(GeoIP.class);
    65         _codeToName = new ConcurrentHashMap(512);
    66         _codeCache = new ConcurrentHashMap(512);
    67         _IPToCountry = new ConcurrentHashMap();
    68         _pendingSearch = new ConcurrentHashSet();
    69         _pendingIPv6Search = new ConcurrentHashSet();
    70         _notFound = new ConcurrentHashSet();
     63        _codeToName = new ConcurrentHashMap<String, String>(512);
     64        _codeCache = new ConcurrentHashMap<String, String>(512);
     65        _IPToCountry = new ConcurrentHashMap<Long, String>();
     66        _pendingSearch = new ConcurrentHashSet<Long>();
     67        _pendingIPv6Search = new ConcurrentHashSet<Long>();
     68        _notFound = new ConcurrentHashSet<Long>();
    7169        _lock = new AtomicBoolean();
    7270        readCountryFile();
  • router/java/src/net/i2p/router/transport/GeoIPv6.java

    re61e950 rbacce17  
    155155    private static boolean compressGeoIPv6CSVFiles(List<File> inFiles, File outFile) {
    156156        boolean DEBUG = false;
    157         List<V6Entry> entries = new ArrayList(20000);
     157        List<V6Entry> entries = new ArrayList<V6Entry>(20000);
    158158        for (File geoFile : inFiles) {
    159159            int count = 0;
     
    343343            System.exit(1);
    344344        }
    345         List<File> infiles = new ArrayList();
     345        List<File> infiles = new ArrayList<File>();
    346346        for (int i = 0; i < args.length - 1; i++) {
    347347            infiles.add(new File(args[i]));
     
    354354        }
    355355        // readback for testing
    356         readGeoIPFile(outfile, new Long[] { Long.MAX_VALUE }, Collections.EMPTY_MAP, new Log(GeoIPv6.class));
     356        readGeoIPFile(outfile, new Long[] { Long.MAX_VALUE }, Collections.<String, String> emptyMap(), new Log(GeoIPv6.class));
    357357    }
    358358}
  • router/java/src/net/i2p/router/transport/OutboundMessageRegistry.java

    re61e950 rbacce17  
    5252        _context = context;
    5353        _log = _context.logManager().getLog(OutboundMessageRegistry.class);
    54         _selectors = new ArrayList(64);
    55         _selectorToMessage = new HashMap(64);
    56         _activeMessages = new ConcurrentHashSet(64);
     54        _selectors = new ArrayList<MessageSelector>(64);
     55        _selectorToMessage = new HashMap<MessageSelector, Object>(64);
     56        _activeMessages = new ConcurrentHashSet<OutNetMessage>(64);
    5757        _cleanupTask = new CleanupTask();
    5858    }
     
    109109                boolean isMatch = sel.isMatch(message);
    110110                if (isMatch) {
    111                     if (matchedSelectors == null) matchedSelectors = new ArrayList(1);
     111                    if (matchedSelectors == null) matchedSelectors = new ArrayList<MessageSelector>(1);
    112112                    matchedSelectors.add(sel);
    113113                    if (!sel.continueMatching()) {
    114                         if (removedSelectors == null) removedSelectors = new ArrayList(1);
     114                        if (removedSelectors == null) removedSelectors = new ArrayList<MessageSelector>(1);
    115115                        removedSelectors.add(sel);
    116116                        //iter.remove();
     
    124124        List<OutNetMessage> rv = null;
    125125        if (matchedSelectors != null) {
    126             rv = new ArrayList(matchedSelectors.size());
     126            rv = new ArrayList<OutNetMessage>(matchedSelectors.size());
    127127            for (MessageSelector sel : matchedSelectors) {
    128128                boolean removed = false;
    129129                OutNetMessage msg = null;
    130                 List msgs = null;
     130                List<OutNetMessage> msgs = null;
    131131                synchronized (_selectorToMessage) {
    132132                    Object o = null;
     
    155155            }
    156156        } else {
    157             rv = Collections.EMPTY_LIST;
     157            rv = Collections.emptyList();
    158158        }
    159159
     
    203203            Object oldMsg = _selectorToMessage.put(sel, msg);
    204204            if (oldMsg != null) {
    205                 List multi = null;
     205                List<OutNetMessage> multi = null;
    206206                if (oldMsg instanceof OutNetMessage) {
    207207                    //multi = Collections.synchronizedList(new ArrayList(4));
    208                     multi = new ArrayList(4);
    209                     multi.add(oldMsg);
     208                    multi = new ArrayList<OutNetMessage>(4);
     209                    multi.add((OutNetMessage)oldMsg);
    210210                    multi.add(msg);
    211211                    _selectorToMessage.put(sel, multi);
     
    262262        public void timeReached() {
    263263            long now = _context.clock().now();
    264             List<MessageSelector> removing = new ArrayList(8);
     264            List<MessageSelector> removing = new ArrayList<MessageSelector>(8);
    265265            synchronized (_selectors) {
    266266                // CME?
  • router/java/src/net/i2p/router/transport/TransportImpl.java

    re61e950 rbacce17  
    2424import java.util.Set;
    2525import java.util.Vector;
    26 import java.util.concurrent.ConcurrentHashMap;
    2726import java.util.concurrent.ArrayBlockingQueue;
    2827import java.util.concurrent.BlockingQueue;
     
    4443import net.i2p.util.LHMCache;
    4544import net.i2p.util.Log;
    46 import net.i2p.util.SimpleScheduler;
    4745import net.i2p.util.SimpleTimer;
    4846import net.i2p.util.SystemVersion;
     
    7674        // 1024 nominal for 128 MB
    7775        int size = (int) Math.max(min, Math.min(max, 1 + (maxMemory / (128*1024))));
    78         _IPMap = new LHMCache(size);
     76        _IPMap = new LHMCache<Hash, byte[]>(size);
    7977    }
    8078
     
    9694        _context.statManager().createRateStat("transport.expiredOnQueueLifetime", "How long a message that expires on our outbound queue is processed", "Transport", new long[] { 60*1000l, 10*60*1000l, 60*60*1000l, 24*60*60*1000l } );
    9795
    98         _currentAddresses = new CopyOnWriteArrayList();
     96        _currentAddresses = new CopyOnWriteArrayList<RouterAddress>();
    9997        if (getStyle().equals("NTCP"))
    100             _sendPool = new ArrayBlockingQueue(8);
     98            _sendPool = new ArrayBlockingQueue<OutNetMessage>(8);
    10199        else
    102100            _sendPool = null;
    103         _unreachableEntries = new HashMap(32);
    104         _wasUnreachableEntries = new HashMap(32);
    105         _localAddresses = new ConcurrentHashSet(4);
     101        _unreachableEntries = new HashMap<Hash, Long>(32);
     102        _wasUnreachableEntries = new HashMap<Hash, Long>(32);
     103        _localAddresses = new ConcurrentHashSet<InetAddress>(4);
    106104        _context.simpleScheduler().addPeriodicEvent(new CleanupUnreachable(), 2 * UNREACHABLE_PERIOD, UNREACHABLE_PERIOD / 2);
    107105    }
     
    180178    public Vector getClockSkews() { return new Vector(); }
    181179
    182     public List<String> getMostRecentErrorMessages() { return Collections.EMPTY_LIST; }
     180    public List<String> getMostRecentErrorMessages() { return Collections.emptyList(); }
    183181
    184182    /**
     
    565563     */
    566564    protected Collection<InetAddress> getSavedLocalAddresses() {
    567         List<InetAddress> rv = new ArrayList(_localAddresses);
     565        List<InetAddress> rv = new ArrayList<InetAddress>(_localAddresses);
    568566        _localAddresses.clear();
    569567        return rv;
  • router/java/src/net/i2p/router/transport/TransportManager.java

    re61e950 rbacce17  
    1414import java.net.UnknownHostException;
    1515import java.util.ArrayList;
    16 import java.util.HashMap;
    1716import java.util.HashSet;
    18 import java.util.Iterator;
    1917import java.util.List;
    2018import java.util.Map;
     
    3230import net.i2p.router.RouterContext;
    3331import static net.i2p.router.transport.Transport.AddressSource.*;
     32import net.i2p.router.transport.TransportManager.Port;
    3433import net.i2p.router.transport.crypto.DHSessionKeyBuilder;
    3534import net.i2p.router.transport.ntcp.NTCPTransport;
     
    6766        _context.statManager().createRateStat("transport.bidFailNoTransports", "Could not attempt to bid on message, as none of the transports could attempt it", "Transport", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
    6867        _context.statManager().createRateStat("transport.bidFailAllTransports", "Could not attempt to bid on message, as all of the transports had failed", "Transport", new long[] { 60*1000, 10*60*1000, 60*60*1000 });
    69         _transports = new ConcurrentHashMap(2);
     68        _transports = new ConcurrentHashMap<String, Transport>(2);
    7069        if (_context.getBooleanPropertyDefaultTrue(PROP_ENABLE_UPNP))
    7170            _upnpManager = new UPnPManager(context, this);
     
    169168        // Let's do this in a predictable order to make testing easier
    170169        // Start NTCP first so it can get notified from SSU
    171         List<Transport> tps = new ArrayList();
     170        List<Transport> tps = new ArrayList<Transport>();
    172171        Transport tp = getTransport(NTCPTransport.STYLE);
    173172        if (tp != null)
     
    364363     */
    365364    public List<RouterAddress> getAddresses() {
    366         List<RouterAddress> rv = new ArrayList(4);
     365        List<RouterAddress> rv = new ArrayList<RouterAddress>(4);
    367366        // do this first since SSU may force a NTCP change
    368367        for (Transport t : _transports.values())
     
    407406     */
    408407    private Set<Port> getPorts() {
    409         Set<Port> rv = new HashSet(4);
     408        Set<Port> rv = new HashSet<Port>(4);
    410409        for (Transport t : _transports.values()) {
    411410            int port = t.getRequestedPort();
     
    436435            throw new IllegalArgumentException("WTF, bids for a message bound to ourselves?");
    437436
    438         List<TransportBid> rv = new ArrayList(_transports.size());
     437        List<TransportBid> rv = new ArrayList<TransportBid>(_transports.size());
    439438        Set failedTransports = msg.getFailedTransports();
    440439        for (Transport t : _transports.values()) {
     
    536535
    537536    public List<String> getMostRecentErrorMessages() {
    538         List<String> rv = new ArrayList(16);
     537        List<String> rv = new ArrayList<String>(16);
    539538        for (Transport t : _transports.values()) {
    540539            rv.addAll(t.getMostRecentErrorMessages());
     
    544543   
    545544    public void renderStatusHTML(Writer out, String urlBase, int sortFlags) throws IOException {
    546         TreeMap<String, Transport> transports = new TreeMap();
     545        TreeMap<String, Transport> transports = new TreeMap<String, Transport>();
    547546        for (Transport t : _transports.values()) {
    548547            transports.put(t.getStyle(), t);
  • router/java/src/net/i2p/router/transport/UPnP.java

    re61e950 rbacce17  
    267267       
    268268        private void registerPortMappings() {
    269                 Set ports;
     269                Set<ForwardPort> ports;
    270270                synchronized(lock) {
    271                         ports = new HashSet(portsForwarded);
     271                        ports = new HashSet<ForwardPort>(portsForwarded);
    272272                }
    273273                if (ports.isEmpty())
     
    327327       
    328328        public void unregisterPortMappings() {
    329                 Set ports;
     329                Set<ForwardPort> ports;
    330330                synchronized(lock) {
    331                         ports = new HashSet(portsForwarded);
     331                        ports = new HashSet<ForwardPort>(portsForwarded);
    332332                }
    333333                if (ports.isEmpty())
     
    919919                                                                      "UPnP device does not support port forwarding",
    920920                                                                      port.portNumber);
    921                         Map map = Collections.singletonMap(port, fps);
     921                        Map<ForwardPort, ForwardPortStatus> map = Collections.singletonMap(port, fps);
    922922                        forwardCallback.portForwardStatus(map);
    923923                    }
     
    950950                                        fps = new ForwardPortStatus(ForwardPortStatus.PROBABLE_FAILURE, "UPnP port forwarding apparently failed", port.portNumber);
    951951                                }
    952                                 Map map = Collections.singletonMap(port, fps);
     952                                Map<ForwardPort, ForwardPortStatus> map = Collections.singletonMap(port, fps);
    953953                                try {
    954954                                        forwardCallback.portForwardStatus(map);
  • router/java/src/net/i2p/router/transport/UPnPManager.java

    re61e950 rbacce17  
    77import java.net.InetAddress;
    88import java.util.HashSet;
    9 import java.util.Iterator;
    109import java.util.Map;
    1110import java.util.Set;
     
    123122        //}
    124123
    125         Set<ForwardPort> forwards = new HashSet(ports.size());
     124        Set<ForwardPort> forwards = new HashSet<ForwardPort>(ports.size());
    126125        for (TransportManager.Port entry : ports) {
    127126            String style = entry.style;
  • router/java/src/net/i2p/router/transport/crypto/DHSessionKeyBuilder.java

    re61e950 rbacce17  
    1818import net.i2p.I2PException;
    1919import net.i2p.crypto.CryptoConstants;
    20 import net.i2p.crypto.KeyGenerator;
    2120import net.i2p.crypto.SHA256Generator;
    2221import net.i2p.data.ByteArray;
     
    471470                _log.debug("DH Precalc (minimum: " + _minSize + " max: " + _maxSize + ", delay: "
    472471                           + _calcDelay + ")");
    473             _builders = new LinkedBlockingQueue(_maxSize);
     472            _builders = new LinkedBlockingQueue<DHSessionKeyBuilder>(_maxSize);
    474473            setPriority(Thread.MIN_PRIORITY);
    475474        }
  • router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java

    re61e950 rbacce17  
    77import java.nio.channels.SocketChannel;
    88import java.util.ArrayList;
    9 import java.util.Iterator;
    109import java.util.List;
    1110import java.util.Queue;
     
    3130import net.i2p.router.RouterContext;
    3231import net.i2p.router.transport.FIFOBandwidthLimiter;
    33 import net.i2p.router.util.CoDelPriorityBlockingQueue;
     32import net.i2p.router.transport.FIFOBandwidthLimiter.Request;
    3433import net.i2p.router.util.PriBlockingQueue;
    3534import net.i2p.util.ByteCache;
     
    171170        _remAddr = null;
    172171        _chan = chan;
    173         _readBufs = new ConcurrentLinkedQueue();
    174         _writeBufs = new ConcurrentLinkedQueue();
    175         _bwInRequests = new ConcurrentHashSet(2);
    176         _bwOutRequests = new ConcurrentHashSet(8);
     172        _readBufs = new ConcurrentLinkedQueue<ByteBuffer>();
     173        _writeBufs = new ConcurrentLinkedQueue<ByteBuffer>();
     174        _bwInRequests = new ConcurrentHashSet<Request>(2);
     175        _bwOutRequests = new ConcurrentHashSet<Request>(8);
    177176        //_outbound = new CoDelPriorityBlockingQueue(ctx, "NTCP-Connection", 32);
    178         _outbound = new PriBlockingQueue(ctx, "NTCP-Connection", 32);
     177        _outbound = new PriBlockingQueue<OutNetMessage>(ctx, "NTCP-Connection", 32);
    179178        _isInbound = true;
    180179        _decryptBlockBuf = new byte[BLOCK_SIZE];
     
    199198        _remotePeer = remotePeer;
    200199        _remAddr = remAddr;
    201         _readBufs = new ConcurrentLinkedQueue();
    202         _writeBufs = new ConcurrentLinkedQueue();
    203         _bwInRequests = new ConcurrentHashSet(2);
    204         _bwOutRequests = new ConcurrentHashSet(8);
     200        _readBufs = new ConcurrentLinkedQueue<ByteBuffer>();
     201        _writeBufs = new ConcurrentLinkedQueue<ByteBuffer>();
     202        _bwInRequests = new ConcurrentHashSet<Request>(2);
     203        _bwOutRequests = new ConcurrentHashSet<Request>(8);
    205204        //_outbound = new CoDelPriorityBlockingQueue(ctx, "NTCP-Connection", 32);
    206         _outbound = new PriBlockingQueue(ctx, "NTCP-Connection", 32);
     205        _outbound = new PriBlockingQueue<OutNetMessage>(ctx, "NTCP-Connection", 32);
    207206        _isInbound = false;
    208207        _establishState = new EstablishState(ctx, transport, this);
     
    382381        }
    383382
    384         List<OutNetMessage> pending = new ArrayList();
     383        List<OutNetMessage> pending = new ArrayList<OutNetMessage>();
    385384        //_outbound.drainAllTo(pending);
    386385        _outbound.drainTo(pending);
     
    870869    }
    871870
    872     private final static LinkedBlockingQueue<PrepBuffer> _bufs = new LinkedBlockingQueue(NUM_PREP_BUFS);
     871    private final static LinkedBlockingQueue<PrepBuffer> _bufs = new LinkedBlockingQueue<PrepBuffer>(NUM_PREP_BUFS);
    873872
    874873    /**
     
    13311330     *  FIXME static queue mixes handlers from different contexts in multirouter JVM
    13321331     */
    1333     private final static LinkedBlockingQueue<I2NPMessageHandler> _i2npHandlers = new LinkedBlockingQueue(MAX_HANDLERS);
     1332    private final static LinkedBlockingQueue<I2NPMessageHandler> _i2npHandlers = new LinkedBlockingQueue<I2NPMessageHandler>(MAX_HANDLERS);
    13341333
    13351334    private final static I2NPMessageHandler acquireHandler(RouterContext ctx) {
  • router/java/src/net/i2p/router/transport/ntcp/NTCPTransport.java

    re61e950 rbacce17  
    1313import java.util.Collections;
    1414import java.util.Comparator;
    15 import java.util.HashMap;
    1615import java.util.HashSet;
    1716import java.util.Iterator;
     
    3231import net.i2p.router.OutNetMessage;
    3332import net.i2p.router.RouterContext;
    34 import net.i2p.router.transport.CommSystemFacadeImpl;
    3533import net.i2p.router.transport.Transport;
    3634import static net.i2p.router.transport.Transport.AddressSource.*;
     
    4038import static net.i2p.router.transport.TransportUtil.IPv6Config.*;
    4139import net.i2p.router.transport.crypto.DHSessionKeyBuilder;
    42 import net.i2p.router.transport.udp.UDPTransport;
    4340import net.i2p.util.Addresses;
    4441import net.i2p.util.ConcurrentHashSet;
     
    171168        //_context.statManager().createRateStat("ntcp.write", "", "ntcp", RATES);
    172169        _context.statManager().createRateStat("ntcp.writeError", "", "ntcp", RATES);
    173         _endpoints = new HashSet(4);
    174         _establishing = new ConcurrentHashSet(16);
     170        _endpoints = new HashSet<InetSocketAddress>(4);
     171        _establishing = new ConcurrentHashSet<NTCPConnection>(16);
    175172        _conLock = new Object();
    176         _conByIdent = new ConcurrentHashMap(64);
     173        _conByIdent = new ConcurrentHashMap<Hash, NTCPConnection>(64);
    177174
    178175        _finisher = new NTCPSendFinisher(ctx, this);
     
    473470    @Override
    474471    public Vector<Long> getClockSkews() {
    475         Vector<Long> skews = new Vector();
     472        Vector<Long> skews = new Vector<Long>();
    476473
    477474        for (NTCPConnection con : _conByIdent.values()) {
     
    10891086        List<NTCPConnection> cons;
    10901087        synchronized (_conLock) {
    1091             cons = new ArrayList(_conByIdent.values());
     1088            cons = new ArrayList<NTCPConnection>(_conByIdent.values());
    10921089            _conByIdent.clear();
    10931090        }
     
    11061103    @Override
    11071104    public void renderStatusHTML(java.io.Writer out, String urlBase, int sortFlags) throws IOException {
    1108         TreeSet<NTCPConnection> peers = new TreeSet(getComparator(sortFlags));
     1105        TreeSet<NTCPConnection> peers = new TreeSet<NTCPConnection>(getComparator(sortFlags));
    11091106        peers.addAll(_conByIdent.values());
    11101107
     
    12211218    }
    12221219
    1223     private Comparator getComparator(int sortFlags) {
    1224         Comparator rv = null;
     1220    private Comparator<NTCPConnection> getComparator(int sortFlags) {
     1221        Comparator<NTCPConnection> rv = null;
    12251222        switch (Math.abs(sortFlags)) {
    12261223            default:
  • router/java/src/net/i2p/router/transport/ntcp/Reader.java

    re61e950 rbacce17  
    3131        _context = ctx;
    3232        _log = ctx.logManager().getLog(getClass());
    33         _pendingConnections = new LinkedHashSet(16);
    34         _runners = new ArrayList(8);
    35         _liveReads = new HashSet(8);
    36         _readAfterLive = new HashSet(8);
     33        _pendingConnections = new LinkedHashSet<NTCPConnection>(16);
     34        _runners = new ArrayList<Runner>(8);
     35        _liveReads = new HashSet<NTCPConnection>(8);
     36        _readAfterLive = new HashSet<NTCPConnection>(8);
    3737    }
    3838   
  • router/java/src/net/i2p/router/transport/ntcp/Writer.java

    re61e950 rbacce17  
    2727    public Writer(RouterContext ctx) {
    2828        _log = ctx.logManager().getLog(getClass());
    29         _pendingConnections = new LinkedHashSet(16);
    30         _runners = new ArrayList(5);
    31         _liveWrites = new HashSet(5);
    32         _writeAfterLive = new HashSet(5);
     29        _pendingConnections = new LinkedHashSet<NTCPConnection>(16);
     30        _runners = new ArrayList<Runner>(5);
     31        _liveWrites = new HashSet<NTCPConnection>(5);
     32        _writeAfterLive = new HashSet<NTCPConnection>(5);
    3333    }
    3434   
  • router/java/src/net/i2p/router/transport/udp/ACKSender.java

    re61e950 rbacce17  
    3535        _log = ctx.logManager().getLog(ACKSender.class);
    3636        _transport = transport;
    37         _peersToACK = new LinkedBlockingQueue();
     37        _peersToACK = new LinkedBlockingQueue<PeerState>();
    3838        _builder = new PacketBuilder(_context, transport);
    3939        _alive = true;
     
    8787
    8888        // we use a Set to strip out dups that come in on the Queue
    89         Set<PeerState> notYet = new HashSet();
     89        Set<PeerState> notYet = new HashSet<PeerState>();
    9090        while (_alive) {
    9191            PeerState peer = null;
  • router/java/src/net/i2p/router/transport/udp/EstablishmentManager.java

    re61e950 rbacce17  
    1010import java.util.concurrent.ConcurrentHashMap;
    1111
    12 import net.i2p.data.Base64;
    13 import net.i2p.data.DataHelper;
    1412import net.i2p.data.Hash;
    1513import net.i2p.data.RouterAddress;
     
    128126        _transport = transport;
    129127        _builder = new PacketBuilder(ctx, transport);
    130         _inboundStates = new ConcurrentHashMap();
    131         _outboundStates = new ConcurrentHashMap();
    132         _queuedOutbound = new ConcurrentHashMap();
    133         _liveIntroductions = new ConcurrentHashMap();
    134         _outboundByClaimedAddress = new ConcurrentHashMap();
    135         _outboundByHash = new ConcurrentHashMap();
     128        _inboundStates = new ConcurrentHashMap<RemoteHostId, InboundEstablishState>();
     129        _outboundStates = new ConcurrentHashMap<RemoteHostId, OutboundEstablishState>();
     130        _queuedOutbound = new ConcurrentHashMap<RemoteHostId, List<OutNetMessage>>();
     131        _liveIntroductions = new ConcurrentHashMap<Long, OutboundEstablishState>();
     132        _outboundByClaimedAddress = new ConcurrentHashMap<RemoteHostId, OutboundEstablishState>();
     133        _outboundByHash = new ConcurrentHashMap<Hash, OutboundEstablishState>();
    136134        _activityLock = new Object();
    137135        DEFAULT_MAX_CONCURRENT_ESTABLISH = Math.max(DEFAULT_LOW_MAX_CONCURRENT_ESTABLISH,
     
    313311                        rejected = true;
    314312                    } else {
    315                         List<OutNetMessage> newQueued = new ArrayList(MAX_QUEUED_PER_PEER);
     313                        List<OutNetMessage> newQueued = new ArrayList<OutNetMessage>(MAX_QUEUED_PER_PEER);
    316314                        List<OutNetMessage> queued = _queuedOutbound.putIfAbsent(to, newQueued);
    317315                        if (queued == null) {
     
    623621            RemoteHostId to = entry.getKey();
    624622            List<OutNetMessage> allQueued = entry.getValue();
    625             List<OutNetMessage> queued = new ArrayList();
     623            List<OutNetMessage> queued = new ArrayList<OutNetMessage>();
    626624            long now = _context.clock().now();
    627625            synchronized (allQueued) {
  • router/java/src/net/i2p/router/transport/udp/IPThrottler.java

    re61e950 rbacce17  
    1717    public IPThrottler(int max, long time) {
    1818        _max = max;
    19         _counter = new ObjectCounter();
     19        _counter = new ObjectCounter<Integer>();
    2020        SimpleScheduler.getInstance().addPeriodicEvent(new Cleaner(), time);
    2121    }
  • router/java/src/net/i2p/router/transport/udp/InboundEstablishState.java

    re61e950 rbacce17  
    9999        _establishBegin = ctx.clock().now();
    100100        _keyBuilder = dh;
    101         _queuedMessages = new LinkedBlockingQueue();
     101        _queuedMessages = new LinkedBlockingQueue<OutNetMessage>();
    102102    }
    103103   
  • router/java/src/net/i2p/router/transport/udp/IntroductionManager.java

    re61e950 rbacce17  
    1212
    1313import net.i2p.data.Base64;
    14 import net.i2p.data.DataHelper;
    1514import net.i2p.data.RouterAddress;
    1615import net.i2p.data.RouterInfo;
    1716import net.i2p.data.SessionKey;
    1817import net.i2p.router.RouterContext;
    19 import net.i2p.router.transport.TransportImpl;
    2018import net.i2p.util.Addresses;
    2119import net.i2p.util.ConcurrentHashSet;
     
    105103        _transport = transport;
    106104        _builder = new PacketBuilder(ctx, transport);
    107         _outbound = new ConcurrentHashMap(MAX_OUTBOUND);
    108         _inbound = new ConcurrentHashSet(MAX_INBOUND);
    109         _recentHolePunches = new HashSet(16);
     105        _outbound = new ConcurrentHashMap<Long, PeerState>(MAX_OUTBOUND);
     106        _inbound = new ConcurrentHashSet<PeerState>(MAX_INBOUND);
     107        _recentHolePunches = new HashSet<InetAddress>(16);
    110108        ctx.statManager().createRateStat("udp.receiveRelayIntro", "How often we get a relayed request for us to talk to someone?", "udp", UDPTransport.RATES);
    111109        ctx.statManager().createRateStat("udp.receiveRelayRequest", "How often we receive a good request to relay to someone else?", "udp", UDPTransport.RATES);
     
    170168            _log.debug("Picking inbound out of " + _inbound.size());
    171169        if (_inbound.isEmpty()) return 0;
    172         List<PeerState> peers = new ArrayList(_inbound);
     170        List<PeerState> peers = new ArrayList<PeerState>(_inbound);
    173171        int sz = peers.size();
    174172        start = start % sz;
  • router/java/src/net/i2p/router/transport/udp/MessageReceiver.java

    re61e950 rbacce17  
    5555            qsize = (int) Math.max(MIN_QUEUE_SIZE, Math.min(MAX_QUEUE_SIZE, maxMemory / (2*1024*1024)));
    5656        }
    57         _completeMessages = new CoDelBlockingQueue(ctx, "UDP-MessageReceiver", qsize);
     57        _completeMessages = new CoDelBlockingQueue<InboundMessageState>(ctx, "UDP-MessageReceiver", qsize);
    5858
    5959        // the runners run forever, no need to have a cache
  • router/java/src/net/i2p/router/transport/udp/OutboundEstablishState.java

    re61e950 rbacce17  
    11package net.i2p.router.transport.udp;
    22
    3 import java.net.InetAddress;
    43import java.util.Queue;
    54import java.util.concurrent.LinkedBlockingQueue;
     
    117116        _remotePeer = remotePeer;
    118117        _introKey = introKey;
    119         _queuedMessages = new LinkedBlockingQueue();
     118        _queuedMessages = new LinkedBlockingQueue<OutNetMessage>();
    120119        _establishBegin = ctx.clock().now();
    121120        _remoteAddress = addr;
  • router/java/src/net/i2p/router/transport/udp/OutboundMessageFragments.java

    re61e950 rbacce17  
    88import net.i2p.data.Hash;
    99import net.i2p.data.RouterInfo;
    10 import net.i2p.data.i2np.I2NPMessage;
    1110import net.i2p.router.OutNetMessage;
    1211import net.i2p.router.RouterContext;
     
    6968        _transport = transport;
    7069        // _throttle = throttle;
    71         _activePeers = new ConcurrentHashSet(256);
     70        _activePeers = new ConcurrentHashSet<PeerState>(256);
    7271        _builder = new PacketBuilder(ctx, transport);
    7372        _alive = true;
     
    364363            int newFullAckCount = msgIds.size();
    365364            msgIds.addAll(peer.getCurrentResendACKs());
    366             List<ACKBitfield> partialACKBitfields = new ArrayList();
     365            List<ACKBitfield> partialACKBitfields = new ArrayList<ACKBitfield>();
    367366            peer.fetchPartialACKs(partialACKBitfields);
    368367            int piggybackedPartialACK = partialACKBitfields.size();
    369368            // getCurrentFullACKs() already makes a copy, do we need to copy again?
    370369            // YES because buildPacket() now removes them (maybe)
    371             List<Long> remaining = new ArrayList(msgIds);
     370            List<Long> remaining = new ArrayList<Long>(msgIds);
    372371            int sparseCount = 0;
    373372            UDPPacket rv[] = new UDPPacket[fragments]; //sparse
  • router/java/src/net/i2p/router/transport/udp/PacketBuilder.java

    re61e950 rbacce17  
    1212import net.i2p.I2PAppContext;
    1313import net.i2p.data.Base64;
    14 import net.i2p.data.ByteArray;
    1514import net.i2p.data.DataHelper;
    1615import net.i2p.data.Hash;
     
    444443     */
    445444    public UDPPacket buildPing(PeerState peer) {
    446         return buildACK(peer, Collections.EMPTY_LIST);
     445        return buildACK(peer, Collections.<ACKBitfield> emptyList());
    447446    }
    448447
     
    10831082        UDPAddress addr = state.getRemoteAddress();
    10841083        int count = addr.getIntroducerCount();
    1085         List<UDPPacket> rv = new ArrayList(count);
     1084        List<UDPPacket> rv = new ArrayList<UDPPacket>(count);
    10861085        for (int i = 0; i < count; i++) {
    10871086            InetAddress iaddr = addr.getIntroducerHost(i);
     
    10961095                (!_transport.isValid(iaddr.getAddress())) ||
    10971096                (Arrays.equals(iaddr.getAddress(), _transport.getExternalIP()) && !_transport.allowLocal())) {
    1098                 if (_log.shouldLog(_log.WARN))
     1097                if (_log.shouldLog(Log.WARN))
    10991098                    _log.warn("Cannot build a relay request to " + state.getRemoteIdentity().calculateHash()
    11001099                               + ", as their UDP address is invalid: addr=" + addr + " index=" + i);
  • router/java/src/net/i2p/router/transport/udp/PacketHandler.java

    re61e950 rbacce17  
    5757        _testManager = testManager;
    5858        _introManager = introManager;
    59         _failCache = new LHMCache(24);
     59        _failCache = new LHMCache<RemoteHostId, Object>(24);
    6060
    6161        long maxMemory = SystemVersion.getMaxMemory();
    6262        int qsize = (int) Math.max(MIN_QUEUE_SIZE, Math.min(MAX_QUEUE_SIZE, maxMemory / (2*1024*1024)));
    63         _inboundQueue = new CoDelBlockingQueue(ctx, "UDP-Receiver", qsize);
     63        _inboundQueue = new CoDelBlockingQueue<UDPPacket>(ctx, "UDP-Receiver", qsize);
    6464        int num_handlers;
    6565        if (maxMemory < 32*1024*1024)
  • router/java/src/net/i2p/router/transport/udp/PeerState.java

    re61e950 rbacce17  
    313313        _lastSendTime = now;
    314314        _lastReceiveTime = now;
    315         _currentACKs = new ConcurrentHashSet();
    316         _currentACKsResend = new LinkedBlockingQueue();
     315        _currentACKs = new ConcurrentHashSet<Long>();
     316        _currentACKsResend = new LinkedBlockingQueue<Long>();
    317317        _sendWindowBytes = DEFAULT_SEND_WINDOW_BYTES;
    318318        _sendWindowBytesRemaining = DEFAULT_SEND_WINDOW_BYTES;
     
    336336        _rtt = INIT_RTT;
    337337        _rttDeviation = _rtt;
    338         _inboundMessages = new HashMap(8);
     338        _inboundMessages = new HashMap<Long, InboundMessageState>(8);
    339339        _outboundMessages = new CachedIteratorArrayList<OutboundMessageState>(32);
    340340        //_outboundQueue = new CoDelPriorityBlockingQueue(ctx, "UDP-PeerState", 32);
    341         _outboundQueue = new PriBlockingQueue(ctx, "UDP-PeerState", 32);
     341        _outboundQueue = new PriBlockingQueue<OutboundMessageState>(ctx, "UDP-PeerState", 32);
    342342        // all createRateStat() moved to EstablishmentManager
    343343        _remoteIP = remoteIP;
     
    821821    public List<Long> getCurrentFullACKs() {
    822822            // no such element exception seen here
    823             List<Long> rv = new ArrayList(_currentACKs);
     823            List<Long> rv = new ArrayList<Long>(_currentACKs);
    824824            //if (_log.shouldLog(Log.DEBUG))
    825825            //    _log.debug("Returning " + _currentACKs.size() + " current acks");
     
    842842     */
    843843    public List<Long> getCurrentResendACKs() {
    844             List<Long> randomResends = new ArrayList(_currentACKsResend);
     844            List<Long> randomResends = new ArrayList<Long>(_currentACKsResend);
    845845            Collections.shuffle(randomResends, _context.random());
    846846            //if (_log.shouldLog(Log.DEBUG))
     
    916916            else
    917917                maxResendAcks = MAX_RESEND_ACKS_LARGE;
    918             List<ACKBitfield> rv = new ArrayList(maxResendAcks);
     918            List<ACKBitfield> rv = new ArrayList<ACKBitfield>(maxResendAcks);
    919919
    920920            // save to add to currentACKsResend later so we don't include twice
    921             List<Long> currentACKsRemoved = new ArrayList(_currentACKs.size());
     921            List<Long> currentACKsRemoved = new ArrayList<Long>(_currentACKs.size());
    922922            // As explained above, we include the acks in any order
    923923            // since we are unlikely to get backed up -
     
    935935                _wantACKSendSince = -1;
    936936            if (alwaysIncludeRetransmissions || !rv.isEmpty()) {
    937                 List<Long> randomResends = new ArrayList(_currentACKsResend);
     937                List<Long> randomResends = new ArrayList<Long>(_currentACKsResend);
    938938                // now repeat by putting in some old ACKs
    939939                // randomly selected from the Resend queue.
     
    969969            // we should try to find some packets to partially ACK
    970970            // (preferably the ones which have the most received fragments)
    971             List<ACKBitfield> partial = new ArrayList();
     971            List<ACKBitfield> partial = new ArrayList<ACKBitfield>();
    972972            fetchPartialACKs(partial);
    973973            // we may not be able to use them all, but lets try...
     
    14331433            synchronized (_outboundMessages) {
    14341434                    _retransmitter = null;
    1435                     tempList = new ArrayList(_outboundMessages);
     1435                    tempList = new ArrayList<OutboundMessageState>(_outboundMessages);
    14361436                    _outboundMessages.clear();
    14371437            }
     
    14821482                    if (_retransmitter == state)
    14831483                        _retransmitter = null;
    1484                     if (succeeded == null) succeeded = new ArrayList(4);
     1484                    if (succeeded == null) succeeded = new ArrayList<OutboundMessageState>(4);
    14851485                    succeeded.add(state);
    14861486                } else if (state.isExpired()) {
     
    14891489                        _retransmitter = null;
    14901490                    _context.statManager().addRateData("udp.sendFailed", state.getPushCount());
    1491                     if (failed == null) failed = new ArrayList(4);
     1491                    if (failed == null) failed = new ArrayList<OutboundMessageState>(4);
    14921492                    failed.add(state);
    14931493                } else if (state.getPushCount() > OutboundMessageFragments.MAX_VOLLEYS) {
     
    14961496                        _retransmitter = null;
    14971497                    _context.statManager().addRateData("udp.sendAggressiveFailed", state.getPushCount());
    1498                     if (failed == null) failed = new ArrayList(4);
     1498                    if (failed == null) failed = new ArrayList<OutboundMessageState>(4);
    14991499                    failed.add(state);
    15001500                } // end (pushCount > maxVolleys)
     
    19141914        oldPeer._dead = true;
    19151915       
    1916         List<Long> tmp = new ArrayList();
     1916        List<Long> tmp = new ArrayList<Long>();
    19171917        // AIOOBE from concurrent access
    19181918        //tmp.addAll(oldPeer._currentACKs);
     
    19341934        }
    19351935       
    1936         Map<Long, InboundMessageState> msgs = new HashMap();
     1936        Map<Long, InboundMessageState> msgs = new HashMap<Long, InboundMessageState>();
    19371937        synchronized (oldPeer._inboundMessages) {
    19381938            msgs.putAll(oldPeer._inboundMessages);
     
    19441944        msgs.clear();
    19451945       
    1946         List<OutboundMessageState> tmp2 = new ArrayList();
     1946        List<OutboundMessageState> tmp2 = new ArrayList<OutboundMessageState>();
    19471947        OutboundMessageState retransmitter = null;
    19481948        synchronized (oldPeer._outboundMessages) {
  • router/java/src/net/i2p/router/transport/udp/PeerTestManager.java

    re61e950 rbacce17  
    1818import net.i2p.util.Addresses;
    1919import net.i2p.util.Log;
    20 import net.i2p.util.SimpleScheduler;
    2120import net.i2p.util.SimpleTimer;
    2221
     
    162161        _transport = transport;
    163162        _log = context.logManager().getLog(PeerTestManager.class);
    164         _activeTests = new ConcurrentHashMap();
    165         _recentTests = new LinkedBlockingQueue();
     163        _activeTests = new ConcurrentHashMap<Long, PeerTestState>();
     164        _recentTests = new LinkedBlockingQueue<Long>();
    166165        _packetBuilder = new PacketBuilder(context, transport);
    167166        _throttle = new IPThrottler(MAX_PER_IP, THROTTLE_CLEAN_TIME);
  • router/java/src/net/i2p/router/transport/udp/RemoteHostId.java

    re61e950 rbacce17  
    11package net.i2p.router.transport.udp;
    22
    3 import net.i2p.data.Base64;
    43import net.i2p.data.DataHelper;
    54import net.i2p.data.Hash;
  • router/java/src/net/i2p/router/transport/udp/TimedWeightedPriorityMessageQueue.java

    re61e950 rbacce17  
    2525    private Log _log;
    2626    /** FIFO queue of messages in a particular priority */
    27     private List _queue[];
     27    private List<OutNetMessage> _queue[];
    2828    /** all messages in the indexed queue are at or below the given priority. */
    2929    private int _priorityLimits[];
     
    4747    private FailedListener _listener;
    4848    /** set of peers (Hash) whose congestion window is exceeded in the active queue */
    49     private Set _chokedPeers;
     49    private Set<Hash> _chokedPeers;
    5050   
    5151    /**
     
    6868        _messagesFlushed = new int[weighting.length];
    6969        for (int i = 0; i < weighting.length; i++) {
    70             _queue[i] = new ArrayList(8);
     70            _queue[i] = new ArrayList<OutNetMessage>(8);
    7171            _weighting[i] = weighting[i];
    7272            _priorityLimits[i] = priorityLimits[i];
     
    7777        _alive = true;
    7878        _nextLock = this;
    79         _chokedPeers = Collections.synchronizedSet(new HashSet(16));
     79        _chokedPeers = Collections.synchronizedSet(new HashSet<Hash>(16));
    8080        _listener = lsnr;
    8181        _context.statManager().createRateStat("udp.timeToEntrance", "Message lifetime until it reaches the UDP system", "udp", UDPTransport.RATES);
     
    234234    private class Expirer implements Runnable {
    235235        public void run() {
    236             List removed = new ArrayList(1);
     236            List<OutNetMessage> removed = new ArrayList<OutNetMessage>(1);
    237237            while (_alive) {
    238238                long now = _context.clock().now();
  • router/java/src/net/i2p/router/transport/udp/UDPAddress.java

    re61e950 rbacce17  
    230230        // 512 nominal for 128 MB
    231231        int size = (int) Math.max(min, Math.min(max, 1 + (maxMemory / (256*1024))));
    232         _inetAddressCache = new LHMCache(size);
     232        _inetAddressCache = new LHMCache<String, InetAddress>(size);
    233233    }
    234234
  • router/java/src/net/i2p/router/transport/udp/UDPPacket.java

    re61e950 rbacce17  
    5252            long maxMemory = SystemVersion.getMaxMemory();
    5353            int csize = (int) Math.max(MIN_CACHE_SIZE, Math.min(MAX_CACHE_SIZE, maxMemory / (1024*1024)));
    54             _packetCache = new LinkedBlockingQueue(csize);
     54            _packetCache = new LinkedBlockingQueue<UDPPacket>(csize);
    5555        } else {
    5656            _packetCache = null;
  • router/java/src/net/i2p/router/transport/udp/UDPReceiver.java

    re61e950 rbacce17  
    99import net.i2p.util.I2PThread;
    1010import net.i2p.util.Log;
    11 import net.i2p.util.SimpleTimer;
    1211import net.i2p.util.SystemVersion;
    1312
  • router/java/src/net/i2p/router/transport/udp/UDPSender.java

    re61e950 rbacce17  
    4141        long maxMemory = SystemVersion.getMaxMemory();
    4242        int qsize = (int) Math.max(MIN_QUEUE_SIZE, Math.min(MAX_QUEUE_SIZE, maxMemory / (1024*1024)));
    43         _outboundQueue = new CoDelBlockingQueue(ctx, "UDP-Sender", qsize);
     43        _outboundQueue = new CoDelBlockingQueue<UDPPacket>(ctx, "UDP-Sender", qsize);
    4444        _socket = socket;
    4545        _runner = new Runner();
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    re61e950 rbacce17  
    1515import java.util.List;
    1616import java.util.Map;
    17 import java.util.Properties;
    1817import java.util.Set;
    1918import java.util.TreeSet;
     
    4948import net.i2p.util.Log;
    5049import net.i2p.util.OrderedProperties;
    51 import net.i2p.util.SimpleScheduler;
    5250import net.i2p.util.SimpleTimer;
    5351import net.i2p.util.SimpleTimer2;
     
    213211        _dhFactory = dh;
    214212        _log = ctx.logManager().getLog(UDPTransport.class);
    215         _peersByIdent = new ConcurrentHashMap(128);
    216         _peersByRemoteHost = new ConcurrentHashMap(128);
    217         _dropList = new ConcurrentHashSet(2);
    218         _endpoints = new CopyOnWriteArrayList();
     213        _peersByIdent = new ConcurrentHashMap<Hash, PeerState>(128);
     214        _peersByRemoteHost = new ConcurrentHashMap<RemoteHostId, PeerState>(128);
     215        _dropList = new ConcurrentHashSet<RemoteHostId>(2);
     216        _endpoints = new CopyOnWriteArrayList<UDPEndpoint>();
    219217       
    220218        // See comments in DummyThrottle.java
     
    281279        if (port < 0) {
    282280            port = UDPEndpoint.selectRandomPort(_context);
    283             Map<String, String> changes = new HashMap();
     281            Map<String, String> changes = new HashMap<String, String>();
    284282            changes.put(PROP_INTERNAL_PORT, Integer.toString(port));
    285283            changes.put(PROP_EXTERNAL_PORT, Integer.toString(port));
     
    331329        }
    332330
    333         List<InetAddress> bindToAddrs = new ArrayList(4);
     331        List<InetAddress> bindToAddrs = new ArrayList<InetAddress>(4);
    334332        if (bindTo != null) {
    335333            String[] bta = bindTo.split("[,; \r\n\t]");
     
    861859        } else if (updated) {
    862860            _context.statManager().addRateData("udp.addressUpdated", 1);
    863             Map<String, String> changes = new HashMap();
     861            Map<String, String> changes = new HashMap<String, String>();
    864862            if (ourIP.length == 4 && !fixedPort)
    865863                changes.put(PROP_EXTERNAL_PORT, Integer.toString(ourPort));
     
    976974     */
    977975    List<PeerState> getPeerStatesByIP(RemoteHostId hostInfo) {
    978         List<PeerState> rv = new ArrayList(4);
     976        List<PeerState> rv = new ArrayList<PeerState>(4);
    979977        byte[] ip = hostInfo.getIP();
    980978        if (ip != null && ip.length == 4) {
     
    21612159    @Override
    21622160    public Vector<Long> getClockSkews() {
    2163         Vector<Long> skews = new Vector();
     2161        Vector<Long> skews = new Vector<Long>();
    21642162
    21652163        // If our clock is way off, we may not have many (or any) successful connections,
     
    22142212    private static final int FLAG_DEBUG = 99;
    22152213   
    2216     private static Comparator getComparator(int sortFlags) {
    2217         Comparator rv = null;
     2214    private static Comparator<PeerState> getComparator(int sortFlags) {
     2215        Comparator<PeerState> rv = null;
    22182216        switch (Math.abs(sortFlags)) {
    22192217            case FLAG_IDLE_IN:
     
    25042502    @Override
    25052503    public void renderStatusHTML(Writer out, String urlBase, int sortFlags) throws IOException {
    2506         TreeSet<PeerState> peers = new TreeSet(getComparator(sortFlags));
     2504        TreeSet<PeerState> peers = new TreeSet<PeerState>(getComparator(sortFlags));
    25072505        peers.addAll(_peersByIdent.values());
    25082506        long offsetTotal = 0;
     
    28452843        public ExpirePeerEvent() {
    28462844            super(_context.simpleTimer2());
    2847             _expirePeers = new ConcurrentHashSet(128);
    2848             _expireBuffer = new ArrayList();
     2845            _expirePeers = new ConcurrentHashSet<PeerState>(128);
     2846            _expireBuffer = new ArrayList<PeerState>();
    28492847        }
    28502848
     
    30403038        if (peerRole == ALICE)
    30413039            throw new IllegalArgumentException();
    3042         List<PeerState> peers = new ArrayList(_peersByIdent.values());
    3043         for (Iterator<PeerState> iter = new RandomIterator(peers); iter.hasNext(); ) {
     3040        List<PeerState> peers = new ArrayList<PeerState>(_peersByIdent.values());
     3041        for (Iterator<PeerState> iter = new RandomIterator<PeerState>(peers); iter.hasNext(); ) {
    30443042            PeerState peer = iter.next();
    30453043            if ( (dontInclude != null) && (dontInclude.equals(peer.getRemoteHostId())) )
  • router/java/src/net/i2p/router/tunnel/BloomFilterIVValidator.java

    re61e950 rbacce17  
    11package net.i2p.router.tunnel;
    22
    3 import net.i2p.data.ByteArray;
    43import net.i2p.data.DataHelper;
    54import net.i2p.router.RouterContext;
  • router/java/src/net/i2p/router/tunnel/BuildMessageGenerator.java

    re61e950 rbacce17  
    144144     * @param order list of hop #s as Integers.  For instance, if (order.get(1) is 4), it is peer cfg.getPeer(4)
    145145     */
    146     public static void layeredEncrypt(I2PAppContext ctx, TunnelBuildMessage msg, TunnelCreatorConfig cfg, List order) {
     146    public static void layeredEncrypt(I2PAppContext ctx, TunnelBuildMessage msg, TunnelCreatorConfig cfg, List<Integer> order) {
    147147        //Log log = ctx.logManager().getLog(BuildMessageGenerator.class);
    148148        // encrypt the records so that the right elements will be visible at the right time
  • router/java/src/net/i2p/router/tunnel/FragmentHandler.java

    re61e950 rbacce17  
    106106        _context = context;
    107107        _log = context.logManager().getLog(FragmentHandler.class);
    108         _fragmentedMessages = new HashMap(16);
     108        _fragmentedMessages = new HashMap<Long, FragmentedMessage>(16);
    109109        _receiver = receiver;
    110110        // all createRateStat in TunnelDispatcher
  • router/java/src/net/i2p/router/tunnel/HashSetIVValidator.java

    re61e950 rbacce17  
    1616   
    1717    public HashSetIVValidator() {
    18         _received = new ConcurrentHashSet();
     18        _received = new ConcurrentHashSet<ByteArray>();
    1919    }
    2020   
  • router/java/src/net/i2p/router/tunnel/InboundEndpointProcessor.java

    re61e950 rbacce17  
    11package net.i2p.router.tunnel;
    22
    3 import net.i2p.data.ByteArray;
    43import net.i2p.data.Hash;
    54import net.i2p.router.RouterContext;
  • router/java/src/net/i2p/router/tunnel/InboundMessageDistributor.java

    re61e950 rbacce17  
    33import net.i2p.data.DatabaseEntry;
    44import net.i2p.data.Hash;
    5 import net.i2p.data.LeaseSet;
    65import net.i2p.data.Payload;
    7 import net.i2p.data.RouterInfo;
    86import net.i2p.data.TunnelId;
    97import net.i2p.data.i2np.DataMessage;
  • router/java/src/net/i2p/router/tunnel/OutboundGatewayProcessor.java

    re61e950 rbacce17  
    33import net.i2p.I2PAppContext;
    44import net.i2p.data.Base64;
    5 import net.i2p.data.ByteArray;
    65import net.i2p.util.Log;
    76import net.i2p.util.SimpleByteCache;
  • router/java/src/net/i2p/router/tunnel/PendingGatewayMessage.java

    re61e950 rbacce17  
    77import net.i2p.data.TunnelId;
    88import net.i2p.data.i2np.I2NPMessage;
    9 import net.i2p.router.RouterContext;
    109import net.i2p.router.util.CDQEntry;
    1110
     
    7069        synchronized (this) {
    7170            if (_messageIds == null)
    72                 _messageIds = new ArrayList();
     71                _messageIds = new ArrayList<Long>();
    7372            _messageIds.add(Long.valueOf(id));
    7473        }
     
    8281        synchronized (this) {
    8382            if (_messageIds != null)
    84                 return new ArrayList(_messageIds);
     83                return new ArrayList<Long>(_messageIds);
    8584            else
    86                 return new ArrayList();
     85                return new ArrayList<Long>();
    8786        }
    8887    }
  • router/java/src/net/i2p/router/tunnel/PumpedTunnelGateway.java

    re61e950 rbacce17  
    6969        } else if (receiver != null) {  // extended by ThrottledPTG for IB
    7070            // Bounded non-priority queue for inbound
    71             _prequeue = new CoDelBlockingQueue(context, "IBGW", MAX_IB_QUEUE);
     71            _prequeue = new CoDelBlockingQueue<PendingGatewayMessage>(context, "IBGW", MAX_IB_QUEUE);
    7272            _nextHop = receiver.getSendTo();
    7373            _isInbound = true;
  • router/java/src/net/i2p/router/tunnel/TrivialPreprocessor.java

    re61e950 rbacce17  
    44
    55import net.i2p.data.Base64;
    6 import net.i2p.data.ByteArray;
    76import net.i2p.data.DataHelper;
    87import net.i2p.data.Hash;
  • router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java

    re61e950 rbacce17  
    66import java.util.ArrayList;
    77import java.util.List;
    8 import java.util.Map;
    98import java.util.concurrent.LinkedBlockingQueue;
    109
     
    9897        _context = ctx;
    9998        _log = ctx.logManager().getLog(TunnelDispatcher.class);
    100         _outboundGateways = new ConcurrentHashMap();
    101         _outboundEndpoints = new ConcurrentHashMap();
    102         _participants = new ConcurrentHashMap();
    103         _inboundGateways = new ConcurrentHashMap();
    104         _participatingConfig = new ConcurrentHashMap();
     99        _outboundGateways = new ConcurrentHashMap<TunnelId, TunnelGateway>();
     100        _outboundEndpoints = new ConcurrentHashMap<TunnelId, OutboundTunnelEndpoint>();
     101        _participants = new ConcurrentHashMap<TunnelId, TunnelParticipant>();
     102        _inboundGateways = new ConcurrentHashMap<TunnelId, TunnelGateway>();
     103        _participatingConfig = new ConcurrentHashMap<TunnelId, HopConfig>();
    105104        _pumper = new TunnelGatewayPumper(ctx);
    106105        _leaveJob = new LeaveTunnel(ctx);
     
    691690     */
    692691    public List<HopConfig> listParticipatingTunnels() {
    693         return new ArrayList(_participatingConfig.values());
     692        return new ArrayList<HopConfig>(_participatingConfig.values());
    694693    }
    695694
     
    950949        public LeaveTunnel(RouterContext ctx) {
    951950            super(ctx);
    952             _configs = new LinkedBlockingQueue();
     951            _configs = new LinkedBlockingQueue<HopConfig>();
    953952            // 20 min no tunnels accepted + 10 min tunnel expiration
    954953            getTiming().setStartAfter(ctx.clock().now() + 30*60*1000);
  • router/java/src/net/i2p/router/tunnel/TunnelGateway.java

    re61e950 rbacce17  
    88import net.i2p.data.i2np.I2NPMessage;
    99import net.i2p.data.i2np.TunnelGatewayMessage;
    10 import net.i2p.router.Router;
    1110import net.i2p.router.RouterContext;
    1211import net.i2p.util.Log;
     
    5857        _context = context;
    5958        _log = context.logManager().getLog(getClass());
    60         _queue = new ArrayList(4);
     59        _queue = new ArrayList<PendingGatewayMessage>(4);
    6160        _preprocessor = preprocessor;
    6261        _sender = sender;
  • router/java/src/net/i2p/router/tunnel/TunnelGatewayPumper.java

    re61e950 rbacce17  
    77import java.util.List;
    88import java.util.Set;
    9 import java.util.concurrent.BlockingQueue;
    10 import java.util.concurrent.LinkedBlockingQueue;
    11 
    129import net.i2p.router.RouterContext;
    1310import net.i2p.util.I2PThread;
    14 import net.i2p.util.SimpleScheduler;
    1511import net.i2p.util.SimpleTimer;
    1612import net.i2p.util.SystemVersion;
     
    4238    public TunnelGatewayPumper(RouterContext ctx) {
    4339        _context = ctx;
    44         _wantsPumping = new LinkedHashSet(16);
    45         _backlogged = new HashSet(16);
     40        _wantsPumping = new LinkedHashSet<PumpedTunnelGateway>(16);
     41        _backlogged = new HashSet<PumpedTunnelGateway>(16);
    4642        if (ctx.getBooleanProperty("i2p.dummyTunnelManager")) {
    4743            _pumpers = 1;
     
    8076    public void run() {
    8177        PumpedTunnelGateway gw = null;
    82         List<PendingGatewayMessage> queueBuf = new ArrayList(32);
     78        List<PendingGatewayMessage> queueBuf = new ArrayList<PendingGatewayMessage>(32);
    8379        boolean requeue = false;
    8480        while (!_stop) {
  • router/java/src/net/i2p/router/tunnel/pool/BuildExecutor.java

    re61e950 rbacce17  
    3131 */
    3232class BuildExecutor implements Runnable {
    33     private final ArrayList<Long> _recentBuildIds = new ArrayList(100);
     33    private final ArrayList<Long> _recentBuildIds = new ArrayList<Long>(100);
    3434    private final RouterContext _context;
    3535    private final Log _log;
     
    5252        _manager = mgr;
    5353        _currentlyBuilding = new Object();
    54         _currentlyBuildingMap = new ConcurrentHashMap(MAX_CONCURRENT_BUILDS);
    55         _recentlyBuildingMap = new ConcurrentHashMap(4 * MAX_CONCURRENT_BUILDS);
     54        _currentlyBuildingMap = new ConcurrentHashMap<Long, PooledTunnelCreatorConfig>(MAX_CONCURRENT_BUILDS);
     55        _recentlyBuildingMap = new ConcurrentHashMap<Long, PooledTunnelCreatorConfig>(4 * MAX_CONCURRENT_BUILDS);
    5656        _context.statManager().createRateStat("tunnel.concurrentBuilds", "How many builds are going at once", "Tunnels", new long[] { 60*1000, 5*60*1000, 60*60*1000 });
    5757        _context.statManager().createRateStat("tunnel.concurrentBuildsLagged", "How many builds are going at once when we reject further builds, due to job lag (period is lag)", "Tunnels", new long[] { 60*1000, 5*60*1000, 60*60*1000 });
     
    154154                iter.remove();
    155155                if (expired == null)
    156                     expired = new ArrayList();
     156                    expired = new ArrayList<PooledTunnelCreatorConfig>();
    157157                expired.add(cfg);
    158158            }
     
    285285    public void run() {
    286286        _isRunning = true;
    287         List<TunnelPool> wanted = new ArrayList(MAX_CONCURRENT_BUILDS);
    288         List<TunnelPool> pools = new ArrayList(8);
     287        List<TunnelPool> wanted = new ArrayList<TunnelPool>(MAX_CONCURRENT_BUILDS);
     288        List<TunnelPool> pools = new ArrayList<TunnelPool>(8);
    289289       
    290290        while (_isRunning && !_manager.isShutdown()){
  • router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java

    re61e950 rbacce17  
    9494        int sz = Math.min(MAX_QUEUE, Math.max(MIN_QUEUE, TunnelDispatcher.getShareBandwidth(ctx) * MIN_QUEUE / 48));
    9595        //_inboundBuildMessages = new CoDelBlockingQueue(ctx, "BuildHandler", sz);
    96         _inboundBuildMessages = new LinkedBlockingQueue(sz);
     96        _inboundBuildMessages = new LinkedBlockingQueue<BuildMessageState>(sz);
    9797   
    9898        _context.statManager().createRateStat("tunnel.reject.10", "How often we reject a tunnel probabalistically", "Tunnels", new long[] { 60*1000, 10*60*1000 });
  • router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java

    re61e950 rbacce17  
    2626 */
    2727abstract class BuildRequestor {
    28     private static final List<Integer> ORDER = new ArrayList(TunnelBuildMessage.MAX_RECORD_COUNT);
     28    private static final List<Integer> ORDER = new ArrayList<Integer>(TunnelBuildMessage.MAX_RECORD_COUNT);
    2929    static {
    3030        for (int i = 0; i < TunnelBuildMessage.MAX_RECORD_COUNT; i++)
     
    226226    /** 5 (~2600 bytes) fits nicely in 3 tunnel messages */
    227227    private static final int SHORT_RECORDS = 5;
    228     private static final List<Integer> SHORT_ORDER = new ArrayList(SHORT_RECORDS);
     228    private static final List<Integer> SHORT_ORDER = new ArrayList<Integer>(SHORT_RECORDS);
    229229    static {
    230230        for (int i = 0; i < SHORT_RECORDS; i++)
     
    293293        if (useVariable) {
    294294            msg = new VariableTunnelBuildMessage(ctx, SHORT_RECORDS);
    295             order = new ArrayList(SHORT_ORDER);
     295            order = new ArrayList<Integer>(SHORT_ORDER);
    296296            //if (log.shouldLog(Log.INFO))
    297297            //    log.info("Using new VTBM");
    298298        } else {
    299299            msg = new TunnelBuildMessage(ctx);
    300             order = new ArrayList(ORDER);
     300            order = new ArrayList<Integer>(ORDER);
    301301        }
    302302
  • router/java/src/net/i2p/router/tunnel/pool/ClientPeerSelector.java

    re61e950 rbacce17  
    3535       
    3636            Set<Hash> exclude = getExclude(settings.isInbound(), false);
    37             Set<Hash> matches = new HashSet(length);
     37            Set<Hash> matches = new HashSet<Hash>(length);
    3838            if (length == 1) {
    3939                ctx.profileOrganizer().selectFastPeers(length, exclude, matches, 0);
    4040                matches.remove(ctx.routerHash());
    41                 rv = new ArrayList(matches);
     41                rv = new ArrayList<Hash>(matches);
    4242            } else {
    4343                // build a tunnel using 4 subtiers.
    4444                // For a 2-hop tunnel, the first hop comes from subtiers 0-1 and the last from subtiers 2-3.
    4545                // For a longer tunnels, the first hop comes from subtier 0, the middle from subtiers 2-3, and the last from subtier 1.
    46                 rv = new ArrayList(length + 1);
     46                rv = new ArrayList<Hash>(length + 1);
    4747                // OBEP or IB last hop
    4848                // group 0 or 1 if two hops, otherwise group 0
     
    6262                    if (matches.size() > 1) {
    6363                        // order the middle peers for tunnels >= 4 hops
    64                         List<Hash> ordered = new ArrayList(matches);
     64                        List<Hash> ordered = new ArrayList<Hash>(matches);
    6565                        orderPeers(ordered, settings.getRandomKey());
    6666                        rv.addAll(ordered);
     
    8181            }
    8282        } else {
    83             rv = new ArrayList(1);
     83            rv = new ArrayList<Hash>(1);
    8484        }
    8585       
  • router/java/src/net/i2p/router/tunnel/pool/ExploratoryPeerSelector.java

    re61e950 rbacce17  
    4848        // FloodfillNetworkDatabaseFacade fac = (FloodfillNetworkDatabaseFacade)ctx.netDb();
    4949        // exclude.addAll(fac.getFloodfillPeers());
    50         HashSet matches = new HashSet(length);
     50        HashSet<Hash> matches = new HashSet<Hash>(length);
    5151        boolean exploreHighCap = shouldPickHighCap();
    5252
     
    7777       
    7878        matches.remove(ctx.routerHash());
    79         ArrayList<Hash> rv = new ArrayList(matches);
     79        ArrayList<Hash> rv = new ArrayList<Hash>(matches);
    8080        if (rv.size() > 1)
    8181            orderPeers(rv, settings.getRandomKey());
  • router/java/src/net/i2p/router/tunnel/pool/ParticipatingThrottler.java

    re61e950 rbacce17  
    44import net.i2p.router.RouterContext;
    55import net.i2p.util.ObjectCounter;
    6 import net.i2p.util.SimpleScheduler;
    76import net.i2p.util.SimpleTimer;
    87
     
    4241    ParticipatingThrottler(RouterContext ctx) {
    4342        this.context = ctx;
    44         this.counter = new ObjectCounter();
     43        this.counter = new ObjectCounter<Hash>();
    4544        ctx.simpleScheduler().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
    4645    }
  • router/java/src/net/i2p/router/tunnel/pool/RequestThrottler.java

    re61e950 rbacce17  
    44import net.i2p.router.RouterContext;
    55import net.i2p.util.ObjectCounter;
    6 import net.i2p.util.SimpleScheduler;
    76import net.i2p.util.SimpleTimer;
    87
     
    2726    RequestThrottler(RouterContext ctx) {
    2827        this.context = ctx;
    29         this.counter = new ObjectCounter();
     28        this.counter = new ObjectCounter<Hash>();
    3029        ctx.simpleScheduler().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
    3130    }
  • router/java/src/net/i2p/router/tunnel/pool/TestJob.java

    re61e950 rbacce17  
    128128        _encryptTag = encryptTag;
    129129        SessionKey sentKey = new SessionKey();
    130         Set sentTags = null;
     130        Set<SessionTag> sentTags = null;
    131131        GarlicMessage msg = GarlicMessageBuilder.buildMessage(getContext(), payload, sentKey, sentTags,
    132132                                                              getContext().keyManager().getPublicKey(),
     
    138138            return;
    139139        }
    140         Set<SessionTag> encryptTags = new RemovableSingletonSet(encryptTag);
     140        Set<SessionTag> encryptTags = new RemovableSingletonSet<SessionTag>(encryptTag);
    141141        // Register the single tag with the appropriate SKM
    142142        if (_cfg.isInbound() && !_pool.getSettings().isExploratory()) {
  • router/java/src/net/i2p/router/tunnel/pool/TunnelPeerSelector.java

    re61e950 rbacce17  
    126126       
    127127        Log log = ctx.logManager().getLog(ClientPeerSelector.class);
    128         List<Hash> rv = new ArrayList();
     128        List<Hash> rv = new ArrayList<Hash>();
    129129        StringTokenizer tok = new StringTokenizer(peers, ",");
    130130        while (tok.hasMoreTokens()) {
     
    199199        // Defaults changed to true for inbound only in filterUnreachable below.
    200200
    201         Set<Hash> peers = new HashSet(1);
     201        Set<Hash> peers = new HashSet<Hash>(1);
    202202        peers.addAll(ctx.profileOrganizer().selectPeersRecentlyRejecting());
    203203        peers.addAll(ctx.tunnelManager().selectPeersInTooManyTunnels());
     
    508508
    509509    /** see HashComparator */
    510     protected void orderPeers(List rv, Hash hash) {
     510    protected void orderPeers(List<Hash> rv, Hash hash) {
    511511        if (rv.size() > 1)
    512512            Collections.sort(rv, new HashComparator(hash));
  • router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java

    re61e950 rbacce17  
    1010import java.util.TreeSet;
    1111
    12 import net.i2p.data.DataHelper;
    1312import net.i2p.data.Hash;
    1413import net.i2p.data.Lease;
     
    3029 */
    3130public class TunnelPool {
    32     private final List<PooledTunnelCreatorConfig> _inProgress = new ArrayList();
     31    private final List<PooledTunnelCreatorConfig> _inProgress = new ArrayList<PooledTunnelCreatorConfig>();
    3332    private final RouterContext _context;
    3433    private final Log _log;
     
    5958        _manager = mgr;
    6059        _settings = settings;
    61         _tunnels = new ArrayList(settings.getTotalQuantity());
     60        _tunnels = new ArrayList<TunnelInfo>(settings.getTotalQuantity());
    6261        _peerSelector = sel;
    6362        _expireSkew = _context.random().nextInt(90*1000);
     
    293292    public List<TunnelInfo> listTunnels() {
    294293        synchronized (_tunnels) {
    295             return new ArrayList(_tunnels);
     294            return new ArrayList<TunnelInfo>(_tunnels);
    296295        }
    297296    }
     
    395394
    396395    /** list of tunnelInfo instances of tunnels currently being built */
    397     public List listPending() { synchronized (_inProgress) { return new ArrayList(_inProgress); } }
     396    public List<PooledTunnelCreatorConfig> listPending() { synchronized (_inProgress) { return new ArrayList<PooledTunnelCreatorConfig>(_inProgress); } }
    398397   
    399398    /** duplicate of size(), let's pick one */
     
    714713        TunnelInfo zeroHopTunnel = null;
    715714        Lease zeroHopLease = null;
    716         TreeSet<Lease> leases = new TreeSet(new LeaseComparator());
     715        TreeSet<Lease> leases = new TreeSet<Lease>(new LeaseComparator());
    717716        for (int i = 0; i < _tunnels.size(); i++) {
    718717            TunnelInfo tunnel = _tunnels.get(i);
     
    11071106                            ti.setReused();
    11081107                            len = ti.getLength();
    1109                             peers = new ArrayList(len);
     1108                            peers = new ArrayList<Hash>(len);
    11101109                            // peers list is ordered endpoint first, but cfg.getPeer() is ordered gateway first
    11111110                            for (int i = len - 1; i >= 0; i--) {
  • router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java

    re61e950 rbacce17  
    2424import net.i2p.util.Log;
    2525import net.i2p.util.ObjectCounter;
    26 import net.i2p.util.SimpleScheduler;
    2726import net.i2p.util.SimpleTimer;
    2827
     
    5958        //ctx.inNetMessagePool().registerHandlerJobBuilder(TunnelDataMessage.MESSAGE_TYPE, b);
    6059
    61         _clientInboundPools = new ConcurrentHashMap(4);
    62         _clientOutboundPools = new ConcurrentHashMap(4);
     60        _clientInboundPools = new ConcurrentHashMap<Hash, TunnelPool>(4);
     61        _clientOutboundPools = new ConcurrentHashMap<Hash, TunnelPool>(4);
    6362        _clientPeerSelector = new ClientPeerSelector(ctx);
    6463
     
    320319        if (part <= 0)
    321320            return 0d;
    322         List<TunnelPool> pools = new ArrayList();
     321        List<TunnelPool> pools = new ArrayList<TunnelPool>();
    323322        listPools(pools);
    324323        int count = 0;
     
    563562    /** @return total number of non-fallback expl. + client tunnels */
    564563    private int countTunnelsPerPeer(ObjectCounter<Hash> lc) {
    565         List<TunnelPool> pools = new ArrayList();
     564        List<TunnelPool> pools = new ArrayList<TunnelPool>();
    566565        listPools(pools);
    567566        int tunnelCount = 0;
     
    598597     */
    599598    public Set<Hash> selectPeersInTooManyTunnels() {
    600         ObjectCounter<Hash> lc = new ObjectCounter();
     599        ObjectCounter<Hash> lc = new ObjectCounter<Hash>();
    601600        int tunnelCount = countTunnelsPerPeer(lc);
    602         Set<Hash> rv = new HashSet();
     601        Set<Hash> rv = new HashSet<Hash>();
    603602        if (tunnelCount >= 4 && _context.router().getUptime() > 10*60*1000) {
    604603            int max = _context.getProperty("router.maxTunnelPercentage", DEFAULT_MAX_PCT_TUNNELS);
     
    613612    /** for TunnelRenderer in router console */
    614613    public Map<Hash, TunnelPool> getInboundClientPools() {
    615             return new HashMap(_clientInboundPools);
     614            return new HashMap<Hash, TunnelPool>(_clientInboundPools);
    616615    }
    617616
    618617    /** for TunnelRenderer in router console */
    619618    public Map<Hash, TunnelPool> getOutboundClientPools() {
    620             return new HashMap(_clientOutboundPools);
     619            return new HashMap<Hash, TunnelPool>(_clientOutboundPools);
    621620    }
    622621
  • router/java/src/net/i2p/router/util/CoDelPriorityBlockingQueue.java

    re61e950 rbacce17  
    22
    33import java.util.Collection;
    4 import java.util.Comparator;
    5 import java.util.concurrent.PriorityBlockingQueue;
    6 import java.util.concurrent.TimeUnit;
    74import java.util.concurrent.atomic.AtomicLong;
    85
  • router/java/src/net/i2p/router/util/DecayingBloomFilter.java

    re61e950 rbacce17  
    11package net.i2p.router.util;
    22
    3 import java.util.Random;
    43import java.util.concurrent.TimeUnit;
    54import java.util.concurrent.locks.ReentrantReadWriteLock;
  • router/java/src/net/i2p/router/util/DecayingHashSet.java

    re61e950 rbacce17  
    11package net.i2p.router.util;
    22
    3 import java.util.Random;
    4 
    53import net.i2p.I2PAppContext;
    6 import net.i2p.data.DataHelper;
    74import net.i2p.util.ConcurrentHashSet;
    85import net.i2p.util.Log;
     
    7875        if (entryBytes <= 0 || entryBytes > 32)
    7976            throw new IllegalArgumentException("Bad size");
    80         _current = new ConcurrentHashSet(128);
    81         _previous = new ConcurrentHashSet(128);
     77        _current = new ConcurrentHashSet<ArrayWrapper>(128);
     78        _previous = new ConcurrentHashSet<ArrayWrapper>(128);
    8279        if (_log.shouldLog(Log.DEBUG))
    8380            _log.debug("New DHS " + name + " entryBytes = " + entryBytes +
  • router/java/src/net/i2p/router/util/EventLog.java

    re61e950 rbacce17  
    6060        _context = ctx;
    6161        _file = file;
    62         _cache = new HashMap(4);
    63         _cacheTime = new HashMap(4);
     62        _cache = new HashMap<String, SortedMap<Long, String>>(4);
     63        _cacheTime = new HashMap<String, Long>(4);
    6464    }
    6565
     
    116116            }
    117117        }
    118         rv = new TreeMap();
     118        rv = new TreeMap<Long, String>();
    119119        InputStream in = null;
    120120        try {
  • router/java/src/net/i2p/router/util/RandomIterator.java

    re61e950 rbacce17  
    193193    private static void test(int n) {
    194194        System.out.println("testing with " + n);
    195         List<Integer> l = new ArrayList(n);
     195        List<Integer> l = new ArrayList<Integer>(n);
    196196        for (int i = 0; i < n; i++) {
    197197            l.add(Integer.valueOf(i));
    198198        }
    199         for (Iterator<Integer> iter = new RandomIterator(l); iter.hasNext(); ) {
     199        for (Iterator<Integer> iter = new RandomIterator<Integer>(l); iter.hasNext(); ) {
    200200            System.out.println(iter.next().toString());
    201201        }
  • router/java/src/net/i2p/router/util/RemovableSingletonSet.java

    re61e950 rbacce17  
    22
    33import java.util.AbstractSet;
    4 import java.util.Collection;
    54import java.util.Iterator;
    65import java.util.NoSuchElementException;
    7 import java.util.Set;
    86
    97/**
  • router/java/src/net/i2p/router/util/RouterPasswordManager.java

    re61e950 rbacce17  
    1010import net.i2p.data.DataHelper;
    1111import net.i2p.data.SessionKey;
    12 import net.i2p.router.Router;
    1312import net.i2p.router.RouterContext;
    1413import net.i2p.util.PasswordManager;
     
    7271            }
    7372            // obfuscation of plaintext passwords
    74             Map<String, String> toAdd = new HashMap(5);
    75             List<String> toDel = new ArrayList(5);
     73            Map<String, String> toAdd = new HashMap<String, String>(5);
     74            List<String> toDel = new ArrayList<String>(5);
    7675         /****
    7776            for (int i = 0; i < MIGRATE_FROM.length; i++) {
     
    115114            pfx += '.' + user;
    116115        Map<String, String> toAdd = Collections.singletonMap(pfx + PROP_PW, pw);
    117         List<String> toDel = new ArrayList(4);
     116        List<String> toDel = new ArrayList<String>(4);
    118117        toDel.add(pfx + PROP_B64);
    119118        toDel.add(pfx + PROP_MD5);
     
    139138        String b64 = Base64.encode(DataHelper.getUTF8(pw));
    140139        Map<String, String> toAdd = Collections.singletonMap(pfx + PROP_B64, b64);
    141         List<String> toDel = new ArrayList(4);
     140        List<String> toDel = new ArrayList<String>(4);
    142141        toDel.add(pfx + PROP_PW);
    143142        toDel.add(pfx + PROP_MD5);
     
    168167        String shash = Base64.encode(shashBytes);
    169168        Map<String, String> toAdd = Collections.singletonMap(pfx + PROP_SHASH, shash);
    170         List<String> toDel = new ArrayList(4);
     169        List<String> toDel = new ArrayList<String>(4);
    171170        toDel.add(pfx + PROP_PW);
    172171        toDel.add(pfx + PROP_B64);
     
    187186        if (user != null && user.length() > 0)
    188187            pfx += '.' + user;
    189         List<String> toDel = new ArrayList(5);
     188        List<String> toDel = new ArrayList<String>(5);
    190189        toDel.add(pfx + PROP_PW);
    191190        toDel.add(pfx + PROP_B64);
Note: See TracChangeset for help on using the changeset viewer.