Consistently support LoadingCache
This commits make sure that CaffeineCache handles consistently the contract of LoadingCache. Closes gh-25173
This commit is contained in:
@@ -83,16 +83,6 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ValueWrapper get(Object key) {
|
||||
if (this.cache instanceof LoadingCache) {
|
||||
Object value = ((LoadingCache<Object, Object>) this.cache).get(key);
|
||||
return toValueWrapper(value);
|
||||
}
|
||||
return super.get(key);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -103,6 +93,9 @@ public class CaffeineCache extends AbstractValueAdaptingCache {
|
||||
@Override
|
||||
@Nullable
|
||||
protected Object lookup(Object key) {
|
||||
if (this.cache instanceof LoadingCache) {
|
||||
return ((LoadingCache<Object, Object>) this.cache).get(key);
|
||||
}
|
||||
return this.cache.getIfPresent(key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user