mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 02:10:44 +01:00
Fix flakiness of the backup tests.
It's possible that pending writes to the key value store (from using .apply()) may not be finished by the time we take the DB snapshot, resulting in us seeing stale data in the snapshot. Now we block on writes finishing.
This commit is contained in:
@@ -59,6 +59,7 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
private final Set<EmptyQueueListener> emptyQueueListeners = new CopyOnWriteArraySet<>();
|
||||
|
||||
private volatile boolean initialized = false;
|
||||
private volatile boolean shutdown = false;
|
||||
|
||||
public JobManager(@NonNull Application application, @NonNull Configuration configuration) {
|
||||
this.application = application;
|
||||
@@ -123,6 +124,13 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down the job manager entirely. Should only be used for testing!
|
||||
*/
|
||||
public void shutdown() {
|
||||
shutdown = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for {@link #addListener(JobTracker.JobFilter, JobTracker.JobListener)} that
|
||||
* takes in an ID to filter on.
|
||||
@@ -456,6 +464,10 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||
* it through here.
|
||||
*/
|
||||
private void runOnExecutor(@NonNull Runnable runnable) {
|
||||
if (shutdown) {
|
||||
return;
|
||||
}
|
||||
|
||||
executor.execute(() -> {
|
||||
waitUntilInitialized();
|
||||
runnable.run();
|
||||
|
||||
Reference in New Issue
Block a user