Bug 4052: SensorFixTracks are only added for available Competitors

This commit is contained in:
Steffen Schaefer committed 2017-02-06 09:19:54 +01:00
1 parent a286b407f5
commit fbfae35264
2 files changed
+14 -6

No files matched your search

@@ -81,13 +81,20 @@ public interface DynamicTrackedRace extends TrackedRace {
DynamicGPSFixTrack<Mark, GPSFix> getOrCreateTrack(Mark mark);
/**
* Gets an existing {@link DynamicSensorFixTrack} or creates and returns a new one if there is none yet.
* Gets an existing {@link DynamicSensorFixTrack} or creates and returns a new one if there is none yet. If a
* Competitor is given who is not part of this race, no track is created.
*
* @see #getDynamicSensorTrack(Competitor, String)
*
* @param competitor the competitor to get the track for
* @param trackName the name of the track to get
* @param newTrackFactory factory to create a new track instance if there isn't one yet for the competitor and the given track name.
* @return the track for the competitor and track name
* @param competitor
* the competitor to get the track for
* @param trackName
* the name of the track to get
* @param newTrackFactory
* factory to create a new track instance if there isn't one yet for the competitor and the given track
* name.
* @return the track for the competitor and track name of null if the given {@link Competitor} isn't part of this
* race
*/
<FixT extends SensorFix, TrackT extends DynamicSensorFixTrack<Competitor, FixT>> TrackT getOrCreateSensorTrack(
Competitor competitor, String trackName, TrackFactory<TrackT> newTrackFactory);
@@ -4004,7 +4004,8 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
LockUtil.lockForWrite(sensorTracksLock);
try {
TrackT result = getTrackInternal(key);
if (result == null) {
if (result == null && tracks.containsKey(competitor)) {
// A track is only added if the given Competitor is known to participate in this race
result = newTrackFactory.get();
addSensorTrackInternal(key, result);
}