avoid deadlock by nested waiting for mark passings collections monitor while holding a read lock on the course

This commit is contained in:
Axel Uhl committed 2012-12-18 00:54:59 +01:00
1 parent a6b1b36ab7
commit 4e84ea63e2
1 file changed
+3 -1
@@ -1691,11 +1691,13 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
boolean markPassingsNotEmpty;
TimePoint extendedFrom = null;
MarkPassing crossedFinishLine = null;
// getLastWaypoint() will wait for a read lock on the course; do this outside the synchronized block to avoid deadlocks
final Waypoint lastWaypoint = getRace().getCourse().getLastWaypoint();
synchronized (markPassings) {
markPassingsNotEmpty = markPassings != null && !markPassings.isEmpty();
if (markPassingsNotEmpty) {
extendedFrom = markPassings.iterator().next().getTimePoint();
crossedFinishLine = getMarkPassing(competitor, getRace().getCourse().getLastWaypoint());
crossedFinishLine = getMarkPassing(competitor, lastWaypoint);
}
}
if (markPassingsNotEmpty) {