@@ -224,9 +224,8 @@ private CompletableFuture<List<V>> sliceIntoBatchesOfBatches(List<K> keys, List<
224224 @ SuppressWarnings ("unchecked" )
225225 private CompletableFuture <List <V >> dispatchQueueBatch (List <K > keys , List <Object > callContexts , List <CompletableFuture <V >> queuedFutures ) {
226226 stats .incrementBatchLoadCountBy (keys .size ());
227- CompletionStage <List <V >> batchLoad = invokeLoader (keys , callContexts , loaderOptions .cachingEnabled ());
227+ CompletableFuture <List <V >> batchLoad = invokeLoader (keys , callContexts , loaderOptions .cachingEnabled ());
228228 return batchLoad
229- .toCompletableFuture ()
230229 .thenApply (values -> {
231230 assertResultSize (keys , values );
232231
@@ -327,7 +326,7 @@ CompletableFuture<V> invokeLoaderImmediately(K key, Object keyContext, boolean c
327326 .toCompletableFuture ();
328327 }
329328
330- CompletionStage <List <V >> invokeLoader (List <K > keys , List <Object > keyContexts , boolean cachingEnabled ) {
329+ CompletableFuture <List <V >> invokeLoader (List <K > keys , List <Object > keyContexts , boolean cachingEnabled ) {
331330 if (!cachingEnabled ) {
332331 return invokeLoader (keys , keyContexts );
333332 }
@@ -361,7 +360,7 @@ CompletionStage<List<V>> invokeLoader(List<K> keys, List<Object> keyContexts, bo
361360 // we missed some of the keys from cache, so send them to the batch loader
362361 // and then fill in their values
363362 //
364- CompletionStage <List <V >> batchLoad = invokeLoader (cacheMissedKeys , cacheMissedContexts );
363+ CompletableFuture <List <V >> batchLoad = invokeLoader (cacheMissedKeys , cacheMissedContexts );
365364 return batchLoad .thenCompose (missedValues -> {
366365 assertResultSize (cacheMissedKeys , missedValues );
367366
@@ -381,8 +380,8 @@ CompletionStage<List<V>> invokeLoader(List<K> keys, List<Object> keyContexts, bo
381380 }
382381
383382
384- CompletionStage <List <V >> invokeLoader (List <K > keys , List <Object > keyContexts ) {
385- CompletionStage <List <V >> batchLoad ;
383+ CompletableFuture <List <V >> invokeLoader (List <K > keys , List <Object > keyContexts ) {
384+ CompletableFuture <List <V >> batchLoad ;
386385 try {
387386 Object context = loaderOptions .getBatchLoaderContextProvider ().getContext ();
388387 BatchLoaderEnvironment environment = BatchLoaderEnvironment .newBatchLoaderEnvironment ()
@@ -399,14 +398,14 @@ CompletionStage<List<V>> invokeLoader(List<K> keys, List<Object> keyContexts) {
399398 }
400399
401400 @ SuppressWarnings ("unchecked" )
402- private CompletionStage <List <V >> invokeListBatchLoader (List <K > keys , BatchLoaderEnvironment environment ) {
401+ private CompletableFuture <List <V >> invokeListBatchLoader (List <K > keys , BatchLoaderEnvironment environment ) {
403402 CompletionStage <List <V >> loadResult ;
404403 if (batchLoadFunction instanceof BatchLoaderWithContext ) {
405404 loadResult = ((BatchLoaderWithContext <K , V >) batchLoadFunction ).load (keys , environment );
406405 } else {
407406 loadResult = ((BatchLoader <K , V >) batchLoadFunction ).load (keys );
408407 }
409- return nonNull (loadResult , () -> "Your batch loader function MUST return a non null CompletionStage promise" );
408+ return nonNull (loadResult , () -> "Your batch loader function MUST return a non null CompletionStage promise" ). toCompletableFuture () ;
410409 }
411410
412411
@@ -415,15 +414,15 @@ private CompletionStage<List<V>> invokeListBatchLoader(List<K> keys, BatchLoader
415414 * to missing elements.
416415 */
417416 @ SuppressWarnings ("unchecked" )
418- private CompletionStage <List <V >> invokeMapBatchLoader (List <K > keys , BatchLoaderEnvironment environment ) {
417+ private CompletableFuture <List <V >> invokeMapBatchLoader (List <K > keys , BatchLoaderEnvironment environment ) {
419418 CompletionStage <Map <K , V >> loadResult ;
420419 Set <K > setOfKeys = new LinkedHashSet <>(keys );
421420 if (batchLoadFunction instanceof MappedBatchLoaderWithContext ) {
422421 loadResult = ((MappedBatchLoaderWithContext <K , V >) batchLoadFunction ).load (setOfKeys , environment );
423422 } else {
424423 loadResult = ((MappedBatchLoader <K , V >) batchLoadFunction ).load (setOfKeys );
425424 }
426- CompletionStage <Map <K , V >> mapBatchLoad = nonNull (loadResult , () -> "Your batch loader function MUST return a non null CompletionStage promise" );
425+ CompletableFuture <Map <K , V >> mapBatchLoad = nonNull (loadResult , () -> "Your batch loader function MUST return a non null CompletionStage promise" ). toCompletableFuture ( );
427426 return mapBatchLoad .thenApply (map -> {
428427 List <V > values = new ArrayList <>();
429428 for (K key : keys ) {
@@ -452,7 +451,7 @@ private CompletableFuture<List<Try<V>>> getFromValueCache(List<K> keys) {
452451 }
453452 }
454453
455- private CompletionStage <List <V >> setToValueCache (List <V > assembledValues , List <K > missedKeys , List <V > missedValues ) {
454+ private CompletableFuture <List <V >> setToValueCache (List <V > assembledValues , List <K > missedKeys , List <V > missedValues ) {
456455 try {
457456 boolean completeValueAfterCacheSet = loaderOptions .getValueCacheOptions ().isCompleteValueAfterCacheSet ();
458457 if (completeValueAfterCacheSet ) {
0 commit comments