forked from upstream-mirrors/OpenTracks
Fix null race-condition for heart rate sensor data
The previous implementation was technically safe because the sensor never had null values. Now that it can, the calls to getHeartRate must be stored instead of repeated to avoid a race condition where the sensor data become null between the null-check and the second call
This commit is contained in:
@@ -161,8 +161,9 @@ public class SensorDataSet {
|
||||
trackPoint.setPosition(gps.getAggregatedValue(trackPointCreator.createNow()));
|
||||
}
|
||||
|
||||
if (getHeartRate() != null) {
|
||||
trackPoint.setHeartRate(getHeartRate().first);
|
||||
Pair<HeartRate, String> heartRate = getHeartRate();
|
||||
if (heartRate != null) {
|
||||
trackPoint.setHeartRate(heartRate.first);
|
||||
}
|
||||
|
||||
if (getCadence() != null) {
|
||||
|
||||
Reference in New Issue
Block a user