11package org .dataloader ;
22
3+ import org .dataloader .annotations .GuardedBy ;
34import org .dataloader .annotations .Internal ;
45import org .dataloader .impl .CompletableFutureKit ;
56import org .dataloader .stats .StatisticsCollector ;
@@ -287,6 +288,7 @@ private void possiblyClearCacheEntriesOnExceptions(List<K> keys) {
287288 }
288289 }
289290
291+ @ GuardedBy ("dataLoader" )
290292 private CompletableFuture <V > loadFromCache (K key , Object loadContext , boolean batchingEnabled ) {
291293 final Object cacheKey = loadContext == null ? getCacheKey (key ) : getCacheKeyWithContext (key , loadContext );
292294
@@ -296,15 +298,12 @@ private CompletableFuture<V> loadFromCache(K key, Object loadContext, boolean ba
296298 return futureCache .get (cacheKey );
297299 }
298300
299- CompletableFuture <V > loadCallFuture ;
300- synchronized (dataLoader ) {
301- loadCallFuture = queueOrInvokeLoader (key , loadContext , batchingEnabled , true );
302- }
303-
301+ CompletableFuture <V > loadCallFuture = queueOrInvokeLoader (key , loadContext , batchingEnabled , true );
304302 futureCache .set (cacheKey , loadCallFuture );
305303 return loadCallFuture ;
306304 }
307305
306+ @ GuardedBy ("dataLoader" )
308307 private CompletableFuture <V > queueOrInvokeLoader (K key , Object loadContext , boolean batchingEnabled , boolean cachingEnabled ) {
309308 if (batchingEnabled ) {
310309 CompletableFuture <V > loadCallFuture = new CompletableFuture <>();
0 commit comments