We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c7810af commit d265290Copy full SHA for d265290
location/src/main/kotlin/io/customer/location/LocationServicesImpl.kt
@@ -19,6 +19,7 @@ internal class LocationServicesImpl(
19
private val scope: CoroutineScope
20
) : LocationServices {
21
22
+ @Volatile
23
private var currentLocationJob: Job? = null
24
25
override fun setLastKnownLocation(latitude: Double, longitude: Double) {
@@ -49,7 +50,11 @@ internal class LocationServicesImpl(
49
50
try {
51
orchestrator.requestLocationUpdate()
52
} finally {
- currentLocationJob = null
53
+ // Only clear if this is still the current job — prevents
54
+ // a cancelled job's finally from nulling a newer job's reference
55
+ if (currentLocationJob === coroutineContext[Job]) {
56
+ currentLocationJob = null
57
+ }
58
}
59
60
0 commit comments