Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,17 @@ public void runWhileNoSyncRuns_waitsForTheSyncInFlightToFinish() throws Exceptio
syncing.start();
assertThat(backend.readStarted.await(5, java.util.concurrent.TimeUnit.SECONDS)).isTrue();

java.util.concurrent.atomic.AtomicBoolean syncAppliedBeforeClear =
new java.util.concurrent.atomic.AtomicBoolean();
Thread clearing =
new Thread(() -> SyncService.runWhileNoSyncRuns(() -> order.add("cleared")));
new Thread(
() ->
SyncService.runWhileNoSyncRuns(
() -> {
syncAppliedBeforeClear.set(
store.appliedSnapshot != null);
order.add("cleared");
}));
clearing.start();
Thread.sleep(200L);

Expand All @@ -360,7 +369,10 @@ public void runWhileNoSyncRuns_waitsForTheSyncInFlightToFinish() throws Exceptio
backend.readReleased.countDown();
syncing.join(5_000L);
clearing.join(5_000L);
assertThat(order).containsExactly("sync finished", "cleared").inOrder();
// "sync finished" is recorded after the sync lets go of the lock, so it may land on either
// side of "cleared"; what matters is that the wipe ran only once the sync had applied.
assertThat(order).containsExactly("sync finished", "cleared");
assertThat(syncAppliedBeforeClear.get()).isTrue();
assertThat(store.appliedSnapshot).isNotNull();
}

Expand Down
Loading