From 2bb4773eeb1e51e7b201cbdaa8eaf254834895c4 Mon Sep 17 00:00:00 2001 From: "David G. Young" Date: Mon, 8 Jul 2019 12:39:37 -0400 Subject: [PATCH] Correct broken synchronization in last commit leading to improper shutdown. --- .../main/java/org/altbeacon/beacon/service/ScanJob.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/main/java/org/altbeacon/beacon/service/ScanJob.java b/lib/src/main/java/org/altbeacon/beacon/service/ScanJob.java index 5c5604d50..86fbddff4 100644 --- a/lib/src/main/java/org/altbeacon/beacon/service/ScanJob.java +++ b/lib/src/main/java/org/altbeacon/beacon/service/ScanJob.java @@ -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 queuedScanResults = ScanJobScheduler.getInstance().dumpBackgroundScanResultQueue(); @@ -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); @@ -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);