diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ConnThrottler.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ConnThrottler.java index 3853100556d98e2d19aba7bb9643645162a7b1d0..c802a999585859359d463a8c0a053e3bae8e1160 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ConnThrottler.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ConnThrottler.java @@ -52,7 +52,7 @@ class ConnThrottler { public ConnThrottler(int max, int totalMax, long period, long throttlePeriod, long totalThrottlePeriod, String action, Log log) { updateLimits(max, totalMax, period, throttlePeriod, totalThrottlePeriod); - _peers = new HashMap(4); + _peers = new HashMap<Hash, Record>(4); _action = action; _log = log; // for logging @@ -143,7 +143,7 @@ class ConnThrottler { private long until; public Record() { - times = new ArrayList(8); + times = new ArrayList<Long>(8); increment(); } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java index 1cdf6f29e2a2a8db4f231692c25cd17adf4180f8..e48a6bc569759e0b2d389abe6205339a4748d63f 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnel.java @@ -46,7 +46,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.StringTokenizer; @@ -99,10 +98,10 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging { private static final String nocli_args[] = { "-nocli", "-die"}; - private final List<I2PTunnelTask> tasks = new ArrayList(); + private final List<I2PTunnelTask> tasks = new ArrayList<I2PTunnelTask>(); private int next_task_id = 1; - private final Set listeners = new CopyOnWriteArraySet(); + private final Set<ConnectionEventListener> listeners = new CopyOnWriteArraySet<ConnectionEventListener>(); public static void main(String[] args) throws IOException { new I2PTunnel(args); @@ -124,7 +123,7 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging { // as of 0.8.4, include context properties Properties p = _context.getProperties(); _clientOptions = p; - _sessions = new CopyOnWriteArraySet(); + _sessions = new CopyOnWriteArraySet<I2PSession>(); addConnectionEventListener(lsnr); boolean gui = true; @@ -196,7 +195,7 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging { /** @return A copy, non-null */ List<I2PSession> getSessions() { - return new ArrayList(_sessions); + return new ArrayList<I2PSession>(_sessions); } void addSession(I2PSession session) { @@ -1506,7 +1505,7 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging { * */ private void purgetasks(Logging l) { - List<I2PTunnelTask> removed = new ArrayList(); + List<I2PTunnelTask> removed = new ArrayList<I2PTunnelTask>(); for (I2PTunnelTask t : tasks) { if (!t.isOpen()) { _log.debug(getPrefix() + "Purging inactive tunnel: [" + t.getId() + "] " + t.toString()); @@ -1668,8 +1667,8 @@ public class I2PTunnel extends EventDispatcherImpl implements Logging { */ void routerDisconnected() { _log.error(getPrefix() + "Router disconnected - firing notification events"); - for (Iterator iter = listeners.iterator(); iter.hasNext();) { - ConnectionEventListener lsnr = (ConnectionEventListener) iter.next(); + for (Iterator<ConnectionEventListener> iter = listeners.iterator(); iter.hasNext();) { + ConnectionEventListener lsnr = iter.next(); if (lsnr != null) lsnr.routerDisconnected(); } } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java index e99b9a1b6bb330048dfdb894b410ea31bed97a07..8adb79bb6c629dccc846d16ec0c8b67e800c8139 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClient.java @@ -43,13 +43,13 @@ public class I2PTunnelClient extends I2PTunnelClientBase { "Standard client on " + tunnel.listenHost + ':' + localPort, tunnel, pkf); - _addrs = new ArrayList(1); + _addrs = new ArrayList<I2PSocketAddress>(1); if (waitEventValue("openBaseClientResult").equals("error")) { notifyEvent("openClientResult", "error"); return; } - dests = new ArrayList(1); + dests = new ArrayList<Destination>(1); buildAddresses(destinations); if (_addrs.isEmpty()) { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java index 381a113be72f4527f76f9b050c546b07e72a3579..807818d44bf621f0ee8659c6a2fba791ddee73d3 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java @@ -48,7 +48,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna protected long _clientId; protected final Object sockLock = new Object(); // Guards sockMgr and mySockets protected I2PSocketManager sockMgr; // should be final and use a factory. LINT - protected final List<I2PSocket> mySockets = new ArrayList(); + protected final List<I2PSocket> mySockets = new ArrayList<I2PSocket>(); protected boolean _ownDest; protected Destination dest = null; @@ -678,7 +678,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna private static class CustomThreadPoolExecutor extends ThreadPoolExecutor { public CustomThreadPoolExecutor() { super(0, Integer.MAX_VALUE, HANDLER_KEEPALIVE_MS, TimeUnit.MILLISECONDS, - new SynchronousQueue(), new CustomThreadFactory()); + new SynchronousQueue<Runnable>(), new CustomThreadFactory()); } } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java index f05600a9e7cb8c7f4c98d9ae9ca0ac96003d0fac..95221c47710134a18bdc99668fdd9f61be6df33f 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelConnectClient.java @@ -3,7 +3,6 @@ */ package net.i2p.i2ptunnel; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java index 3ab3e6709e6706f1cf35563bb1fad7ad342073f7..a0e9405787c39243753b96d4ad596ce3b401c7a1 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClient.java @@ -3,7 +3,6 @@ */ package net.i2p.i2ptunnel; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -70,7 +69,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelHTTPClientBase implements Runn * Map of host name to base64 destination for destinations collected * via address helper links */ - private final ConcurrentHashMap<String, String> addressHelpers = new ConcurrentHashMap(8); + private final ConcurrentHashMap<String, String> addressHelpers = new ConcurrentHashMap<String, String>(8); /** * Used to protect actions via http://proxy.i2p/ diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java index 3209b6ad2ce04a0c8ce6f357cd47191a7fad5d97..2ae58a39844e5db7eb7ea899867807f3897e35c7 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java @@ -94,10 +94,10 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem EventDispatcher notifyThis, String handlerName, I2PTunnel tunnel) throws IllegalArgumentException { super(localPort, ownDest, l, notifyThis, handlerName, tunnel); - _proxyList = new ArrayList(4); + _proxyList = new ArrayList<String>(4); _proxyNonce = new byte[PROXYNONCE_BYTES]; _context.random().nextBytes(_proxyNonce); - _nonces = new ConcurrentHashMap(); + _nonces = new ConcurrentHashMap<String, NonceInfo>(); } /** @@ -110,10 +110,10 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem I2PTunnel tunnel, EventDispatcher notifyThis, long clientId ) throws IllegalArgumentException { super(localPort, l, sktMgr, tunnel, notifyThis, clientId); - _proxyList = new ArrayList(4); + _proxyList = new ArrayList<String>(4); _proxyNonce = new byte[PROXYNONCE_BYTES]; _context.random().nextBytes(_proxyNonce); - _nonces = new ConcurrentHashMap(); + _nonces = new ConcurrentHashMap<String, NonceInfo>(); } //////// Authorization stuff @@ -409,7 +409,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem * @since 0.9.4 */ private static Map<String, String> parseArgs(String args) { - Map<String, String> rv = new HashMap(8); + Map<String, String> rv = new HashMap<String, String>(8); char data[] = args.toCharArray(); StringBuilder buf = new StringBuilder(32); boolean isQuoted = false; diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java index 5e1b76fc788c618eaff4758e445e84de28182bd5..c74dad2666039b8ba375a5c3478acf77695dbd23 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java @@ -8,7 +8,6 @@ import java.util.List; import java.util.Properties; import java.util.StringTokenizer; -import net.i2p.I2PException; import net.i2p.client.streaming.I2PSocket; import net.i2p.client.streaming.I2PSocketAddress; import net.i2p.data.Base32; @@ -60,7 +59,7 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase { notifyThis, "IRC Client on " + tunnel.listenHost + ':' + localPort, tunnel, pkf); - _addrs = new ArrayList(4); + _addrs = new ArrayList<I2PSocketAddress>(4); buildAddresses(destinations); if (_addrs.isEmpty()) { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java index e8112ad18589d1fedffa8b7449ef81b2cef63861..8d5f4ff4baa13ddfd0cd8b230be6080b14a3dc23 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelServer.java @@ -27,7 +27,6 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.ThreadFactory; -import net.i2p.I2PAppContext; import net.i2p.I2PException; import net.i2p.client.I2PSessionException; import net.i2p.client.streaming.I2PServerSocket; @@ -77,7 +76,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { protected I2PTunnelTask task; protected boolean bidir; private ThreadPoolExecutor _executor; - private final Map<Integer, InetSocketAddress> _socketMap = new ConcurrentHashMap(4); + private final Map<Integer, InetSocketAddress> _socketMap = new ConcurrentHashMap<Integer, InetSocketAddress>(4); /** unused? port should always be specified */ private int DEFAULT_LOCALPORT = 4488; @@ -321,7 +320,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { synchronized (lock) { if (!forced && sockMgr.listSockets().size() != 0) { l.log("There are still active connections!"); - for (Iterator it = sockMgr.listSockets().iterator(); it.hasNext();) { + for (Iterator<I2PSocket> it = sockMgr.listSockets().iterator(); it.hasNext();) { l.log("->" + it.next()); } return false; @@ -473,7 +472,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable { private static class CustomThreadPoolExecutor extends ThreadPoolExecutor { public CustomThreadPoolExecutor(int max, String name) { super(MIN_HANDLERS, max, HANDLER_KEEPALIVE_MS, TimeUnit.MILLISECONDS, - new SynchronousQueue(), new CustomThreadFactory(name)); + new SynchronousQueue<Runnable>(), new CustomThreadFactory(name)); } } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2Ping.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2Ping.java index 3da0ba275a8d4aa726b93148b71a89fe16971103..3ab952a951c614bdaf38717bd2400f243f8764ae 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2Ping.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2Ping.java @@ -123,7 +123,7 @@ public class I2Ping extends I2PTunnelTask implements Runnable { } else if (cmd.startsWith("-l ")) { // ping a list of hosts BufferedReader br = new BufferedReader(new FileReader(cmd.substring(3))); String line; - List pingHandlers = new ArrayList(); + List<PingHandler> pingHandlers = new ArrayList<PingHandler>(); int i = 0; while ((line = br.readLine()) != null) { if (line.startsWith("#")) continue; // comments @@ -137,7 +137,7 @@ public class I2Ping extends I2PTunnelTask implements Runnable { reportTimes = false; } br.close(); - for (Iterator it = pingHandlers.iterator(); it.hasNext();) { + for (Iterator<PingHandler> it = pingHandlers.iterator(); it.hasNext();) { Thread t = (Thread) it.next(); t.join(); } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java index 821d325cdc7056e19f55d17da89e8db5e824aa81..a02de79b2601cb58e91b8d52f81512c970b973fe 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelController.java @@ -4,13 +4,9 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.Random; - import net.i2p.I2PAppContext; import net.i2p.I2PException; import net.i2p.client.I2PClient; @@ -70,7 +66,7 @@ public class TunnelController implements Logging { _tunnel = new I2PTunnel(); _log = I2PAppContext.getGlobalContext().logManager().getLog(TunnelController.class); setConfig(config, prefix); - _messages = new ArrayList(4); + _messages = new ArrayList<String>(4); _running = false; boolean keyOK = true; if (createKey && (getType().endsWith("server") || getPersistentClientKey())) @@ -741,9 +737,9 @@ public class TunnelController implements Logging { * @return list of messages pulled off (each is a String, earliest first) */ public List<String> clearMessages() { - List rv = null; + List<String> rv = null; synchronized (this) { - rv = new ArrayList(_messages); + rv = new ArrayList<String>(_messages); _messages.clear(); } return rv; diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelControllerGroup.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelControllerGroup.java index d20d0be55e0df759b3f7a799352fad76c666c005..a0614dceba20e96f946612932ced03ee12c1a410 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelControllerGroup.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelControllerGroup.java @@ -3,7 +3,6 @@ package net.i2p.i2ptunnel; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -83,14 +82,14 @@ public class TunnelControllerGroup implements ClientApp { _context = context; _mgr = mgr; _log = _context.logManager().getLog(TunnelControllerGroup.class); - _controllers = new ArrayList(); + _controllers = new ArrayList<TunnelController>(); if (args == null || args.length <= 0) _configFile = DEFAULT_CONFIG_FILE; else if (args.length == 1) _configFile = args[0]; else throw new IllegalArgumentException("Usage: TunnelControllerGroup [filename]"); - _sessions = new HashMap(4); + _sessions = new HashMap<I2PSession, Set<TunnelController>>(4); synchronized (TunnelControllerGroup.class) { if (_instance == null) _instance = this; @@ -288,7 +287,7 @@ public class TunnelControllerGroup implements ClientApp { * @return list of messages from the controller as it is stopped */ public synchronized List<String> removeController(TunnelController controller) { - if (controller == null) return new ArrayList(); + if (controller == null) return new ArrayList<String>(); controller.stopTunnel(); List<String> msgs = controller.clearMessages(); _controllers.remove(controller); @@ -302,7 +301,7 @@ public class TunnelControllerGroup implements ClientApp { * @return list of messages the tunnels generate when stopped */ public synchronized List<String> stopAllControllers() { - List<String> msgs = new ArrayList(); + List<String> msgs = new ArrayList<String>(); for (int i = 0; i < _controllers.size(); i++) { TunnelController controller = _controllers.get(i); controller.stopTunnel(); @@ -319,7 +318,7 @@ public class TunnelControllerGroup implements ClientApp { * @return list of messages the tunnels generate when started */ public synchronized List<String> startAllControllers() { - List<String> msgs = new ArrayList(); + List<String> msgs = new ArrayList<String>(); for (int i = 0; i < _controllers.size(); i++) { TunnelController controller = _controllers.get(i); controller.startTunnelBackground(); @@ -337,7 +336,7 @@ public class TunnelControllerGroup implements ClientApp { * @return list of messages the tunnels generate when restarted */ public synchronized List<String> restartAllControllers() { - List<String> msgs = new ArrayList(); + List<String> msgs = new ArrayList<String>(); for (int i = 0; i < _controllers.size(); i++) { TunnelController controller = _controllers.get(i); controller.restartTunnel(); @@ -354,7 +353,7 @@ public class TunnelControllerGroup implements ClientApp { * @return list of messages the tunnels have generated */ public synchronized List<String> clearAllMessages() { - List<String> msgs = new ArrayList(); + List<String> msgs = new ArrayList<String>(); for (int i = 0; i < _controllers.size(); i++) { TunnelController controller = _controllers.get(i); msgs.addAll(controller.clearMessages()); @@ -426,7 +425,7 @@ public class TunnelControllerGroup implements ClientApp { * @return list of TunnelController objects */ public synchronized List<TunnelController> getControllers() { - return new ArrayList(_controllers); + return new ArrayList<TunnelController>(_controllers); } @@ -439,7 +438,7 @@ public class TunnelControllerGroup implements ClientApp { synchronized (_sessions) { Set<TunnelController> owners = _sessions.get(session); if (owners == null) { - owners = new HashSet(2); + owners = new HashSet<TunnelController>(2); _sessions.put(session, owners); } owners.add(controller); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/DCCClientManager.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/DCCClientManager.java index f98f8d0ab4e00258fc09131ada46b62bd1032283..42af9abf220afd602473c5af32392db3d7ba6c54 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/DCCClientManager.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/DCCClientManager.java @@ -55,9 +55,9 @@ public class DCCClientManager extends EventReceiver { _dispatch = dispatch; _tunnel = tunnel; _log = tunnel.getContext().logManager().getLog(DCCClientManager.class); - _incoming = new ConcurrentHashMap(8); - _active = new ConcurrentHashMap(8); - _complete = new ConcurrentHashMap(8); + _incoming = new ConcurrentHashMap<Integer, I2PTunnelDCCClient>(8); + _active = new ConcurrentHashMap<Integer, I2PTunnelDCCClient>(8); + _complete = new ConcurrentHashMap<Integer, I2PTunnelDCCClient>(8); } public boolean close(boolean forced) { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/I2PTunnelDCCServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/I2PTunnelDCCServer.java index 8b4a3e295360ccc34d64097a63ad458315d61ba6..48e53dd57cd74c4b25b88db129e037b0dba1505f 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/I2PTunnelDCCServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/I2PTunnelDCCServer.java @@ -75,10 +75,10 @@ public class I2PTunnelDCCServer extends I2PTunnelServer { public I2PTunnelDCCServer(I2PSocketManager sktMgr, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) { super(DUMMY, 0, sktMgr, l, notifyThis, tunnel); - _outgoing = new ConcurrentHashMap(8); - _active = new ConcurrentHashMap(8); - _resume = new ConcurrentHashMap(8); - _sockList = new CopyOnWriteArrayList(); + _outgoing = new ConcurrentHashMap<Integer, LocalAddress>(8); + _active = new ConcurrentHashMap<Integer, LocalAddress>(8); + _resume = new ConcurrentHashMap<Integer, LocalAddress>(8); + _sockList = new CopyOnWriteArrayList<I2PSocket>(); } /** diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IRCFilter.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IRCFilter.java index f4c7e1ec35cc2ca85baaf9021130398d0b59b27d..a995285f42f5ad3b70cb1680cdfabe0de60c68f4 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IRCFilter.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IRCFilter.java @@ -232,7 +232,7 @@ abstract class IRCFilter { "WALLOPS", "ZLINE" }; - _allowedOutbound = new HashSet(Arrays.asList(allowedCommands)); + _allowedOutbound = new HashSet<String>(Arrays.asList(allowedCommands)); } /************************************************************************* diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/localServer/LocalHTTPServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/localServer/LocalHTTPServer.java index a61082fbfe9157175077f89085e29b58994e132e..1368580c777a6b7137f8e1a1f50bebd0c36a8aab 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/localServer/LocalHTTPServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/localServer/LocalHTTPServer.java @@ -17,7 +17,6 @@ import net.i2p.data.DataFormatException; import net.i2p.data.Destination; import net.i2p.i2ptunnel.I2PTunnelHTTPClient; import net.i2p.util.FileUtil; -import net.i2p.util.Log; import net.i2p.util.Translate; /** @@ -119,7 +118,7 @@ public abstract class LocalHTTPServer { // Parameters are url, host, dest, nonce, and master | router | private. // Do the add and redirect. if (targetRequest.equals("/add")) { - Map<String, String> opts = new HashMap(8); + Map<String, String> opts = new HashMap<String, String>(8); // this only works if all keys are followed by =value StringTokenizer tok = new StringTokenizer(query, "=&;"); while (tok.hasMoreTokens()) { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java index 1cf873966dbac7346f76a705d25632c47310133e..b66d613a8ced9f0545e75fb04e162f351737b179 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/I2PSOCKSTunnel.java @@ -69,13 +69,13 @@ public class I2PSOCKSTunnel extends I2PTunnelClientBase { private void parseOptions() { Properties opts = getTunnel().getClientOptions(); - proxies = new HashMap(1); + proxies = new HashMap<String, List<String>>(1); for (Map.Entry e : opts.entrySet()) { String prop = (String)e.getKey(); if ((!prop.startsWith(PROP_PROXY_PREFIX)) || prop.length() <= PROP_PROXY_PREFIX.length()) continue; String port = prop.substring(PROP_PROXY_PREFIX.length()); - List proxyList = new ArrayList(1); + List<String> proxyList = new ArrayList<String>(1); StringTokenizer tok = new StringTokenizer((String)e.getValue(), ", \t"); while (tok.hasMoreTokens()) { String proxy = tok.nextToken().trim(); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/MultiSink.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/MultiSink.java index 3c63758c138da9b08280a6a7a0cdb69412aceaef..dde5f01b0f57f3ff8db9ca634a025103f3e81c85 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/MultiSink.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/MultiSink.java @@ -10,10 +10,10 @@ import net.i2p.util.Log; * Sends to one of many Sinks * @author zzz modded from streamr/MultiSource */ -public class MultiSink implements Source, Sink { +public class MultiSink<S extends Sink> implements Source, Sink { private static final Log _log = new Log(MultiSink.class); - public MultiSink(Map cache) { + public MultiSink(Map<Destination, S> cache) { this.cache = cache; } @@ -31,5 +31,5 @@ public class MultiSink implements Source, Sink { s.send(from, data); } - private Map<Destination, Sink> cache; + private Map<Destination, S> cache; } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/ReplyTracker.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/ReplyTracker.java index fbdf2939d124bab702c67ecbeae47d3d92456094..6495235a93c9f7eb6152c9731922606d1ae2627d 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/ReplyTracker.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/ReplyTracker.java @@ -10,10 +10,10 @@ import net.i2p.util.Log; * Track who the reply goes to * @author zzz */ -public class ReplyTracker implements Source, Sink { +public class ReplyTracker<S extends Sink> implements Source, Sink { private static final Log _log = new Log(MultiSink.class); - public ReplyTracker(Sink reply, Map cache) { + public ReplyTracker(S reply, Map<Destination, S> cache) { this.reply = reply; this.cache = cache; } @@ -29,7 +29,7 @@ public class ReplyTracker implements Source, Sink { this.sink.send(to, data); } - private Sink reply; - private Map<Destination, Sink> cache; + private S reply; + private Map<Destination, S> cache; private Sink sink; } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKS5Server.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKS5Server.java index edbaa88593f497d79e1d62d4355861506277ce51..c4412346bc2eabd3bcfd7a8d1ff5162d83f2978c 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKS5Server.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKS5Server.java @@ -597,7 +597,7 @@ public class SOCKS5Server extends SOCKSServer { * RFC 1928 isn't clear... maybe not. */ private void handleUDP(DataInputStream in, DataOutputStream out) throws SOCKSException { - List<Integer> ports = new ArrayList(1); + List<Integer> ports = new ArrayList<Integer>(1); synchronized (_startLock) { if (_tunnel == null) { // tunnel options? diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSUDPPort.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSUDPPort.java index b56c9082ffb8d52986e79372c303a2eaee5c0a3c..1f414f1343fab17367b812d2fbfc81dbff4fb26c 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSUDPPort.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSUDPPort.java @@ -26,10 +26,10 @@ import net.i2p.i2ptunnel.udp.*; */ public class SOCKSUDPPort implements Source, Sink { - public SOCKSUDPPort(InetAddress host, int port, Map replyMap) { + public SOCKSUDPPort(InetAddress host, int port, Map<Destination, SOCKSUDPPort> replyMap) { // this passes the host and port from UDPUnwrapper to UDPWrapper - Map cache = new ConcurrentHashMap(4); + Map<Destination, SOCKSHeader> cache = new ConcurrentHashMap<Destination, SOCKSHeader>(4); // rcv from I2P and send to a port this.wrapper = new SOCKSUDPWrapper(cache); @@ -41,7 +41,7 @@ public class SOCKSUDPPort implements Source, Sink { this.udpsource = new UDPSource(sock); this.unwrapper = new SOCKSUDPUnwrapper(cache); this.udpsource.setSink(this.unwrapper); - this.udptracker = new ReplyTracker(this, replyMap); + this.udptracker = new ReplyTracker<SOCKSUDPPort>(this, replyMap); this.unwrapper.setSink(this.udptracker); } @@ -73,5 +73,5 @@ public class SOCKSUDPPort implements Source, Sink { private UDPSource udpsource; private SOCKSUDPWrapper wrapper; private SOCKSUDPUnwrapper unwrapper; - private ReplyTracker udptracker; + private ReplyTracker<SOCKSUDPPort> udptracker; } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSUDPTunnel.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSUDPTunnel.java index 0490a6f0affe0aa9c776bd776b0bc4ac24fcf763..044b000573eea8bb65263a11636705465fe5a9ba 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSUDPTunnel.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/socks/SOCKSUDPTunnel.java @@ -4,7 +4,6 @@ import java.net.InetAddress; import java.util.concurrent.ConcurrentHashMap; import java.util.Iterator; import java.util.Map; - import net.i2p.data.Destination; import net.i2p.i2ptunnel.I2PTunnel; import net.i2p.i2ptunnel.udpTunnel.I2PTunnelUDPClientBase; @@ -33,9 +32,9 @@ public class SOCKSUDPTunnel extends I2PTunnelUDPClientBase { public SOCKSUDPTunnel(I2PTunnel tunnel) { super(null, tunnel, tunnel, tunnel); - this.ports = new ConcurrentHashMap(1); - this.cache = new ConcurrentHashMap(1); - this.demuxer = new MultiSink(this.cache); + this.ports = new ConcurrentHashMap<Integer, SOCKSUDPPort>(1); + this.cache = new ConcurrentHashMap<Destination, SOCKSUDPPort>(1); + this.demuxer = new MultiSink<SOCKSUDPPort>(this.cache); setSink(this.demuxer); } @@ -53,8 +52,8 @@ public class SOCKSUDPTunnel extends I2PTunnelUDPClientBase { SOCKSUDPPort sup = this.ports.remove(port); if (sup != null) sup.stop(); - for (Iterator iter = cache.entrySet().iterator(); iter.hasNext();) { - Map.Entry<Destination, SOCKSUDPPort> e = (Map.Entry) iter.next(); + for (Iterator<Map.Entry<Destination, SOCKSUDPPort>> iter = cache.entrySet().iterator(); iter.hasNext();) { + Map.Entry<Destination, SOCKSUDPPort> e = iter.next(); if (e.getValue() == sup) iter.remove(); } @@ -89,5 +88,5 @@ public class SOCKSUDPTunnel extends I2PTunnelUDPClientBase { private Map<Integer, SOCKSUDPPort> ports; private Map<Destination, SOCKSUDPPort> cache; - private MultiSink demuxer; + private MultiSink<SOCKSUDPPort> demuxer; } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Subscriber.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Subscriber.java index f93d87404ad74a844410b81e762857eb64d9debf..8dfcbb3cb1dbe88f488014df85d75b01270a230d 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Subscriber.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/streamr/Subscriber.java @@ -8,8 +8,6 @@ package net.i2p.i2ptunnel.streamr; // system import java.util.Set; -// i2p -import net.i2p.client.I2PSession; import net.i2p.data.Destination; import net.i2p.i2ptunnel.udp.*; import net.i2p.util.ConcurrentHashSet; diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSource.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSource.java index 0b54747772f425169ef950bf31e0a2058edde98e..04a8bde6a032c48d0baf7d4999ad9f56d4f6c011 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSource.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udp/I2PSource.java @@ -32,7 +32,7 @@ public class I2PSource implements Source, Runnable { this.raw = raw; // create queue - this.queue = new ArrayBlockingQueue(256); + this.queue = new ArrayBlockingQueue<Integer>(256); // create listener this.sess.setSessionListener(new Listener()); diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPClientBase.java index f439019484c21b3410ce8225bbbac19b289e4a2f..20551aabbf555cfdcd0f2d7c4e9ae26701296f7e 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPClientBase.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/udpTunnel/I2PTunnelUDPClientBase.java @@ -5,7 +5,6 @@ package net.i2p.i2ptunnel.udpTunnel; import java.io.ByteArrayOutputStream; import java.io.ByteArrayInputStream; -import java.net.ServerSocket; import java.util.concurrent.atomic.AtomicLong; import net.i2p.I2PAppContext; diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java index 3c3c9e44c793e94c25b18289f7783135f946e9c9..c3160b841980d1c2cce83ccbe53b75517bf8d827 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/EditBean.java @@ -8,11 +8,9 @@ package net.i2p.i2ptunnel.web; * */ -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.StringTokenizer; import java.util.Set; import java.util.TreeMap; @@ -43,9 +41,9 @@ public class EditBean extends IndexBean { TunnelControllerGroup group = TunnelControllerGroup.getInstance(); if (group == null) return false; - List controllers = group.getControllers(); + List<TunnelController> controllers = group.getControllers(); if (controllers.size() > tunnel) { - TunnelController cur = (TunnelController)controllers.get(tunnel); + TunnelController cur = controllers.get(tunnel); if (cur == null) return false; return isClient(cur.getType()); } else { @@ -374,7 +372,7 @@ public class EditBean extends IndexBean { if (opts == null) return ""; boolean isMD5Proxy = "httpclient".equals(tun.getType()) || "connectclient".equals(tun.getType()); - Map<String, String> sorted = new TreeMap(); + Map<String, String> sorted = new TreeMap<String, String>(); for (Map.Entry e : opts.entrySet()) { String key = (String)e.getKey(); if (_noShowSet.contains(key)) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java index 99ff7af5947746d0439519ce40234eb05f26e38a..56be5d3a83731f4a14c9d906227235c6fc48873c 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java @@ -102,7 +102,7 @@ public class IndexBean { /** 3 wasn't enough for some browsers. They are reloading the page for some reason - maybe HEAD? @since 0.8.1 */ private static final int MAX_NONCES = 8; /** store nonces in a static FIFO instead of in System Properties @since 0.8.1 */ - private static final List<String> _nonces = new ArrayList(MAX_NONCES + 1); + private static final List<String> _nonces = new ArrayList<String>(MAX_NONCES + 1); static final String CLIENT_NICKNAME = "shared clients"; public static final String PROP_THEME_NAME = "routerconsole.theme"; @@ -129,8 +129,8 @@ public class IndexBean { _tunnel = -1; _curNonce = "-1"; addNonce(); - _booleanOptions = new ConcurrentHashSet(4); - _otherOptions = new ConcurrentHashMap(4); + _booleanOptions = new ConcurrentHashSet<String>(4); + _otherOptions = new ConcurrentHashMap<String, String>(4); } /** @@ -1224,8 +1224,8 @@ public class IndexBean { "proxyUsername", "proxyPassword" }; - protected static final Set _noShowSet = new HashSet(128); - protected static final Set _nonProxyNoShowSet = new HashSet(4); + protected static final Set<String> _noShowSet = new HashSet<String>(128); + protected static final Set<String> _nonProxyNoShowSet = new HashSet<String>(4); static { _noShowSet.addAll(Arrays.asList(_noShowOpts)); _noShowSet.addAll(Arrays.asList(_booleanClientOpts));