8241248: NullPointerException in sun.security.ssl.HKDF.extract(HKDF.java:93)

Reviewed-by: jnimeh, xuelei
This commit is contained in:
Alexey Bakhtin 2021-05-10 09:45:35 +00:00 committed by Vladimir Kempik
parent 0f925d1f58
commit 1603ca2342
4 changed files with 42 additions and 5 deletions

View file

@ -100,6 +100,11 @@ public abstract class Cache<K,V> {
*/
public abstract void remove(Object key);
/**
* Pull an entry from the cache.
*/
public abstract V pull(Object key);
/**
* Set the maximum size.
*/
@ -224,6 +229,10 @@ class NullCache<K,V> extends Cache<K,V> {
// empty
}
public V pull(Object key) {
return null;
}
public void setCapacity(int size) {
// empty
}
@ -412,6 +421,26 @@ class MemoryCache<K,V> extends Cache<K,V> {
}
}
public synchronized V pull(Object key) {
emptyQueue();
CacheEntry<K,V> entry = cacheMap.remove(key);
if (entry == null) {
return null;
}
long time = (lifetime == 0) ? 0 : System.currentTimeMillis();
if (entry.isValid(time)) {
V value = entry.getValue();
entry.invalidate();
return value;
} else {
if (DEBUG) {
System.out.println("Ignoring expired entry");
}
return null;
}
}
public synchronized void setCapacity(int size) {
expungeExpiredEntries();
if (size > 0 && cacheMap.size() > size) {