From bf6fe20f249d9c8c526ee546d54a2f976b3d2d37 Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Thu, 11 Jan 2024 08:33:01 -0800 Subject: [PATCH] Synchronized access to future --- .../kolibri/src/main/java/org/learningequality/Task.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python-for-android/dists/kolibri/src/main/java/org/learningequality/Task.java b/python-for-android/dists/kolibri/src/main/java/org/learningequality/Task.java index bb3a6ed2..f9c48ca7 100644 --- a/python-for-android/dists/kolibri/src/main/java/org/learningequality/Task.java +++ b/python-for-android/dists/kolibri/src/main/java/org/learningequality/Task.java @@ -104,8 +104,10 @@ public static CompletableFuture reconcile(Context context, Executor exe // Run through all the states and check them, then process the results for (StateMap stateRef : StateMap.forReconciliation()) { chain = chain.thenComposeAsync((_didReconcile) -> { - if (future.isCancelled()) { - return CompletableFuture.completedFuture(_didReconcile); + synchronized (future) { + if (future.isCancelled()) { + return CompletableFuture.completedFuture(_didReconcile); + } } Log.i(TAG, "Requesting sentinel check state " + stateRef);