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 (#1550)

Fixes #1409.
  • Loading branch information
allanrodriguez authored Feb 25, 2024
1 parent d7a3c29 commit 7f82472
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 7f82472

Please sign in to comment.