mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-21 03:30:12 +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
+12
-6
+12
-6
@@ -1249,13 +1249,19 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
|
||||
DummyMarkPassingWithTimePointOnly markPassingTimePoint = new DummyMarkPassingWithTimePointOnly(timePoint);
|
||||
TrackedLegOfCompetitor result = null;
|
||||
if (!competitorMarkPassings.isEmpty()) {
|
||||
MarkPassing lastMarkPassingAtOfBeforeTimePoint = competitorMarkPassings.floor(markPassingTimePoint);
|
||||
if (lastMarkPassingAtOfBeforeTimePoint != null) {
|
||||
Waypoint waypointPassedLastAtOrBeforeTimePoint = lastMarkPassingAtOfBeforeTimePoint.getWaypoint();
|
||||
// don't return a leg if competitor has already finished last leg and therefore the race
|
||||
if (waypointPassedLastAtOrBeforeTimePoint != getRace().getCourse().getLastWaypoint()) {
|
||||
result = getTrackedLegStartingAt(waypointPassedLastAtOrBeforeTimePoint).getTrackedLeg(competitor);
|
||||
final Course course = getRace().getCourse();
|
||||
course.lockForRead();
|
||||
try {
|
||||
MarkPassing lastMarkPassingAtOfBeforeTimePoint = competitorMarkPassings.floor(markPassingTimePoint);
|
||||
if (lastMarkPassingAtOfBeforeTimePoint != null) {
|
||||
Waypoint waypointPassedLastAtOrBeforeTimePoint = lastMarkPassingAtOfBeforeTimePoint.getWaypoint();
|
||||
// don't return a leg if competitor has already finished last leg and therefore the race
|
||||
if (waypointPassedLastAtOrBeforeTimePoint != course.getLastWaypoint()) {
|
||||
result = getTrackedLegStartingAt(waypointPassedLastAtOrBeforeTimePoint).getTrackedLeg(competitor);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
course.unlockAfterRead();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in new issue
Block a user