Core: type arguments, unused imports

This commit is contained in:
str4d
2013-11-20 04:02:28 +00:00
parent bacce17990
commit 89dcceefee
76 changed files with 174 additions and 221 deletions

View File

@ -201,7 +201,7 @@ public class I2PAppContext {
_overrideProps = new I2PProperties();
if (envProps != null)
_overrideProps.putAll(envProps);
_shutdownTasks = new ConcurrentHashSet(32);
_shutdownTasks = new ConcurrentHashSet<Runnable>(32);
_portMapper = new PortMapper(this);
/*
@ -535,7 +535,7 @@ public class I2PAppContext {
*
* @return set of Strings containing the names of defined system properties
*/
public Set getPropertyNames() {
public Set<String> getPropertyNames() {
// clone to avoid ConcurrentModificationException
Set names = new HashSet(((Properties) System.getProperties().clone()).keySet());
if (_overrideProps != null)

View File

@ -1,7 +1,5 @@
package net.i2p.app;
import net.i2p.I2PAppContext;
/**
* If a class started via clients.config implements this interface,
* it will be used to manage the client, instead of starting with main()

View File

@ -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();
}

View File

@ -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 */

View File

@ -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() {

View File

@ -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");

View File

@ -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

View File

@ -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:

View File

@ -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) {

View File

@ -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;
/**

View File

@ -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();
}

View File

@ -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

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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));
}

View File

@ -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();
}
/**

View File

@ -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();

View File

@ -4,11 +4,8 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.security.GeneralSecurityException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.Locale;

View File

@ -18,7 +18,6 @@ import java.security.InvalidKeyException;
//import javax.crypto.spec.SecretKeySpec;
import net.i2p.I2PAppContext;
import net.i2p.data.ByteArray;
import net.i2p.data.DataHelper;
import net.i2p.data.SessionKey;
import net.i2p.util.Log;

View File

@ -26,7 +26,7 @@ public final class CryptixAESKeyCache {
* @deprecated unused, keys are now cached in the SessionKey objects
*/
public CryptixAESKeyCache() {
_availableKeys = new LinkedBlockingQueue(MAX_KEYS);
_availableKeys = new LinkedBlockingQueue<KeyCacheEntry>(MAX_KEYS);
}
/**

View File

@ -29,13 +29,11 @@ package net.i2p.crypto;
* POSSIBILITY OF SUCH DAMAGE.
*/
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.security.GeneralSecurityException;
import java.security.Key;
import java.security.KeyFactory;
import java.security.MessageDigest;
import java.security.PrivateKey;
import java.security.PublicKey;

View File

@ -3,11 +3,8 @@ package net.i2p.crypto;
import java.lang.reflect.Constructor;
import java.math.BigInteger;
import java.security.AlgorithmParameters;
import java.security.AlgorithmParameterGenerator;
import java.security.GeneralSecurityException;
import java.security.Provider;
import java.security.Security;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.ECField;
import java.security.spec.ECFieldFp;
import java.security.spec.ECGenParameterSpec;

View File

@ -17,7 +17,6 @@ import java.util.List;
import java.util.Set;
import net.i2p.I2PAppContext;
import net.i2p.data.Base64;
import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
import net.i2p.data.Hash;
@ -100,7 +99,7 @@ public class ElGamalAESEngine {
SessionKey key = keyManager.consumeTag(st);
SessionKey foundKey = new SessionKey();
SessionKey usedKey = new SessionKey();
Set foundTags = new HashSet();
Set<SessionTag> foundTags = new HashSet<SessionTag>();
byte decrypted[] = null;
boolean wasExisting = false;
if (key != null) {
@ -170,7 +169,7 @@ public class ElGamalAESEngine {
*
* @return null if decryption fails
*/
private byte[] decryptNewSession(byte data[], PrivateKey targetPrivateKey, Set foundTags, SessionKey usedKey,
private byte[] decryptNewSession(byte data[], PrivateKey targetPrivateKey, Set<SessionTag> foundTags, SessionKey usedKey,
SessionKey foundKey) throws DataFormatException {
if (data == null) {
//if (_log.shouldLog(Log.WARN)) _log.warn("Data is null, unable to decrypt new session");
@ -246,7 +245,7 @@ public class ElGamalAESEngine {
* @return decrypted data or null on failure
*
*/
private byte[] decryptExistingSession(byte data[], SessionKey key, PrivateKey targetPrivateKey, Set foundTags,
private byte[] decryptExistingSession(byte data[], SessionKey key, PrivateKey targetPrivateKey, Set<SessionTag> foundTags,
SessionKey usedKey, SessionKey foundKey) throws DataFormatException {
byte preIV[] = SimpleByteCache.acquire(32);
System.arraycopy(data, 0, preIV, 0, 32);
@ -315,7 +314,7 @@ public class ElGamalAESEngine {
* Note: package private for ElGamalTest.testAES()
*/
byte[] decryptAESBlock(byte encrypted[], int offset, int encryptedLen, SessionKey key, byte iv[],
byte sentTag[], Set foundTags, SessionKey foundKey) throws DataFormatException {
byte sentTag[], Set<SessionTag> foundTags, SessionKey foundKey) throws DataFormatException {
//_log.debug("iv for decryption: " + DataHelper.toString(iv, 16));
//_log.debug("decrypting AES block. encr.length = " + (encrypted == null? -1 : encrypted.length) + " sentTag: " + DataHelper.toString(sentTag, 32));
byte decrypted[] = new byte[encryptedLen];
@ -324,13 +323,13 @@ public class ElGamalAESEngine {
//_log.debug("Hash of entire aes block after decryption: \n" + DataHelper.toString(h.getData(), 32));
try {
SessionKey newKey = null;
List tags = null;
List<SessionTag> tags = null;
//ByteArrayInputStream bais = new ByteArrayInputStream(decrypted);
int cur = 0;
long numTags = DataHelper.fromLong(decrypted, cur, 2);
if ((numTags < 0) || (numTags > MAX_TAGS_RECEIVED)) throw new Exception("Invalid number of session tags");
if (numTags > 0) tags = new ArrayList((int)numTags);
if (numTags > 0) tags = new ArrayList<SessionTag>((int)numTags);
cur += 2;
//_log.debug("# tags: " + numTags);
if (numTags * SessionTag.BYTE_LENGTH > decrypted.length - 2) {
@ -404,7 +403,7 @@ public class ElGamalAESEngine {
*
* Unused externally, only called by below (i.e. newKey is always null)
*/
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery,
SessionTag currentTag, SessionKey newKey, long paddedSize) {
if (currentTag == null) {
if (_log.shouldLog(Log.INFO))
@ -450,7 +449,7 @@ public class ElGamalAESEngine {
* body's real size, no bytes are appended but the body is not truncated)
*
*/
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery,
SessionTag currentTag, long paddedSize) {
return encrypt(data, target, key, tagsForDelivery, currentTag, null, paddedSize);
}
@ -464,7 +463,7 @@ public class ElGamalAESEngine {
* 200 max enforced at receiver
* @deprecated unused
*/
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery, long paddedSize) {
public byte[] encrypt(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery, long paddedSize) {
return encrypt(data, target, key, tagsForDelivery, null, null, paddedSize);
}
@ -502,7 +501,7 @@ public class ElGamalAESEngine {
* @param tagsForDelivery session tags to be associated with the key or null;
* 200 max enforced at receiver
*/
private byte[] encryptNewSession(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
private byte[] encryptNewSession(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery,
SessionKey newKey, long paddedSize) {
//_log.debug("Encrypting to a NEW session");
byte elgSrcData[] = new byte[SessionKey.KEYSIZE_BYTES+32+158];
@ -571,7 +570,7 @@ public class ElGamalAESEngine {
* @param tagsForDelivery session tags to be associated with the key or null;
* 200 max enforced at receiver
*/
private byte[] encryptExistingSession(byte data[], PublicKey target, SessionKey key, Set tagsForDelivery,
private byte[] encryptExistingSession(byte data[], PublicKey target, SessionKey key, Set<SessionTag> tagsForDelivery,
SessionTag currentTag, SessionKey newKey, long paddedSize) {
//_log.debug("Encrypting to an EXISTING session");
byte rawTag[] = currentTag.getData();
@ -629,7 +628,7 @@ public class ElGamalAESEngine {
* @param tagsForDelivery session tags to be associated with the key or null;
* 200 max enforced at receiver
*/
final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set tagsForDelivery, SessionKey newKey,
final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set<SessionTag> tagsForDelivery, SessionKey newKey,
long paddedSize) {
return encryptAESBlock(data, key, iv, tagsForDelivery, newKey, paddedSize, 0);
}
@ -639,11 +638,11 @@ public class ElGamalAESEngine {
* @param tagsForDelivery session tags to be associated with the key or null;
* 200 max enforced at receiver
*/
private final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set tagsForDelivery, SessionKey newKey,
private final byte[] encryptAESBlock(byte data[], SessionKey key, byte[] iv, Set<SessionTag> tagsForDelivery, SessionKey newKey,
long paddedSize, int prefixBytes) {
//_log.debug("iv for encryption: " + DataHelper.toString(iv, 16));
//_log.debug("Encrypting AES");
if (tagsForDelivery == null) tagsForDelivery = Collections.EMPTY_SET;
if (tagsForDelivery == null) tagsForDelivery = Collections.emptySet();
int size = 2 // sizeof(tags)
+ SessionTag.BYTE_LENGTH*tagsForDelivery.size()
+ 4 // payload length
@ -657,8 +656,8 @@ public class ElGamalAESEngine {
int cur = prefixBytes;
DataHelper.toLong(aesData, cur, 2, tagsForDelivery.size());
cur += 2;
for (Iterator iter = tagsForDelivery.iterator(); iter.hasNext();) {
SessionTag tag = (SessionTag) iter.next();
for (Iterator<SessionTag> iter = tagsForDelivery.iterator(); iter.hasNext();) {
SessionTag tag = iter.next();
System.arraycopy(tag.getData(), 0, aesData, cur, SessionTag.BYTE_LENGTH);
cur += SessionTag.BYTE_LENGTH;
}

View File

@ -49,7 +49,7 @@ public class HMACGenerator {
* @param context unused
*/
public HMACGenerator(I2PAppContext context) {
_available = new LinkedBlockingQueue(32);
_available = new LinkedBlockingQueue<I2PHMac>(32);
}
/**

View File

@ -9,8 +9,6 @@ import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateExpiredException;
import java.security.cert.CertificateNotYetValidException;
import java.security.cert.CertificateFactory;
@ -20,7 +18,6 @@ import java.util.Locale;
import net.i2p.I2PAppContext;
import net.i2p.data.Base32;
import net.i2p.data.DataHelper;
import net.i2p.util.Log;
import net.i2p.util.SecureDirectory;
import net.i2p.util.SecureFileOutputStream;

View File

@ -35,7 +35,7 @@ public final class SHA256Generator {
* @param context unused
*/
public SHA256Generator(I2PAppContext context) {
_digests = new LinkedBlockingQueue(32);
_digests = new LinkedBlockingQueue<MessageDigest>(32);
}
public static final SHA256Generator getInstance() {

View File

@ -30,11 +30,7 @@ import net.i2p.I2PAppContext;
import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
import net.i2p.data.Signature;
import net.i2p.data.SigningPrivateKey;
import net.i2p.data.SigningPublicKey;
import net.i2p.data.SimpleDataStructure;
import net.i2p.util.HexDump;
import net.i2p.util.SecureFileOutputStream;
/**
* Succesor to the ".sud" format used in TrustedUpdate.
@ -441,7 +437,7 @@ public class SU3File {
*/
public static void main(String[] args) {
boolean ok = false;
List<String> a = new ArrayList(Arrays.asList(args));
List<String> a = new ArrayList<String>(Arrays.asList(args));
try {
// defaults
String stype = null;

View File

@ -21,14 +21,10 @@ import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.DSAPrivateKeySpec;
import java.security.spec.DSAPublicKeySpec;
import java.security.spec.ECField;
import java.security.spec.ECFieldFp;
import java.security.spec.ECGenParameterSpec;
import java.security.spec.ECParameterSpec;
import java.security.spec.ECPrivateKeySpec;
import java.security.spec.ECPublicKeySpec;
import java.security.spec.ECPoint;
import java.security.spec.EllipticCurve;
import java.security.spec.KeySpec;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAKeyGenParameterSpec;
@ -51,8 +47,8 @@ import net.i2p.util.NativeBigInteger;
*/
class SigUtil {
private static final Map<SigningPublicKey, ECPublicKey> _pubkeyCache = new LHMCache(64);
private static final Map<SigningPrivateKey, ECPrivateKey> _privkeyCache = new LHMCache(16);
private static final Map<SigningPublicKey, ECPublicKey> _pubkeyCache = new LHMCache<SigningPublicKey, ECPublicKey>(64);
private static final Map<SigningPrivateKey, ECPrivateKey> _privkeyCache = new LHMCache<SigningPrivateKey, ECPrivateKey>(16);
private SigUtil() {}

View File

@ -19,7 +19,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicInteger;
@ -30,7 +29,6 @@ import net.i2p.data.PublicKey;
import net.i2p.data.SessionKey;
import net.i2p.data.SessionTag;
import net.i2p.util.Log;
import net.i2p.util.SimpleScheduler;
import net.i2p.util.SimpleTimer;
/**
@ -177,8 +175,8 @@ public class TransientSessionKeyManager extends SessionKeyManager {
_lowThreshold = lowThreshold;
_log = context.logManager().getLog(TransientSessionKeyManager.class);
_context = context;
_outboundSessions = new HashMap(64);
_inboundTagSets = new HashMap(128);
_outboundSessions = new HashMap<PublicKey, OutboundSession>(64);
_inboundTagSets = new HashMap<SessionTag, TagSet>(128);
context.statManager().createRateStat("crypto.sessionTagsExpired", "How many tags/sessions are expired?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 });
context.statManager().createRateStat("crypto.sessionTagsRemaining", "How many tags/sessions are remaining after a cleanup?", "Encryption", new long[] { 10*60*1000, 60*60*1000, 3*60*60*1000 });
_alive = true;
@ -212,14 +210,14 @@ public class TransientSessionKeyManager extends SessionKeyManager {
/** TagSet - used only by HTML */
private Set<TagSet> getInboundTagSets() {
synchronized (_inboundTagSets) {
return new HashSet(_inboundTagSets.values());
return new HashSet<TagSet>(_inboundTagSets.values());
}
}
/** OutboundSession - used only by HTML */
private Set<OutboundSession> getOutboundSessions() {
synchronized (_outboundSessions) {
return new HashSet(_outboundSessions.values());
return new HashSet<OutboundSession>(_outboundSessions.values());
}
}
@ -586,7 +584,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
int tags = 0;
int toRemove = overage * 2;
_log.log(Log.CRIT, "TOO MANY SESSION TAGS! Starting cleanup, overage = " + overage);
List<TagSet> removed = new ArrayList(toRemove);
List<TagSet> removed = new ArrayList<TagSet>(toRemove);
synchronized (_inboundTagSets) {
for (TagSet set : _inboundTagSets.values()) {
int size = set.getTags().size();
@ -717,12 +715,12 @@ public class TransientSessionKeyManager extends SessionKeyManager {
buf.append("<h2>Inbound sessions</h2>" +
"<table>");
Set<TagSet> inbound = getInboundTagSets();
Map<SessionKey, Set<TagSet>> inboundSets = new HashMap(inbound.size());
Map<SessionKey, Set<TagSet>> inboundSets = new HashMap<SessionKey, Set<TagSet>>(inbound.size());
// Build a map of the inbound tag sets, grouped by SessionKey
for (TagSet ts : inbound) {
Set<TagSet> sets = inboundSets.get(ts.getAssociatedKey());
if (sets == null) {
sets = new HashSet();
sets = new HashSet<TagSet>();
inboundSets.put(ts.getAssociatedKey(), sets);
}
sets.add(ts);
@ -731,7 +729,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
long now = _context.clock().now();
for (Map.Entry<SessionKey, Set<TagSet>> e : inboundSets.entrySet()) {
SessionKey skey = e.getKey();
Set<TagSet> sets = new TreeSet(new TagSetComparator());
Set<TagSet> sets = new TreeSet<TagSet>(new TagSetComparator());
sets.addAll(e.getValue());
buf.append("<tr><td><b>Session key</b>: ").append(skey.toBase64()).append("</td>" +
"<td><b># Sets:</b> ").append(sets.size()).append("</td></tr>" +
@ -761,7 +759,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
Set<OutboundSession> outbound = getOutboundSessions();
for (Iterator<OutboundSession> iter = outbound.iterator(); iter.hasNext();) {
OutboundSession sess = iter.next();
Set<TagSet> sets = new TreeSet(new TagSetComparator());
Set<TagSet> sets = new TreeSet<TagSet>(new TagSetComparator());
sets.addAll(sess.getTagSets());
buf.append("<tr><td><b>Target public key:</b> ").append(toString(sess.getTarget())).append("<br>" +
"<b>Established:</b> ").append(DataHelper.formatDuration2(now - sess.getEstablishedDate())).append(" ago<br>" +
@ -850,7 +848,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
private static final int MAX_FAILS = 2;
public OutboundSession(I2PAppContext ctx, Log log, PublicKey target) {
this(ctx, log, target, null, ctx.clock().now(), ctx.clock().now(), new ArrayList());
this(ctx, log, target, null, ctx.clock().now(), ctx.clock().now(), new ArrayList<TagSet>());
}
OutboundSession(I2PAppContext ctx, Log log, PublicKey target, SessionKey curKey,
@ -862,7 +860,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
_established = established;
_lastUsed = lastUsed;
_unackedTagSets = tagSets;
_tagSets = new ArrayList();
_tagSets = new ArrayList<TagSet>();
}
/**
@ -873,7 +871,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
List<TagSet> getTagSets() {
List<TagSet> rv;
synchronized (_tagSets) {
rv = new ArrayList(_unackedTagSets);
rv = new ArrayList<TagSet>(_unackedTagSets);
rv.addAll(_tagSets);
}
return rv;

View File

@ -161,7 +161,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
/** 172 */
private static final int KEYSIZE_B64_BYTES = 2 + (SigningPublicKey.KEYSIZE_BYTES * 4 / 3);
private static final Map<String, String> DEFAULT_KEYS = new HashMap(4);
private static final Map<String, String> DEFAULT_KEYS = new HashMap<String, String>(4);
static {
//DEFAULT_KEYS.put(DEFAULT_TRUSTED_KEY, "jrandom@mail.i2p");
DEFAULT_KEYS.put(DEFAULT_TRUSTED_KEY2, "zzz@mail.i2p");
@ -187,7 +187,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
public TrustedUpdate(I2PAppContext context) {
_context = context;
_log = _context.logManager().getLog(TrustedUpdate.class);
_trustedKeys = new HashMap(4);
_trustedKeys = new HashMap<SigningPublicKey, String>(4);
String propertyTrustedKeys = context.getProperty(PROP_TRUSTED_KEYS);

View File

@ -64,7 +64,7 @@ class YKGenerator {
MAX_NUM_BUILDERS = ctx.getProperty(PROP_YK_PRECALC_MAX, defaultMax);
CALC_DELAY = ctx.getProperty(PROP_YK_PRECALC_DELAY, DEFAULT_YK_PRECALC_DELAY);
_values = new LinkedBlockingQueue(MAX_NUM_BUILDERS);
_values = new LinkedBlockingQueue<BigInteger[]>(MAX_NUM_BUILDERS);
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("ElGamal YK Precalc (minimum: " + MIN_NUM_BUILDERS + " max: " + MAX_NUM_BUILDERS + ", delay: "

View File

@ -92,7 +92,7 @@ public class DataHelper {
"version", "created", "upgraded", "lists",
"a", "s",
};
_propertiesKeyCache = new HashMap(keys.length);
_propertiesKeyCache = new HashMap<String, String>(keys.length);
for (int i = 0; i < keys.length; i++) {
_propertiesKeyCache.put(keys[i], keys[i]);
}
@ -1394,7 +1394,7 @@ public class DataHelper {
* @return a new list
*/
public static List<? extends DataStructure> sortStructures(Collection<? extends DataStructure> dataStructures) {
if (dataStructures == null) return Collections.EMPTY_LIST;
if (dataStructures == null) return Collections.emptyList();
// This used to use Hash.toString(), which is insane, since a change to toString()
// would break the whole network. Now use Hash.toBase64().
@ -1409,7 +1409,7 @@ public class DataHelper {
//for (DataStructure struct : tm.values()) {
// rv.add(struct);
//}
ArrayList<DataStructure> rv = new ArrayList(dataStructures);
ArrayList<DataStructure> rv = new ArrayList<DataStructure>(dataStructures);
sortStructureList(rv);
return rv;
}

View File

@ -13,7 +13,6 @@ import java.io.InputStream;
import java.io.IOException;
import java.util.Map;
import net.i2p.I2PAppContext;
import net.i2p.util.LHMCache;
import net.i2p.util.SystemVersion;
@ -48,7 +47,7 @@ public class Destination extends KeysAndCert {
// I2PAppContext.getGlobalContext().statManager().createRateStat("DestCache", "Hit rate", "Router", new long[] { 10*60*1000 });
}
private static final Map<SigningPublicKey, Destination> _cache = new LHMCache(CACHE_SIZE);
private static final Map<SigningPublicKey, Destination> _cache = new LHMCache<SigningPublicKey, Destination>(CACHE_SIZE);
/**
* Pull from cache or return new

View File

@ -26,7 +26,7 @@ public class Hash extends SimpleDataStructure {
public final static Hash FAKE_HASH = new Hash(new byte[HASH_LENGTH]);
private static final int CACHE_SIZE = 2048;
private static final SDSCache<Hash> _cache = new SDSCache(Hash.class, HASH_LENGTH, CACHE_SIZE);
private static final SDSCache<Hash> _cache = new SDSCache<Hash>(Hash.class, HASH_LENGTH, CACHE_SIZE);
/**
* Pull from cache or return new

View File

@ -93,7 +93,7 @@ public class LeaseSet extends DatabaseEntry {
private static final int OLD_MAX_LEASES = 6;
public LeaseSet() {
_leases = new ArrayList(OLD_MAX_LEASES);
_leases = new ArrayList<Lease>(OLD_MAX_LEASES);
_firstExpiration = Long.MAX_VALUE;
}
@ -290,8 +290,8 @@ public class LeaseSet extends DatabaseEntry {
_signingKey.writeBytes(out);
DataHelper.writeLong(out, 1, _leases.size());
//DataHelper.writeLong(out, 4, _version);
for (Iterator iter = _leases.iterator(); iter.hasNext();) {
Lease lease = (Lease) iter.next();
for (Iterator<Lease> iter = _leases.iterator(); iter.hasNext();) {
Lease lease = iter.next();
lease.writeBytes(out);
}
} catch (IOException ioe) {
@ -339,8 +339,8 @@ public class LeaseSet extends DatabaseEntry {
_signingKey.writeBytes(out);
DataHelper.writeLong(out, 1, _leases.size());
//DataHelper.writeLong(out, 4, _version);
for (Iterator iter = _leases.iterator(); iter.hasNext();) {
Lease lease = (Lease) iter.next();
for (Iterator<Lease> iter = _leases.iterator(); iter.hasNext();) {
Lease lease = iter.next();
lease.writeBytes(out);
}
_signature.writeBytes(out);
@ -494,7 +494,7 @@ public class LeaseSet extends DatabaseEntry {
byte[] dec = new byte[enclen];
I2PAppContext.getGlobalContext().aes().decrypt(enc, 0, dec, 0, key, iv, enclen);
ByteArrayInputStream bais = new ByteArrayInputStream(dec);
_decryptedLeases = new ArrayList(size - 1);
_decryptedLeases = new ArrayList<Lease>(size - 1);
for (int i = 0; i < size-1; i++) {
Lease l = new Lease();
Hash h = new Hash();

View File

@ -23,7 +23,7 @@ public class PublicKey extends SimpleDataStructure {
public final static int KEYSIZE_BYTES = 256;
private static final int CACHE_SIZE = 1024;
private static final SDSCache<PublicKey> _cache = new SDSCache(PublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
private static final SDSCache<PublicKey> _cache = new SDSCache<PublicKey>(PublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
/**
* Pull from cache or return new.

View File

@ -202,7 +202,7 @@ public class RouterInfo extends DatabaseEntry {
*/
public Set<Hash> getPeers() {
if (_peers == null)
return Collections.EMPTY_SET;
return Collections.emptySet();
return _peers;
}
@ -221,7 +221,7 @@ public class RouterInfo extends DatabaseEntry {
return;
}
if (_peers == null)
_peers = new HashSet(2);
_peers = new HashSet<Hash>(2);
synchronized (_peers) {
_peers.clear();
_peers.addAll(peers);
@ -546,7 +546,7 @@ public class RouterInfo extends DatabaseEntry {
if (numPeers == 0) {
_peers = null;
} else {
_peers = new HashSet(numPeers);
_peers = new HashSet<Hash>(numPeers);
for (int i = 0; i < numPeers; i++) {
Hash peerIdentityHash = new Hash();
peerIdentityHash.readBytes(din);

View File

@ -70,7 +70,7 @@ public class SDSCache<V extends SimpleDataStructure> {
*/
public SDSCache(Class<V> rvClass, int len, int max) {
int size = (int) (max * FACTOR);
_cache = new LHMCache(size);
_cache = new LHMCache<Integer, WeakReference<V>>(size);
_datalen = len;
try {
_rvCon = rvClass.getConstructor(conArg);
@ -135,7 +135,7 @@ public class SDSCache<V extends SimpleDataStructure> {
} catch (InvocationTargetException e) {
throw new RuntimeException("SDSCache error", e);
}
_cache.put(key, new WeakReference(rv));
_cache.put(key, new WeakReference<V>(rv));
found = 0;
}
}

View File

@ -27,7 +27,7 @@ public class SigningPublicKey extends SimpleDataStructure {
public final static int KEYSIZE_BYTES = DEF_TYPE.getPubkeyLen();
private static final int CACHE_SIZE = 1024;
private static final SDSCache<SigningPublicKey> _cache = new SDSCache(SigningPublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
private static final SDSCache<SigningPublicKey> _cache = new SDSCache<SigningPublicKey>(SigningPublicKey.class, KEYSIZE_BYTES, CACHE_SIZE);
private final SigType _type;

View File

@ -14,7 +14,6 @@ import java.io.IOException;
import java.io.InputStream;
import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
import net.i2p.data.LeaseSet;
import net.i2p.data.PrivateKey;
import net.i2p.data.SigningPrivateKey;

View File

@ -14,7 +14,6 @@ import java.io.IOException;
import java.io.InputStream;
import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
/**
* Defines the message a client sends to a router when establishing a new

View File

@ -10,7 +10,6 @@ import java.io.IOException;
import java.io.InputStream;
import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
import net.i2p.data.Hash;
/**

View File

@ -11,7 +11,6 @@ import java.io.IOException;
import java.io.InputStream;
import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.data.Hash;

View File

@ -14,7 +14,6 @@ import java.io.IOException;
import java.io.InputStream;
import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
/**
* Defines the message a client sends to a router when destroying

View File

@ -14,7 +14,6 @@ import java.io.IOException;
import java.io.InputStream;
import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
/**
* Defines the message a client sends to a router when

View File

@ -14,7 +14,6 @@ import java.io.IOException;
import java.io.InputStream;
import net.i2p.data.DataFormatException;
import net.i2p.data.DataHelper;
/**
* Defines the message a client sends to a router when asking the

View File

@ -34,7 +34,7 @@ public class RequestLeaseSetMessage extends I2CPMessageImpl {
private Date _end;
public RequestLeaseSetMessage() {
_endpoints = new ArrayList();
_endpoints = new ArrayList<TunnelEndpoint>();
}
public SessionId getSessionId() {

View File

@ -37,7 +37,7 @@ public class RequestVariableLeaseSetMessage extends I2CPMessageImpl {
private static final String MIN_VERSION = "0.9.7";
public RequestVariableLeaseSetMessage() {
_endpoints = new ArrayList();
_endpoints = new ArrayList<Lease>();
}
/**

View File

@ -26,7 +26,7 @@ public class BufferedStatLog implements StatLog {
private int _lastWrite;
/** flush stat events to disk after this many events (or 30s)*/
private int _flushFrequency;
private final List _statFilters;
private final List<String> _statFilters;
private String _lastFilters;
private BufferedWriter _out;
private String _outFile;
@ -45,7 +45,7 @@ public class BufferedStatLog implements StatLog {
_events[i] = new StatEvent();
_eventNext = 0;
_lastWrite = _events.length-1;
_statFilters = new ArrayList(10);
_statFilters = new ArrayList<String>(10);
_flushFrequency = 500;
updateFilters();
I2PThread writer = new I2PThread(new StatLogWriter(), "StatLogWriter");

View File

@ -1,8 +1,5 @@
package net.i2p.update;
import java.net.URI;
import java.util.List;
/**
* Controls one or more types of updates.
* This must be registered with the UpdateManager.

View File

@ -83,7 +83,7 @@ public abstract class Addresses {
boolean includeIPv6) {
boolean haveIPv4 = false;
boolean haveIPv6 = false;
SortedSet<String> rv = new TreeSet();
SortedSet<String> rv = new TreeSet<String>();
try {
InetAddress localhost = InetAddress.getLocalHost();
InetAddress[] allMyIps = InetAddress.getAllByName(localhost.getCanonicalHostName());
@ -236,7 +236,7 @@ public abstract class Addresses {
} else {
size = 32;
}
_IPAddress = new LHMCache(size);
_IPAddress = new LHMCache<String, byte[]>(size);
}
/**

View File

@ -52,7 +52,7 @@ import net.i2p.data.ByteArray;
public final class ByteCache {
//private static final Log _log = I2PAppContext.getGlobalContext().logManager().getLog(ByteCache.class);
private static final Map<Integer, ByteCache> _caches = new ConcurrentHashMap(16);
private static final Map<Integer, ByteCache> _caches = new ConcurrentHashMap<Integer, ByteCache>(16);
/**
* max size in bytes of each cache
@ -119,7 +119,7 @@ public final class ByteCache {
private ByteCache(int maxCachedEntries, int entrySize) {
if (_cache)
_available = new LinkedBlockingQueue(maxCachedEntries);
_available = new LinkedBlockingQueue<ByteArray>(maxCachedEntries);
_maxCached = maxCachedEntries;
_entrySize = entrySize;
_lastOverflow = -1;
@ -131,7 +131,7 @@ public final class ByteCache {
if (_maxCached >= maxCachedEntries) return;
_maxCached = maxCachedEntries;
// make a bigger one, move the cached items over
Queue<ByteArray> newLBQ = new LinkedBlockingQueue(maxCachedEntries);
Queue<ByteArray> newLBQ = new LinkedBlockingQueue<ByteArray>(maxCachedEntries);
ByteArray ba;
while ((ba = _available.poll()) != null)
newLBQ.offer(ba);

View File

@ -27,7 +27,7 @@ public class Clock implements Timestamper.UpdateListener {
public Clock(I2PAppContext context) {
_context = context;
_listeners = new CopyOnWriteArraySet();
_listeners = new CopyOnWriteArraySet<ClockUpdateListener>();
_startedOn = System.currentTimeMillis();
}

View File

@ -17,10 +17,10 @@ public class ConcurrentHashSet<E> extends AbstractSet<E> implements Set<E> {
private final Map<E, Object> _map;
public ConcurrentHashSet() {
_map = new ConcurrentHashMap();
_map = new ConcurrentHashMap<E, Object>();
}
public ConcurrentHashSet(int capacity) {
_map = new ConcurrentHashMap(capacity);
_map = new ConcurrentHashMap<E, Object>(capacity);
}
@Override

View File

@ -143,7 +143,7 @@ public class EepGet {
_postData = postData;
_bytesRemaining = -1;
_fetchHeaderTimeout = CONNECT_TIMEOUT;
_listeners = new ArrayList(1);
_listeners = new ArrayList<StatusListener>(1);
_etag = etag;
_lastModified = lastModified;
_etagOrig = etag;
@ -190,7 +190,7 @@ public class EepGet {
lineLen = Integer.parseInt(args[++i]);
} else if (args[i].equals("-h")) {
if (extra == null)
extra = new ArrayList(2);
extra = new ArrayList<String>(2);
extra.add(args[++i]);
extra.add(args[++i]);
} else if (args[i].equals("-u")) {
@ -1241,7 +1241,7 @@ public class EepGet {
*/
public void addHeader(String name, String value) {
if (_extraHeaders == null)
_extraHeaders = new ArrayList();
_extraHeaders = new ArrayList<String>();
_extraHeaders.add(name + ": " + value);
}

View File

@ -82,7 +82,7 @@ public interface EventDispatcher {
*
* @return A set of event names
*/
public Set getEvents();
public Set<String> getEvents();
/**
* Ignore further event notifications

View File

@ -35,8 +35,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
public class EventDispatcherImpl implements EventDispatcher {
private boolean _ignore = false;
private final Map<String, Object> _events = new ConcurrentHashMap(4);
private final List<EventDispatcher> _attached = new CopyOnWriteArrayList();
private final Map<String, Object> _events = new ConcurrentHashMap<String, Object>(4);
private final List<EventDispatcher> _attached = new CopyOnWriteArrayList<EventDispatcher>();
public EventDispatcher getEventDispatcher() {
return this;
@ -72,8 +72,8 @@ public class EventDispatcherImpl implements EventDispatcher {
}
public Set<String> getEvents() {
if (_ignore) return Collections.EMPTY_SET;
return new HashSet(_events.keySet());
if (_ignore) return Collections.emptySet();
return new HashSet<String>(_events.keySet());
}
public void ignoreEvents() {

View File

@ -106,7 +106,7 @@ public class FileUtil {
try {
byte buf[] = new byte[16*1024];
zip = new ZipFile(zipfile);
Enumeration entries = zip.entries();
Enumeration<? extends ZipEntry> entries = zip.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry)entries.nextElement();
if (entry.getName().indexOf("..") != -1) {
@ -215,7 +215,7 @@ public class FileUtil {
try {
byte buf[] = new byte[16*1024];
zip = new ZipFile(zipfile);
Enumeration entries = zip.entries();
Enumeration<? extends ZipEntry> entries = zip.entries();
boolean p200TestRequired = true;
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry)entries.nextElement();
@ -358,7 +358,7 @@ public class FileUtil {
try {
fis = new FileInputStream(f);
BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
List lines = new ArrayList(maxNumLines > 0 ? maxNumLines : 64);
List<String> lines = new ArrayList<String>(maxNumLines > 0 ? maxNumLines : 64);
String line = null;
while ( (line = in.readLine()) != null) {
lines.add(line);

View File

@ -22,7 +22,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
*/
public class I2PAppThread extends I2PThread {
private final Set _threadListeners = new CopyOnWriteArraySet();
private final Set<OOMEventListener> _threadListeners = new CopyOnWriteArraySet<OOMEventListener>();
public I2PAppThread() {
super();
@ -45,8 +45,8 @@ public class I2PAppThread extends I2PThread {
@Override
protected void fireOOM(OutOfMemoryError oom) {
for (Iterator iter = _threadListeners.iterator(); iter.hasNext(); ) {
OOMEventListener listener = (OOMEventListener)iter.next();
for (Iterator<OOMEventListener> iter = _threadListeners.iterator(); iter.hasNext(); ) {
OOMEventListener listener = iter.next();
listener.outOfMemory(oom);
}
}

View File

@ -1,9 +1,7 @@
package net.i2p.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.security.KeyStore;

View File

@ -26,7 +26,7 @@ public class I2PThread extends Thread {
* Logging removed, too much trouble with extra contexts
*/
//private volatile Log _log;
private static final Set _listeners = new CopyOnWriteArraySet();
private static final Set<OOMEventListener> _listeners = new CopyOnWriteArraySet<OOMEventListener>();
//private String _name;
//private Exception _createdBy;
@ -112,8 +112,8 @@ public class I2PThread extends Thread {
****/
protected void fireOOM(OutOfMemoryError oom) {
for (Iterator iter = _listeners.iterator(); iter.hasNext(); ) {
OOMEventListener listener = (OOMEventListener)iter.next();
for (Iterator<OOMEventListener> iter = _listeners.iterator(); iter.hasNext(); ) {
OOMEventListener listener = iter.next();
listener.outOfMemory(oom);
}
}

View File

@ -24,7 +24,7 @@ import java.util.concurrent.LinkedBlockingQueue;
* @since 0.7.9
*/
public class InternalServerSocket extends ServerSocket {
private static final ConcurrentHashMap<Integer, InternalServerSocket> _sockets = new ConcurrentHashMap(4);
private static final ConcurrentHashMap<Integer, InternalServerSocket> _sockets = new ConcurrentHashMap<Integer, InternalServerSocket>(4);
private final BlockingQueue<InternalSocket> _acceptQueue;
private final Integer _port;
private volatile boolean _running;
@ -41,7 +41,7 @@ public class InternalServerSocket extends ServerSocket {
if (previous != null)
throw new IOException("Internal port in use: " + port);
_running = true;
_acceptQueue = new LinkedBlockingQueue();
_acceptQueue = new LinkedBlockingQueue<InternalSocket>();
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("Registered " + _port);
}

View File

@ -36,8 +36,8 @@ public class LogConsoleBuffer {
lim = Math.max(limit, 4);
// Add some extra room to minimize the chance of losing a message,
// since we are doing offer() below.
_buffer = new LinkedBlockingQueue(lim + 4);
_critBuffer = new LinkedBlockingQueue(lim + 4);
_buffer = new LinkedBlockingQueue<String>(lim + 4);
_critBuffer = new LinkedBlockingQueue<String>(lim + 4);
}
void add(String msg) {
@ -64,7 +64,7 @@ public class LogConsoleBuffer {
* @return oldest first
*/
public List<String> getMostRecentMessages() {
return new ArrayList(_buffer);
return new ArrayList<String>(_buffer);
}
/**
@ -75,7 +75,7 @@ public class LogConsoleBuffer {
* @return oldest first
*/
public List<String> getMostRecentCriticalMessages() {
return new ArrayList(_critBuffer);
return new ArrayList<String>(_critBuffer);
}
/**

View File

@ -131,14 +131,14 @@ public class LogManager {
public LogManager(I2PAppContext context) {
_displayOnScreen = true;
_alreadyNoticedMissingConfig = false;
_limits = new ConcurrentHashSet();
_logs = new ConcurrentHashMap(128);
_limits = new ConcurrentHashSet<LogLimit>();
_logs = new ConcurrentHashMap<Object, Log>(128);
_defaultLimit = Log.ERROR;
_context = context;
_log = getLog(LogManager.class);
String location = context.getProperty(CONFIG_LOCATION_PROP, CONFIG_LOCATION_DEFAULT);
setConfig(location);
_records = new LinkedBlockingQueue(_logBufferSize);
_records = new LinkedBlockingQueue<LogRecord>(_logBufferSize);
_consoleBuffer = new LogConsoleBuffer(_consoleBufferSize);
// If we aren't in the router context, delay creating the LogWriter until required,
// so it doesn't create a log directory and log files unless there is output.
@ -582,7 +582,7 @@ public class LogManager {
for (LogLimit limit : _limits) {
if (limit.matches(log)) {
if (limits == null)
limits = new ArrayList(4);
limits = new ArrayList<LogLimit>(4);
limits.add(limit);
}
}

View File

@ -35,7 +35,6 @@ import freenet.support.CPUInformation.UnknownCPUException;
import net.i2p.I2PAppContext;
import net.i2p.crypto.CryptoConstants;
import net.i2p.data.DataHelper;
/**
* <p>BigInteger that takes advantage of the jbigi library for the modPow operation,
@ -627,8 +626,8 @@ public class NativeBigInteger extends BigInteger {
*/
private static List<String> getResourceList() {
if (_isAndroid)
return Collections.EMPTY_LIST;
List<String> rv = new ArrayList(8);
return Collections.emptyList();
List<String> rv = new ArrayList<String>(8);
String primary = getMiddleName2(true);
if (primary != null) {
if (_is64) {
@ -708,7 +707,7 @@ public class NativeBigInteger extends BigInteger {
* @since 0.9.1
*/
private static Map<String, String> getCPUInfo() {
Map<String, String> rv = new HashMap(32);
Map<String, String> rv = new HashMap<String, String>(32);
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/cpuinfo"), "ISO-8859-1"), 4096);

View File

@ -32,7 +32,7 @@ public class PortMapper {
* @param context unused for now
*/
public PortMapper(I2PAppContext context) {
_dir = new ConcurrentHashMap(8);
_dir = new ConcurrentHashMap<String, Integer>(8);
}
/**

View File

@ -14,7 +14,7 @@ public class ReusableGZIPInputStream extends ResettableGZIPInputStream {
private static final LinkedBlockingQueue<ReusableGZIPInputStream> _available;
static {
if (ENABLE_CACHING)
_available = new LinkedBlockingQueue(8);
_available = new LinkedBlockingQueue<ReusableGZIPInputStream>(8);
else
_available = null;
}

View File

@ -25,7 +25,7 @@ public class ReusableGZIPOutputStream extends ResettableGZIPOutputStream {
private static final LinkedBlockingQueue<ReusableGZIPOutputStream> _available;
static {
if (ENABLE_CACHING)
_available = new LinkedBlockingQueue(16);
_available = new LinkedBlockingQueue<ReusableGZIPOutputStream>(16);
else
_available = null;
}

View File

@ -39,10 +39,8 @@ package net.i2p.util;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
@ -50,8 +48,6 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.security.KeyStore;
import java.security.GeneralSecurityException;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Locale;

View File

@ -1,6 +1,5 @@
package net.i2p.util;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
@ -16,7 +15,7 @@ import java.util.concurrent.LinkedBlockingQueue;
*/
public final class SimpleByteCache {
private static final ConcurrentHashMap<Integer, SimpleByteCache> _caches = new ConcurrentHashMap(8);
private static final ConcurrentHashMap<Integer, SimpleByteCache> _caches = new ConcurrentHashMap<Integer, SimpleByteCache>(8);
private static final int DEFAULT_SIZE = 64;
@ -89,8 +88,8 @@ public final class SimpleByteCache {
*/
private Queue<byte[]> createQueue() {
if (_entrySize <= MAX_FOR_ABQ)
return new ArrayBlockingQueue(_maxCached);
return new LinkedBlockingQueue(_maxCached);
return new ArrayBlockingQueue<byte[]>(_maxCached);
return new LinkedBlockingQueue<byte[]>(_maxCached);
}
/**

View File

@ -54,9 +54,9 @@ public class SimpleTimer {
private SimpleTimer(I2PAppContext context, String name) {
runn = new SimpleStore(true);
_log = context.logManager().getLog(SimpleTimer.class);
_events = new TreeMap();
_eventTimes = new HashMap(256);
_readyEvents = new ArrayList(4);
_events = new TreeMap<Long, TimedEvent>();
_eventTimes = new HashMap<TimedEvent, Long>(256);
_readyEvents = new ArrayList<TimedEvent>(4);
I2PThread runner = new I2PThread(new SimpleTimerRunner());
runner.setName(name);
runner.setDaemon(true);
@ -155,8 +155,8 @@ public class SimpleTimer {
if ( (_events.size() != _eventTimes.size()) ) {
_log.error("Skewed events: " + _events.size() + " for " + _eventTimes.size());
for (Iterator iter = _eventTimes.keySet().iterator(); iter.hasNext(); ) {
TimedEvent evt = (TimedEvent)iter.next();
for (Iterator<TimedEvent> iter = _eventTimes.keySet().iterator(); iter.hasNext(); ) {
TimedEvent evt = iter.next();
Long when = _eventTimes.get(evt);
TimedEvent cur = _events.get(when);
if (cur != evt) {
@ -209,7 +209,7 @@ public class SimpleTimer {
// private TimedEvent _recentEvents[] = new TimedEvent[5];
private class SimpleTimerRunner implements Runnable {
public void run() {
List<TimedEvent> eventsToFire = new ArrayList(1);
List<TimedEvent> eventsToFire = new ArrayList<TimedEvent>(1);
while(runn.getAnswer()) {
try {
synchronized (_events) {

View File

@ -26,8 +26,8 @@ import net.i2p.util.ConcurrentHashSet;
public abstract class Translate {
public static final String PROP_LANG = "routerconsole.lang";
private static final String _localeLang = Locale.getDefault().getLanguage();
private static final Map<String, ResourceBundle> _bundles = new ConcurrentHashMap(16);
private static final Set<String> _missing = new ConcurrentHashSet(16);
private static final Map<String, ResourceBundle> _bundles = new ConcurrentHashMap<String, ResourceBundle>(16);
private static final Set<String> _missing = new ConcurrentHashSet<String>(16);
/** use to look for untagged strings */
private static final String TEST_LANG = "xx";
private static final String TEST_STRING = "XXXX";

View File

@ -71,7 +71,7 @@ public class TranslateReader extends FilterReader {
super(new BufferedReader(new InputStreamReader(in, "UTF-8")));
_ctx = ctx;
_bundle = bundle;
_args = new ArrayList(4);
_args = new ArrayList<String>(4);
_inBuf = new StringBuilder(64);
_outBuf = new StringBuilder(64);
_argBuf = new StringBuilder(64);
@ -415,7 +415,7 @@ public class TranslateReader extends FilterReader {
File[] listing = dir.listFiles();
if (listing == null)
throw new IOException();
filelist = new ArrayList(listing.length);
filelist = new ArrayList<String>(listing.length);
for (int i = 0; i < listing.length; i++) {
File f = listing[i];
if (!f.isDirectory())

View File

@ -94,7 +94,7 @@ public class BlockFile {
private boolean _isClosed;
/** cached list of free pages, only valid if freListStart > 0 */
private FreeListBlock flb;
private final HashMap openIndices = new HashMap();
private final HashMap<String, BSkipList> openIndices = new HashMap<String, BSkipList>();
private void mount() throws IOException {
file.seek(BlockFile.OFFSET_MOUNTED);
@ -481,12 +481,12 @@ public class BlockFile {
_isClosed = true;
metaIndex.close();
Set oi = openIndices.keySet();
Iterator i = oi.iterator();
Set<String> oi = openIndices.keySet();
Iterator<String> i = oi.iterator();
Object k;
while(i.hasNext()) {
k = i.next();
BSkipList bsl = (BSkipList) openIndices.get(k);
BSkipList bsl = openIndices.get(k);
bsl.close();
}

View File

@ -226,7 +226,7 @@ public class BSkipLevels extends SkipLevels {
* @since 0.8.8
*/
private boolean blvlfix() {
TreeSet<SkipLevels> lvls = new TreeSet(new LevelComparator());
TreeSet<SkipLevels> lvls = new TreeSet<SkipLevels>(new LevelComparator());
if (bf.log.shouldLog(Log.DEBUG))
bf.log.debug("Starting level search");
getAllLevels(this, lvls);
@ -284,7 +284,7 @@ public class BSkipLevels extends SkipLevels {
* @param lvlSet out parameter, the result
* @since 0.8.8
*/
private void getAllLevels(SkipLevels l, Set lvlSet) {
private void getAllLevels(SkipLevels l, Set<SkipLevels> lvlSet) {
if (bf.log.shouldLog(Log.DEBUG))
bf.log.debug("GAL " + l.print());
// Do level 0 without recursion, on the assumption everything is findable

View File

@ -58,8 +58,8 @@ public class BSkipList extends SkipList {
public final BlockFile bf;
private boolean isClosed;
final HashMap<Integer, BSkipSpan> spanHash = new HashMap();
final HashMap<Integer, SkipLevels> levelHash = new HashMap();
final HashMap<Integer, BSkipSpan> spanHash = new HashMap<Integer, BSkipSpan>();
final HashMap<Integer, SkipLevels> levelHash = new HashMap<Integer, SkipLevels>();
private final boolean fileOnly;