Fix bad locking.
When synchronizing on a field, it should be final to avoid locking on different objects. Missing synchronization on use of mRunning caught by Error Prone's @GuardedBy checker. Bug: 27723540 Change-Id: I9d7c9e37f8ef5f7f49707bfdf607a6b73b9654d8
This commit is contained in:
@@ -95,7 +95,7 @@ public class FileOperationService extends Service implements Job.Listener {
|
||||
private NotificationManager mNotificationManager;
|
||||
|
||||
@GuardedBy("mRunning")
|
||||
private Map<String, JobRecord> mRunning = new HashMap<>();
|
||||
private final Map<String, JobRecord> mRunning = new HashMap<>();
|
||||
|
||||
private int mLastServiceId;
|
||||
|
||||
@@ -176,7 +176,9 @@ public class FileOperationService extends Service implements Job.Listener {
|
||||
if (DEBUG) Log.d(
|
||||
TAG, "Scheduling job " + job.id + " to run in " + delay + " milliseconds.");
|
||||
ScheduledFuture<?> future = executor.schedule(job, delay, TimeUnit.MILLISECONDS);
|
||||
mRunning.put(jobId, new JobRecord(job, future));
|
||||
synchronized (mRunning) {
|
||||
mRunning.put(jobId, new JobRecord(job, future));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user