mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 13:20:57 +00:00
bug 3829: adding a null check against rare race condition of mark passing between leg finish checks
Change-Id: Ifb2a76c0bd2bcedcdddf6a4667f53ecf80095f60
This commit is contained in:
1 parent
37b3dd4310
commit
b58037fdeb
2 files changed
+9
-1
No files matched your search
+5
-1
@@ -1745,8 +1745,12 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
|
||||
result.timeInMilliseconds = time.asMillis();
|
||||
result.finished = trackedLeg.hasFinishedLeg(timePoint);
|
||||
final TimePoint legFinishTime = trackedLeg.getFinishTime();
|
||||
// See bug 3829: there is an unlikely possibility that legFinishTime is null and the call to hasFinishedLeg below
|
||||
// says that the leg has already finished. This can happen if the corresponding mark passing arrives between the two
|
||||
// calls. To avoid having to use expensive locking, we'll just double-check here if legFinishTime is null and
|
||||
// treat this as if trackedLeg.hasFinishedLeg(timePoint) had returned false.
|
||||
result.correctedTotalTime = trackedLeg.hasStartedLeg(timePoint) ? trackedLeg.getTrackedLeg().getTrackedRace().getRankingMetric().getCorrectedTime(trackedLeg.getCompetitor(),
|
||||
trackedLeg.hasFinishedLeg(timePoint) ? legFinishTime : timePoint, cache) : null;
|
||||
trackedLeg.hasFinishedLeg(timePoint) && legFinishTime != null ? legFinishTime : timePoint, cache) : null;
|
||||
// fetch the leg gap in own corrected time from the ranking metric
|
||||
final Duration gapToLeaderInOwnTime = trackedLeg.getTrackedLeg().getTrackedRace().getRankingMetric().
|
||||
getLegGapToLegLeaderInOwnTime(trackedLeg, timePoint, rankingInfo, cache);
|
||||
|
||||
+4
@@ -195,6 +195,10 @@ public interface TrackedLegOfCompetitor extends Serializable {
|
||||
*/
|
||||
TimePoint getStartTime();
|
||||
|
||||
/**
|
||||
* @return <code>null</code> if the competitor hasn't finished this leg yet; the time point when the competitor passed
|
||||
* the end waypoint of this leg otherwise
|
||||
*/
|
||||
TimePoint getFinishTime();
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user