Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5feec52 authored by Ian Rogers's avatar Ian Rogers
Browse files

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
parent 6f2f02e4
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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,8 +176,10 @@ 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);
        synchronized (mRunning) {
            mRunning.put(jobId, new JobRecord(job, future));
        }
    }

    /**
     * Cancels the operation corresponding to job id, identified in "EXTRA_JOB_ID".