mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-22 12:03:58 +00:00
fixing locking issue in TrackedRaceImpl.getCurrentLeg(...) which could have lead to NPEs during course updates
This commit is contained in:
1 parent
c2cbc75754
commit
2e8f5dd9dd
1 file changed
+7
-1
+7
-1
@@ -1249,14 +1249,20 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
|
|||||||
DummyMarkPassingWithTimePointOnly markPassingTimePoint = new DummyMarkPassingWithTimePointOnly(timePoint);
|
DummyMarkPassingWithTimePointOnly markPassingTimePoint = new DummyMarkPassingWithTimePointOnly(timePoint);
|
||||||
TrackedLegOfCompetitor result = null;
|
TrackedLegOfCompetitor result = null;
|
||||||
if (!competitorMarkPassings.isEmpty()) {
|
if (!competitorMarkPassings.isEmpty()) {
|
||||||
|
final Course course = getRace().getCourse();
|
||||||
|
course.lockForRead();
|
||||||
|
try {
|
||||||
MarkPassing lastMarkPassingAtOfBeforeTimePoint = competitorMarkPassings.floor(markPassingTimePoint);
|
MarkPassing lastMarkPassingAtOfBeforeTimePoint = competitorMarkPassings.floor(markPassingTimePoint);
|
||||||
if (lastMarkPassingAtOfBeforeTimePoint != null) {
|
if (lastMarkPassingAtOfBeforeTimePoint != null) {
|
||||||
Waypoint waypointPassedLastAtOrBeforeTimePoint = lastMarkPassingAtOfBeforeTimePoint.getWaypoint();
|
Waypoint waypointPassedLastAtOrBeforeTimePoint = lastMarkPassingAtOfBeforeTimePoint.getWaypoint();
|
||||||
// don't return a leg if competitor has already finished last leg and therefore the race
|
// don't return a leg if competitor has already finished last leg and therefore the race
|
||||||
if (waypointPassedLastAtOrBeforeTimePoint != getRace().getCourse().getLastWaypoint()) {
|
if (waypointPassedLastAtOrBeforeTimePoint != course.getLastWaypoint()) {
|
||||||
result = getTrackedLegStartingAt(waypointPassedLastAtOrBeforeTimePoint).getTrackedLeg(competitor);
|
result = getTrackedLegStartingAt(waypointPassedLastAtOrBeforeTimePoint).getTrackedLeg(competitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
course.unlockAfterRead();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user