Skip to content

Commit

Permalink
Correct broken synchronization in last commit leading to improper shu…
Browse files Browse the repository at this point in the history
…tdown.
  • Loading branch information
davidgyoung committed Jul 8, 2019
1 parent ffdfe84 commit 2bb4773
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/src/main/java/org/altbeacon/beacon/service/ScanJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public void run() {
}
ScanJobScheduler.getInstance().ensureNotificationProcessorSetup(getApplicationContext());
if (jobParameters.getJobId() == getImmediateScanJobId(ScanJob.this)) {
LogManager.i(TAG, "Running immediate scan job: instance is "+this);
LogManager.i(TAG, "Running immediate scan job: instance is "+ScanJob.this);
}
else {
LogManager.i(TAG, "Running periodic scan job: instance is "+this);
LogManager.i(TAG, "Running periodic scan job: instance is "+ScanJob.this);
}

List<ScanResult> queuedScanResults = ScanJobScheduler.getInstance().dumpBackgroundScanResultQueue();
Expand All @@ -91,7 +91,7 @@ public void run() {
// This syncronized block is around the scan start.
// Without it, it is possilbe that onStopJob is called in another thread and
// closing out the CycledScanner
synchronized(this) {
synchronized(ScanJob.this) {
if (mStopCalled) {
LogManager.d(TAG, "Quitting scan job before we even start. Somebody told us to stop.");
ScanJob.this.jobFinished(jobParameters , false);
Expand Down Expand Up @@ -190,7 +190,7 @@ private void startPassiveScanIfNeeded() {
@Override
public boolean onStopJob(JobParameters params) {
// See corresponding synchronized block in onStartJob
synchronized(this) {
synchronized(ScanJob.this) {
mStopCalled = true;
if (params.getJobId() == getPeriodicScanJobId(this)) {
LogManager.i(TAG, "onStopJob called for periodic scan " + this);
Expand Down

0 comments on commit 2bb4773

Please sign in to comment.