mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8291509: Minor cleanup could be done in sun.security
Reviewed-by: weijun
This commit is contained in:
parent
6beeb8471c
commit
4cec141a90
298 changed files with 2650 additions and 3262 deletions
|
@ -187,16 +187,15 @@ public abstract class Cache<K,V> {
|
|||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof EqualByteArray == false) {
|
||||
if (!(obj instanceof EqualByteArray other)) {
|
||||
return false;
|
||||
}
|
||||
EqualByteArray other = (EqualByteArray)obj;
|
||||
return Arrays.equals(this.b, other.b);
|
||||
}
|
||||
}
|
||||
|
||||
public interface CacheVisitor<K,V> {
|
||||
public void visit(Map<K,V> map);
|
||||
void visit(Map<K, V> map);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -269,7 +268,7 @@ class MemoryCache<K,V> extends Cache<K,V> {
|
|||
|
||||
public MemoryCache(boolean soft, int maxSize, int lifetime) {
|
||||
this.maxSize = maxSize;
|
||||
this.lifetime = lifetime * 1000;
|
||||
this.lifetime = lifetime * 1000L;
|
||||
if (soft)
|
||||
this.queue = new ReferenceQueue<>();
|
||||
else
|
||||
|
@ -334,7 +333,7 @@ class MemoryCache<K,V> extends Cache<K,V> {
|
|||
for (Iterator<CacheEntry<K,V>> t = cacheMap.values().iterator();
|
||||
t.hasNext(); ) {
|
||||
CacheEntry<K,V> entry = t.next();
|
||||
if (entry.isValid(time) == false) {
|
||||
if (!entry.isValid(time)) {
|
||||
t.remove();
|
||||
cnt++;
|
||||
} else if (nextExpirationTime > entry.getExpirationTime()) {
|
||||
|
@ -403,7 +402,7 @@ class MemoryCache<K,V> extends Cache<K,V> {
|
|||
return null;
|
||||
}
|
||||
long time = (lifetime == 0) ? 0 : System.currentTimeMillis();
|
||||
if (entry.isValid(time) == false) {
|
||||
if (!entry.isValid(time)) {
|
||||
if (DEBUG) {
|
||||
System.out.println("Ignoring expired entry");
|
||||
}
|
||||
|
@ -456,7 +455,7 @@ class MemoryCache<K,V> extends Cache<K,V> {
|
|||
}
|
||||
}
|
||||
|
||||
maxSize = size > 0 ? size : 0;
|
||||
maxSize = Math.max(size, 0);
|
||||
|
||||
if (DEBUG) {
|
||||
System.out.println("** capacity reset to " + size);
|
||||
|
@ -499,7 +498,7 @@ class MemoryCache<K,V> extends Cache<K,V> {
|
|||
}
|
||||
}
|
||||
|
||||
private static interface CacheEntry<K,V> {
|
||||
private interface CacheEntry<K,V> {
|
||||
|
||||
boolean isValid(long currentTime);
|
||||
|
||||
|
@ -538,7 +537,7 @@ class MemoryCache<K,V> extends Cache<K,V> {
|
|||
|
||||
public boolean isValid(long currentTime) {
|
||||
boolean valid = (currentTime <= expirationTime);
|
||||
if (valid == false) {
|
||||
if (!valid) {
|
||||
invalidate();
|
||||
}
|
||||
return valid;
|
||||
|
@ -579,7 +578,7 @@ class MemoryCache<K,V> extends Cache<K,V> {
|
|||
|
||||
public boolean isValid(long currentTime) {
|
||||
boolean valid = (currentTime <= expirationTime) && (get() != null);
|
||||
if (valid == false) {
|
||||
if (!valid) {
|
||||
invalidate();
|
||||
}
|
||||
return valid;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue