Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
pditommaso committed Dec 22, 2024
1 parent 4d14f3c commit dea618b
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ abstract class AbstractTieredCache<V extends MoshiExchange> implements TieredCac
*/
@Override
V get(String key) {
getOrCompute(key, null, null)
getOrCompute0(key, null)
}

/**
Expand All @@ -129,9 +129,9 @@ abstract class AbstractTieredCache<V extends MoshiExchange> implements TieredCac
*/
V getOrCompute(String key, Function<String,V> loader, Duration ttl) {
if( loader==null ) {
return getOrCompute(key, null, null)
return getOrCompute0(key, null)
}
return getOrCompute(key, (String k)-> {
return getOrCompute0(key, (String k)-> {
V v = loader.apply(key)
return v != null ? new Tuple2<>(v, ttl) : null
})
Expand All @@ -148,6 +148,10 @@ abstract class AbstractTieredCache<V extends MoshiExchange> implements TieredCac
* The value associated with the specified key, or #function result otherwise
*/
V getOrCompute(String key, Function<String, Tuple2<V,Duration>> loader) {
return getOrCompute0(key, loader)
}

private V getOrCompute0(String key, Function<String, Tuple2<V,Duration>> loader) {
assert key!=null, "Argument key cannot be null"

log.trace "Cache '${name}' checking key=$key"
Expand Down

0 comments on commit dea618b

Please sign in to comment.