11package org .dataloader .strategy ;
22
3+ import org .dataloader .DataLoader ;
34import org .dataloader .DataLoaderRegistry ;
45import org .dataloader .DispatchStrategy ;
56import org .dataloader .annotations .VisibleForTesting ;
67import org .dataloader .impl .Assertions ;
8+ import org .jspecify .annotations .NullMarked ;
79import org .jspecify .annotations .Nullable ;
810
911import java .time .Duration ;
12+ import java .util .concurrent .CompletableFuture ;
1013import java .util .concurrent .ScheduledExecutorService ;
1114import java .util .concurrent .ScheduledFuture ;
1215import java .util .concurrent .TimeUnit ;
2528 * In practice this will greedily fill up DataLoader keys while walking the chain to provide a nice balance of
2629 * batching/dedupe/caching while not needing to worry about manually dispatching the tree.
2730 */
31+ @ NullMarked
2832public class GreedyLevelByLevelChainedDispatchStrategy implements DispatchStrategy {
2933
3034 private static final Duration DEFAULT_FALLBACK_TIMEOUT = Duration .ofMillis (30 );
@@ -35,7 +39,9 @@ public class GreedyLevelByLevelChainedDispatchStrategy implements DispatchStrate
3539 private final Object dispatchLock = new Object ();
3640
3741 // only used for tests
38- private Runnable onIteration ;
42+ Runnable onIteration = () -> {
43+
44+ };
3945
4046 private final Duration fallbackTimeout ;
4147 @ Nullable private ScheduledFuture <?> fallbackDispatchFuture = null ;
@@ -53,7 +59,7 @@ public void onRegistryCreation(DataLoaderRegistry registry) {
5359 }
5460
5561 @ Override
56- public void loadCalled () {
62+ public void loadCalled (DataLoader <?, ?> dataLoader , Object key , @ Nullable Object loaderContext , CompletableFuture <?> result ) {
5763 // initial load called
5864 pendingLoadCount .incrementAndGet ();
5965 int previousTotal = totalWorkCount .getAndIncrement ();
@@ -63,7 +69,7 @@ public void loadCalled() {
6369 }
6470
6571 @ Override
66- public void loadCompleted () {
72+ public void loadCompleted (DataLoader <?, ?> dataLoader , @ Nullable Object result , @ Nullable Throwable error ) {
6773 pendingLoadCount .decrementAndGet ();
6874 }
6975
0 commit comments