forked from I2P_Developers/i2p.i2p
* Replace size() <= 0 with isEmpty() everywhere, ditto > 0 -> !isEmpty()
This commit is contained in:
@@ -451,13 +451,13 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
Long msgId = null;
|
||||
Integer size = null;
|
||||
synchronized (AvailabilityNotifier.this) {
|
||||
if (_pendingIds.size() <= 0) {
|
||||
if (_pendingIds.isEmpty()) {
|
||||
try {
|
||||
AvailabilityNotifier.this.wait();
|
||||
} catch (InterruptedException ie) { // nop
|
||||
}
|
||||
}
|
||||
if (_pendingIds.size() > 0) {
|
||||
if (!_pendingIds.isEmpty()) {
|
||||
msgId = (Long)_pendingIds.remove(0);
|
||||
size = (Integer)_pendingSizes.remove(0);
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
oldTags = _context.sessionKeyManager().getAvailableTags(dest.getPublicKey(), key);
|
||||
long availTimeLeft = _context.sessionKeyManager().getAvailableTimeLeft(dest.getPublicKey(), key);
|
||||
|
||||
if ( (tagsSent == null) || (tagsSent.size() <= 0) ) {
|
||||
if ( (tagsSent == null) || (tagsSent.isEmpty()) ) {
|
||||
if (oldTags < NUM_TAGS) {
|
||||
sentTags = createNewTags(NUM_TAGS);
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
@@ -261,7 +261,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
if (false) // rekey
|
||||
newKey = _context.keyGenerator().generateSessionKey();
|
||||
|
||||
if ( (tagsSent != null) && (tagsSent.size() > 0) ) {
|
||||
if ( (tagsSent != null) && (!tagsSent.isEmpty()) ) {
|
||||
if (sentTags == null)
|
||||
sentTags = new HashSet();
|
||||
sentTags.addAll(tagsSent);
|
||||
|
||||
@@ -72,7 +72,7 @@ public class EepGetNamingService extends NamingService {
|
||||
return d;
|
||||
|
||||
List URLs = getURLs();
|
||||
if (URLs.size() == 0)
|
||||
if (URLs.isEmpty())
|
||||
return null;
|
||||
|
||||
// prevent lookup loops - this cannot be the only lookup service
|
||||
|
||||
@@ -31,7 +31,7 @@ public final class CryptixAESKeyCache {
|
||||
*/
|
||||
public final KeyCacheEntry acquireKey() {
|
||||
synchronized (_availableKeys) {
|
||||
if (_availableKeys.size() > 0)
|
||||
if (!_availableKeys.isEmpty())
|
||||
return (KeyCacheEntry)_availableKeys.remove(0);
|
||||
}
|
||||
return createNew();
|
||||
|
||||
@@ -114,7 +114,7 @@ public class DHSessionKeyBuilder {
|
||||
this(false);
|
||||
DHSessionKeyBuilder builder = null;
|
||||
synchronized (_builders) {
|
||||
if (_builders.size() > 0) {
|
||||
if (!_builders.isEmpty()) {
|
||||
builder = (DHSessionKeyBuilder) _builders.remove(0);
|
||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Removing a builder. # left = " + _builders.size());
|
||||
} else {
|
||||
|
||||
@@ -104,7 +104,7 @@ public class ElGamalAESEngine {
|
||||
decrypted = decryptExistingSession(data, key, targetPrivateKey, foundTags, usedKey, foundKey);
|
||||
if (decrypted != null) {
|
||||
_context.statManager().updateFrequency("crypto.elGamalAES.decryptExistingSession");
|
||||
if ( (foundTags.size() > 0) && (_log.shouldLog(Log.DEBUG)) )
|
||||
if ( (!foundTags.isEmpty()) && (_log.shouldLog(Log.DEBUG)) )
|
||||
_log.debug(id + ": ElG/AES decrypt success with " + st + ": found tags: " + foundTags);
|
||||
wasExisting = true;
|
||||
} else {
|
||||
@@ -118,7 +118,7 @@ public class ElGamalAESEngine {
|
||||
decrypted = decryptNewSession(data, targetPrivateKey, foundTags, usedKey, foundKey);
|
||||
if (decrypted != null) {
|
||||
_context.statManager().updateFrequency("crypto.elGamalAES.decryptNewSession");
|
||||
if ( (foundTags.size() > 0) && (_log.shouldLog(Log.DEBUG)) )
|
||||
if ( (!foundTags.isEmpty()) && (_log.shouldLog(Log.DEBUG)) )
|
||||
_log.debug("ElG decrypt success: found tags: " + foundTags);
|
||||
} else {
|
||||
_context.statManager().updateFrequency("crypto.elGamalAES.decryptFailed");
|
||||
@@ -131,7 +131,7 @@ public class ElGamalAESEngine {
|
||||
//_log.debug("Unable to decrypt the data starting with tag [" + st + "] - did the tag expire recently?", new Exception("Decrypt failure"));
|
||||
}
|
||||
|
||||
if (foundTags.size() > 0) {
|
||||
if (!foundTags.isEmpty()) {
|
||||
if (foundKey.getData() != null) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Found key: " + foundKey.toBase64() + " tags: " + foundTags + " wasExisting? " + wasExisting);
|
||||
|
||||
@@ -22,7 +22,7 @@ public class HMAC256Generator extends HMACGenerator {
|
||||
@Override
|
||||
protected I2PHMac acquire() {
|
||||
synchronized (_available) {
|
||||
if (_available.size() > 0)
|
||||
if (!_available.isEmpty())
|
||||
return (I2PHMac)_available.remove(0);
|
||||
}
|
||||
// the HMAC is hardcoded to use SHA256 digest size
|
||||
|
||||
@@ -89,7 +89,7 @@ public class HMACGenerator {
|
||||
|
||||
protected I2PHMac acquire() {
|
||||
synchronized (_available) {
|
||||
if (_available.size() > 0)
|
||||
if (!_available.isEmpty())
|
||||
return (I2PHMac)_available.remove(0);
|
||||
}
|
||||
// the HMAC is hardcoded to use SHA256 digest size
|
||||
@@ -108,7 +108,7 @@ public class HMACGenerator {
|
||||
private byte[] acquireTmp() {
|
||||
byte rv[] = null;
|
||||
synchronized (_availableTmp) {
|
||||
if (_availableTmp.size() > 0)
|
||||
if (!_availableTmp.isEmpty())
|
||||
rv = (byte[])_availableTmp.remove(0);
|
||||
}
|
||||
if (rv != null)
|
||||
|
||||
@@ -52,7 +52,7 @@ public final class SHA256Generator {
|
||||
private Sha256Standalone acquireGnu() {
|
||||
Sha256Standalone rv = null;
|
||||
synchronized (_digestsGnu) {
|
||||
if (_digestsGnu.size() > 0)
|
||||
if (!_digestsGnu.isEmpty())
|
||||
rv = (Sha256Standalone)_digestsGnu.remove(0);
|
||||
}
|
||||
if (rv != null)
|
||||
|
||||
@@ -307,7 +307,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
||||
public TagSetHandle tagsDelivered(PublicKey target, SessionKey key, Set<SessionTag> sessionTags) {
|
||||
if (_log.shouldLog(Log.DEBUG)) {
|
||||
//_log.debug("Tags delivered to set " + set + " on session " + sess);
|
||||
if (sessionTags.size() > 0)
|
||||
if (!sessionTags.isEmpty())
|
||||
_log.debug("Tags delivered: " + sessionTags.size() + " for key: " + key + ": " + sessionTags);
|
||||
}
|
||||
OutboundSession sess = getSession(target);
|
||||
@@ -415,7 +415,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
||||
if (overage > 0)
|
||||
clearExcess(overage);
|
||||
|
||||
if ( (sessionTags.size() <= 0) && (_log.shouldLog(Log.DEBUG)) )
|
||||
if ( (sessionTags.isEmpty()) && (_log.shouldLog(Log.DEBUG)) )
|
||||
_log.debug("Received 0 tags for key " + key);
|
||||
//if (false) aggressiveExpire();
|
||||
}
|
||||
@@ -785,7 +785,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
||||
long now = _context.clock().now();
|
||||
_lastUsed = now;
|
||||
synchronized (_tagSets) {
|
||||
while (_tagSets.size() > 0) {
|
||||
while (!_tagSets.isEmpty()) {
|
||||
TagSet set = _tagSets.get(0);
|
||||
if (set.getDate() + SESSION_TAG_DURATION_MS > now) {
|
||||
SessionTag tag = set.consumeNext();
|
||||
@@ -830,7 +830,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
|
||||
synchronized (_tagSets) {
|
||||
for (Iterator<TagSet> iter = _tagSets.iterator(); iter.hasNext();) {
|
||||
TagSet set = iter.next();
|
||||
if ( (set.getDate() > last) && (set.getTags().size() > 0) )
|
||||
if ( (set.getDate() > last) && (!set.getTags().isEmpty()) )
|
||||
last = set.getDate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ class YKGenerator {
|
||||
public static BigInteger[] getNextYK() {
|
||||
if (true) {
|
||||
synchronized (_values) {
|
||||
if (_values.size() > 0) {
|
||||
if (!_values.isEmpty()) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Sufficient precalculated YK values - fetch the existing");
|
||||
return (BigInteger[]) _values.remove(0);
|
||||
|
||||
@@ -201,7 +201,7 @@ public class LeaseSet extends DataStructureImpl {
|
||||
* @return earliest end date of any lease in the set, or -1 if there are no leases
|
||||
*/
|
||||
public long getEarliestLeaseDate() {
|
||||
if (_leases.size() <= 0)
|
||||
if (_leases.isEmpty())
|
||||
return -1;
|
||||
return _firstExpiration;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class BufferedStatLog implements StatLog {
|
||||
_statFilters.clear();
|
||||
while (tok.hasMoreTokens())
|
||||
_statFilters.add(tok.nextToken().trim());
|
||||
_filtersSpecified = _statFilters.size() > 0;
|
||||
_filtersSpecified = !_statFilters.isEmpty();
|
||||
}
|
||||
}
|
||||
_lastFilters = val;
|
||||
|
||||
@@ -20,9 +20,9 @@ class Executor implements Runnable {
|
||||
while(runn.getAnswer()) {
|
||||
SimpleTimer.TimedEvent evt = null;
|
||||
synchronized (_readyEvents) {
|
||||
if (_readyEvents.size() <= 0)
|
||||
if (_readyEvents.isEmpty())
|
||||
try { _readyEvents.wait(); } catch (InterruptedException ie) {}
|
||||
if (_readyEvents.size() > 0)
|
||||
if (!_readyEvents.isEmpty())
|
||||
evt = (SimpleTimer.TimedEvent)_readyEvents.remove(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ public class SimpleTimer {
|
||||
long nextEventDelay = -1;
|
||||
Object nextEvent = null;
|
||||
while(runn.getAnswer()) {
|
||||
if(_events.size() <= 0) {
|
||||
if(_events.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
Long when = (Long)_events.firstKey();
|
||||
@@ -196,7 +196,7 @@ public class SimpleTimer {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (eventsToFire.size() <= 0) {
|
||||
if (eventsToFire.isEmpty()) {
|
||||
if (nextEventDelay != -1) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Next event in " + nextEventDelay + ": " + nextEvent);
|
||||
|
||||
Reference in New Issue
Block a user