forked from I2P_Developers/i2p.i2p
Core: type arguments, unused imports
This commit is contained in:
@@ -33,7 +33,7 @@ class ClientWriterRunner implements Runnable {
|
||||
public ClientWriterRunner(OutputStream out, I2PSessionImpl session) {
|
||||
_out = new BufferedOutputStream(out);
|
||||
_session = session;
|
||||
_messagesToWrite = new LinkedBlockingQueue(MAX_QUEUE_SIZE);
|
||||
_messagesToWrite = new LinkedBlockingQueue<I2CPMessage>(MAX_QUEUE_SIZE);
|
||||
Thread t = new I2PAppThread(this, "I2CP Client Writer " + __Id.incrementAndGet(), true);
|
||||
t.start();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class I2PSessionDemultiplexer implements I2PSessionMuxedListener {
|
||||
|
||||
public I2PSessionDemultiplexer(I2PAppContext ctx) {
|
||||
_log = ctx.logManager().getLog(I2PSessionDemultiplexer.class);
|
||||
_listeners = new ConcurrentHashMap();
|
||||
_listeners = new ConcurrentHashMap<Integer, I2PSessionMuxedListener>();
|
||||
}
|
||||
|
||||
/** unused */
|
||||
|
||||
@@ -47,7 +47,6 @@ import net.i2p.util.I2PAppThread;
|
||||
import net.i2p.util.I2PSSLSocketFactory;
|
||||
import net.i2p.util.LHMCache;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
import net.i2p.util.VersionComparator;
|
||||
|
||||
@@ -99,7 +98,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
protected Map<Long, MessagePayloadMessage> _availableMessages;
|
||||
|
||||
/** hashes of lookups we are waiting for */
|
||||
protected final LinkedBlockingQueue<LookupWaiter> _pendingLookups = new LinkedBlockingQueue();
|
||||
protected final LinkedBlockingQueue<LookupWaiter> _pendingLookups = new LinkedBlockingQueue<LookupWaiter>();
|
||||
protected final Object _bwReceivedLock = new Object();
|
||||
protected volatile int[] _bwLimits;
|
||||
|
||||
@@ -145,7 +144,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
/**
|
||||
* @since 0.8.9
|
||||
*/
|
||||
private static final Map<Hash, Destination> _lookupCache = new LHMCache(16);
|
||||
private static final Map<Hash, Destination> _lookupCache = new LHMCache<Hash, Destination>(16);
|
||||
|
||||
/** SSL interface (only) @since 0.8.3 */
|
||||
protected static final String PROP_ENABLE_SSL = "i2cp.SSL";
|
||||
@@ -196,7 +195,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
_fastReceive = Boolean.parseBoolean(_options.getProperty(I2PClient.PROP_FAST_RECEIVE));
|
||||
if (hasDest) {
|
||||
_producer = new I2CPMessageProducer(context);
|
||||
_availableMessages = new ConcurrentHashMap();
|
||||
_availableMessages = new ConcurrentHashMap<Long, MessagePayloadMessage>();
|
||||
_myDestination = new Destination();
|
||||
_privateKey = new PrivateKey();
|
||||
_signingPrivateKey = new SigningPrivateKey();
|
||||
@@ -593,7 +592,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
* message. Just copy all unclaimed ones and check 30 seconds later.
|
||||
*/
|
||||
private class VerifyUsage implements SimpleTimer.TimedEvent {
|
||||
private final List<Long> toCheck = new ArrayList();
|
||||
private final List<Long> toCheck = new ArrayList<Long>();
|
||||
|
||||
public void timeReached() {
|
||||
if (isClosed())
|
||||
@@ -623,8 +622,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
private volatile boolean _alive;
|
||||
|
||||
public AvailabilityNotifier() {
|
||||
_pendingIds = new ArrayList(2);
|
||||
_pendingSizes = new ArrayList(2);
|
||||
_pendingIds = new ArrayList<Long>(2);
|
||||
_pendingSizes = new ArrayList<Integer>(2);
|
||||
}
|
||||
|
||||
public void stopNotifying() {
|
||||
|
||||
@@ -63,7 +63,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
*/
|
||||
public I2PSessionImpl2(I2PAppContext ctx, InputStream destKeyStream, Properties options) throws I2PSessionException {
|
||||
super(ctx, destKeyStream, options);
|
||||
_sendingStates = new HashSet(32);
|
||||
_sendingStates = new HashSet<MessageState>(32);
|
||||
// default is BestEffort
|
||||
_noEffort = "none".equals(getOptions().getProperty(I2PClient.PROP_RELIABILITY, "").toLowerCase(Locale.US));
|
||||
|
||||
@@ -449,8 +449,8 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
long inSync = 0;
|
||||
synchronized (_sendingStates) {
|
||||
inSync = _context.clock().now();
|
||||
for (Iterator iter = _sendingStates.iterator(); iter.hasNext();) {
|
||||
state = (MessageState) iter.next();
|
||||
for (Iterator<MessageState> iter = _sendingStates.iterator(); iter.hasNext();) {
|
||||
state = iter.next();
|
||||
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "State " + state.getMessageId() + " / " + state.getNonce());
|
||||
if (state.getNonce() == nonce) {
|
||||
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Found a matching state");
|
||||
@@ -523,8 +523,8 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
if (_sendingStates == null) // only null if overridden by I2PSimpleSession
|
||||
return;
|
||||
synchronized (_sendingStates) {
|
||||
for (Iterator iter = _sendingStates.iterator(); iter.hasNext();) {
|
||||
MessageState state = (MessageState) iter.next();
|
||||
for (Iterator<MessageState> iter = _sendingStates.iterator(); iter.hasNext();) {
|
||||
MessageState state = iter.next();
|
||||
state.cancel();
|
||||
}
|
||||
if (_log.shouldLog(Log.INFO)) _log.info(getPrefix() + "Disconnecting " + _sendingStates.size() + " states");
|
||||
|
||||
@@ -16,7 +16,6 @@ import net.i2p.data.Destination;
|
||||
import net.i2p.data.SessionKey;
|
||||
import net.i2p.data.i2cp.MessagePayloadMessage;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
|
||||
/**
|
||||
* I2PSession with protocol and ports
|
||||
@@ -297,7 +296,7 @@ class I2PSessionMuxedImpl extends I2PSessionImpl2 {
|
||||
private final AtomicBoolean stopping = new AtomicBoolean(false);
|
||||
|
||||
public MuxedAvailabilityNotifier() {
|
||||
_msgs = new LinkedBlockingQueue();
|
||||
_msgs = new LinkedBlockingQueue<MsgData>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,7 +41,7 @@ class MessageState {
|
||||
_log = ctx.logManager().getLog(MessageState.class);
|
||||
_nonce = nonce;
|
||||
_prefix = prefix + "[" + _stateId + "]: ";
|
||||
_receivedStatus = new HashSet();
|
||||
_receivedStatus = new HashSet<Integer>();
|
||||
_created = ctx.clock().now();
|
||||
//ctx.statManager().createRateStat("i2cp.checkStatusTime", "how long it takes to go through the states", "i2cp", new long[] { 60*1000 });
|
||||
}
|
||||
@@ -150,8 +150,8 @@ class MessageState {
|
||||
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug(_prefix + "isSuccess(" + wantedStatus + "): " + _receivedStatus);
|
||||
for (Iterator iter = _receivedStatus.iterator(); iter.hasNext();) {
|
||||
Integer val = (Integer) iter.next();
|
||||
for (Iterator<Integer> iter = _receivedStatus.iterator(); iter.hasNext();) {
|
||||
Integer val = iter.next();
|
||||
int recv = val.intValue();
|
||||
switch (recv) {
|
||||
case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_FAILURE:
|
||||
@@ -210,8 +210,8 @@ class MessageState {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug(_prefix + "isFailure(" + wantedStatus + "): " + _receivedStatus);
|
||||
|
||||
for (Iterator iter = _receivedStatus.iterator(); iter.hasNext();) {
|
||||
Integer val = (Integer) iter.next();
|
||||
for (Iterator<Integer> iter = _receivedStatus.iterator(); iter.hasNext();) {
|
||||
Integer val = iter.next();
|
||||
int recv = val.intValue();
|
||||
switch (recv) {
|
||||
case MessageStatusMessage.STATUS_SEND_BEST_EFFORT_FAILURE:
|
||||
|
||||
@@ -48,7 +48,7 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
|
||||
protected RequestLeaseSetMessageHandler(I2PAppContext context, int messageType) {
|
||||
super(context, messageType);
|
||||
// not clear why there would ever be more than one
|
||||
_existingLeaseSets = new ConcurrentHashMap(4);
|
||||
_existingLeaseSets = new ConcurrentHashMap<Destination, LeaseInfo>(4);
|
||||
}
|
||||
|
||||
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
||||
|
||||
@@ -10,7 +10,6 @@ import java.util.Properties;
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.SimpleScheduler;
|
||||
import net.i2p.util.SimpleTimer;
|
||||
|
||||
/**
|
||||
|
||||
@@ -133,9 +133,9 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
*/
|
||||
public BlockfileNamingService(I2PAppContext context) {
|
||||
super(context);
|
||||
_lists = new ArrayList();
|
||||
_invalid = new ArrayList();
|
||||
_negativeCache = new LHMCache(NEGATIVE_CACHE_SIZE);
|
||||
_lists = new ArrayList<String>();
|
||||
_invalid = new ArrayList<InvalidEntry>();
|
||||
_negativeCache = new LHMCache<String, String>(NEGATIVE_CACHE_SIZE);
|
||||
BlockFile bf = null;
|
||||
RAIFile raf = null;
|
||||
boolean readOnly = false;
|
||||
@@ -468,7 +468,7 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
|
||||
private static List<String> getFilenames(String list) {
|
||||
StringTokenizer tok = new StringTokenizer(list, ",");
|
||||
List<String> rv = new ArrayList(tok.countTokens());
|
||||
List<String> rv = new ArrayList<String>(tok.countTokens());
|
||||
while (tok.hasMoreTokens())
|
||||
rv.add(tok.nextToken());
|
||||
return rv;
|
||||
@@ -847,20 +847,20 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
" limit=" + limit + " skip=" + skip);
|
||||
synchronized(_bf) {
|
||||
if (_isClosed)
|
||||
return Collections.EMPTY_MAP;
|
||||
return Collections.emptyMap();
|
||||
try {
|
||||
SkipList sl = _bf.getIndex(listname, _stringSerializer, _destSerializer);
|
||||
if (sl == null) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("No skiplist found for lookup in " + listname);
|
||||
return Collections.EMPTY_MAP;
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
SkipIterator iter;
|
||||
if (beginWith != null)
|
||||
iter = sl.find(beginWith);
|
||||
else
|
||||
iter = sl.iterator();
|
||||
Map<String, Destination> rv = new HashMap();
|
||||
Map<String, Destination> rv = new HashMap<String, Destination>();
|
||||
for (int i = 0; i < skip && iter.hasNext(); i++) {
|
||||
// don't bother validating here
|
||||
iter.next();
|
||||
@@ -886,10 +886,10 @@ public class BlockfileNamingService extends DummyNamingService {
|
||||
return rv;
|
||||
} catch (IOException ioe) {
|
||||
_log.error("DB lookup error", ioe);
|
||||
return Collections.EMPTY_MAP;
|
||||
return Collections.emptyMap();
|
||||
} catch (RuntimeException re) {
|
||||
_log.error("DB lookup error", re);
|
||||
return Collections.EMPTY_MAP;
|
||||
return Collections.emptyMap();
|
||||
} finally {
|
||||
deleteInvalid();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class DummyNamingService extends NamingService {
|
||||
* Classes should take care to call removeCache() for any entries that
|
||||
* are invalidated.
|
||||
*/
|
||||
private static final Map<String, Destination> _cache = new LHMCache(CACHE_MAX_SIZE);
|
||||
private static final Map<String, Destination> _cache = new LHMCache<String, Destination>(CACHE_MAX_SIZE);
|
||||
|
||||
/**
|
||||
* The naming service should only be constructed and accessed through the
|
||||
|
||||
@@ -50,10 +50,10 @@ public class EepGetNamingService extends DummyNamingService {
|
||||
super(context);
|
||||
}
|
||||
|
||||
private List getURLs() {
|
||||
private List<String> getURLs() {
|
||||
String list = _context.getProperty(PROP_EEPGET_LIST, DEFAULT_EEPGET_LIST);
|
||||
StringTokenizer tok = new StringTokenizer(list, ",");
|
||||
List rv = new ArrayList(tok.countTokens());
|
||||
List<String> rv = new ArrayList<String>(tok.countTokens());
|
||||
while (tok.hasMoreTokens())
|
||||
rv.add(tok.nextToken());
|
||||
return rv;
|
||||
@@ -70,13 +70,13 @@ public class EepGetNamingService extends DummyNamingService {
|
||||
if (hostname.length() == BASE32_HASH_LENGTH + 8 && hostname.endsWith(".b32.i2p"))
|
||||
return null;
|
||||
|
||||
List URLs = getURLs();
|
||||
List<String> URLs = getURLs();
|
||||
if (URLs.isEmpty())
|
||||
return null;
|
||||
|
||||
// prevent lookup loops - this cannot be the only lookup service
|
||||
for (int i = 0; i < URLs.size(); i++) {
|
||||
String url = (String)URLs.get(i);
|
||||
String url = URLs.get(i);
|
||||
if (url.startsWith("http://" + hostname + "/")) {
|
||||
_log.error("Lookup loop: " + hostname);
|
||||
return null;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class HostsTxtNamingService extends MetaNamingService {
|
||||
private List<String> getFilenames() {
|
||||
String list = _context.getProperty(PROP_HOSTS_FILE, DEFAULT_HOSTS_FILE);
|
||||
StringTokenizer tok = new StringTokenizer(list, ",");
|
||||
List<String> rv = new ArrayList(tok.countTokens());
|
||||
List<String> rv = new ArrayList<String>(tok.countTokens());
|
||||
while (tok.hasMoreTokens())
|
||||
rv.add(tok.nextToken());
|
||||
return rv;
|
||||
@@ -97,6 +97,6 @@ public class HostsTxtNamingService extends MetaNamingService {
|
||||
if (name.equals(file) || name.endsWith('/' + file) || name.endsWith('\\' + file))
|
||||
return ns.getNames(options);
|
||||
}
|
||||
return new HashSet(0);
|
||||
return new HashSet<String>(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class MetaNamingService extends DummyNamingService {
|
||||
super(context);
|
||||
String list = _context.getProperty(PROP_NAME_SERVICES, DEFAULT_NAME_SERVICES);
|
||||
StringTokenizer tok = new StringTokenizer(list, ",");
|
||||
_services = new CopyOnWriteArrayList();
|
||||
_services = new CopyOnWriteArrayList<NamingService>();
|
||||
while (tok.hasMoreTokens()) {
|
||||
try {
|
||||
Class cls = Class.forName(tok.nextToken());
|
||||
@@ -53,7 +53,7 @@ public class MetaNamingService extends DummyNamingService {
|
||||
*/
|
||||
public MetaNamingService(I2PAppContext context, List<NamingService> services) {
|
||||
super(context);
|
||||
_services = new CopyOnWriteArrayList();
|
||||
_services = new CopyOnWriteArrayList<NamingService>();
|
||||
if (services != null) {
|
||||
for (NamingService ns : services) {
|
||||
addNamingService(ns, false);
|
||||
@@ -172,7 +172,7 @@ public class MetaNamingService extends DummyNamingService {
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Destination> getEntries(Properties options) {
|
||||
Map<String, Destination> rv = new HashMap();
|
||||
Map<String, Destination> rv = new HashMap<String, Destination>();
|
||||
for (NamingService ns : _services) {
|
||||
rv.putAll(ns.getEntries(options));
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public class MetaNamingService extends DummyNamingService {
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getNames(Properties options) {
|
||||
Set<String> rv = new HashSet();
|
||||
Set<String> rv = new HashSet<String>();
|
||||
for (NamingService ns : _services) {
|
||||
rv.addAll(ns.getNames(options));
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ public abstract class NamingService {
|
||||
protected NamingService(I2PAppContext context) {
|
||||
_context = context;
|
||||
_log = context.logManager().getLog(getClass());
|
||||
_listeners = new CopyOnWriteArraySet();
|
||||
_updaters = new CopyOnWriteArraySet();
|
||||
_listeners = new CopyOnWriteArraySet<NamingServiceListener>();
|
||||
_updaters = new CopyOnWriteArraySet<NamingServiceUpdater>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,7 +226,7 @@ public abstract class NamingService {
|
||||
* @since 0.8.7
|
||||
*/
|
||||
public Map<String, Destination> getEntries(Properties options) {
|
||||
return Collections.EMPTY_MAP;
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,7 +242,7 @@ public abstract class NamingService {
|
||||
* @since 0.8.7
|
||||
*/
|
||||
public Map<String, String> getBase64Entries(Properties options) {
|
||||
return Collections.EMPTY_MAP;
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,7 +263,7 @@ public abstract class NamingService {
|
||||
* @since 0.8.7
|
||||
*/
|
||||
public Set<String> getNames(Properties options) {
|
||||
return Collections.EMPTY_SET;
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -308,7 +308,7 @@ public class SingleFileNamingService extends NamingService {
|
||||
@Override
|
||||
public Map<String, Destination> getEntries(Properties options) {
|
||||
if (!_file.exists())
|
||||
return Collections.EMPTY_MAP;
|
||||
return Collections.emptyMap();
|
||||
String searchOpt = null;
|
||||
String startsWith = null;
|
||||
if (options != null) {
|
||||
@@ -322,7 +322,7 @@ public class SingleFileNamingService extends NamingService {
|
||||
try {
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(_file), "UTF-8"), 16*1024);
|
||||
String line = null;
|
||||
Map<String, Destination> rv = new HashMap();
|
||||
Map<String, Destination> rv = new HashMap<String, Destination>();
|
||||
while ( (line = in.readLine()) != null) {
|
||||
if (line.length() <= 0)
|
||||
continue;
|
||||
@@ -357,7 +357,7 @@ public class SingleFileNamingService extends NamingService {
|
||||
return rv;
|
||||
} catch (IOException ioe) {
|
||||
_log.error("getEntries error", ioe);
|
||||
return Collections.EMPTY_MAP;
|
||||
return Collections.emptyMap();
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
releaseReadLock();
|
||||
@@ -370,13 +370,13 @@ public class SingleFileNamingService extends NamingService {
|
||||
*/
|
||||
public Set<String> getNames(Properties options) {
|
||||
if (!_file.exists())
|
||||
return Collections.EMPTY_SET;
|
||||
return Collections.emptySet();
|
||||
BufferedReader in = null;
|
||||
getReadLock();
|
||||
try {
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(_file), "UTF-8"), 16*1024);
|
||||
String line = null;
|
||||
Set<String> rv = new HashSet();
|
||||
Set<String> rv = new HashSet<String>();
|
||||
while ( (line = in.readLine()) != null) {
|
||||
if (line.length() <= 0)
|
||||
continue;
|
||||
@@ -391,7 +391,7 @@ public class SingleFileNamingService extends NamingService {
|
||||
return rv;
|
||||
} catch (IOException ioe) {
|
||||
_log.error("getNames error", ioe);
|
||||
return Collections.EMPTY_SET;
|
||||
return Collections.emptySet();
|
||||
} finally {
|
||||
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||
releaseReadLock();
|
||||
|
||||
Reference in New Issue
Block a user