Skip to content

Commit

Permalink
When AsyncCacheLoader.asyncLoadAll returns excess keys, wait for al…
Browse files Browse the repository at this point in the history
…l keys to be added to the cache before returning requested keys

Fixes #1409.
  • Loading branch information
allanrodriguez committed Feb 24, 2024
1 parent c4b8dd7 commit e5e9bc3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ default CompletableFuture<Map<K, V>> getAll(Iterable<? extends K> keys,
try {
var loader = mappingFunction.apply(
Collections.unmodifiableSet(proxies.keySet()), cache().executor());
loader.whenComplete(completer);
return composeResult(futures);
return loader.whenComplete(completer).thenCompose(ignored -> composeResult(futures));
} catch (Throwable t) {
completer.accept(/* result */ null, t);
throw t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ public void getAll_present_partial(AsyncLoadingCache<Int, Int> cache, CacheConte

@Test(dataProvider = "caches")
@CacheSpec(loader = Loader.BULK_NEGATIVE_EXCEEDS,
removalListener = { Listener.DISABLED, Listener.REJECTING })
removalListener = { Listener.DISABLED, Listener.REJECTING },
executor = { CacheExecutor.DIRECT, CacheExecutor.DEFAULT })
public void getAll_exceeds(AsyncLoadingCache<Int, Int> cache, CacheContext context) {
var result = cache.getAll(context.absentKeys()).join();

Expand Down

0 comments on commit e5e9bc3

Please sign in to comment.