Files
sailing-analytics/java/com.sap.sailing.domain
Axel Uhl eb068fa670 bug6241: add PolarDataService.raceRemoved to prune per-race loading callbacks
Follow-up to holding PolarDataMiner's race-keyed collections weakly. The weak
key on callbacksWaitingForFixIngestion was defeated by its own values: a parked
callback (the scheduleWindEstimationInstallation closure) strongly captures the
same TrackedRace that keys its entry, so the entry -- and the race with all its
tracks -- would never be collected while parked. That is a brittle contract to
place on callers (they must ensure their Runnable holds no strong reference to
the race), and easy to get wrong.

Instead:
 - callbacksWaitingForFixIngestion goes back to a strong HashMap (weak keys were
   misleading there) and is pruned explicitly.
 - racesWithIngestedFixes stays a weak set (it has no values, so weak keys are
   effective) and is additionally pruned eagerly as belt-and-suspenders.
 - New PolarDataService.raceRemoved(TrackedRace) (delegating to
   PolarDataMiner.raceRemoved) forgets both collections for a race.
 - RacingEventServiceImpl.RaceAdditionListener.raceRemoved now calls
   polarDataService.raceRemoved(trackedRace) (null-guarded, since the service
   arrives via an OSGi ServiceTracker).

The runWhenPolarLoadingFinishedFor Javadoc gains an explicit LEAK CONTRACT
paragraph documenting that callers must arrange for raceRemoved to be called on
race removal, and why the map cannot rely on weak keys. Dropping a removed
instance's parked install callback loses nothing: a re-added race is a new
TrackedRace instance that gets a fresh raceAdded -> scheduleWindEstimationInstallation
-> runWhenPolarLoadingFinishedFor registration. Post-startup manual loads still
wait for the loading-pipeline drain (Gate A on racesWithIngestedFixes ensures the
race's own fixes are ingested before the callback is eligible; the drain then
covers it and any concurrently-loading races). Live TRACKING fixes flow through
the separate preFilteringProcessor chain and never perturb the loading drain.

Also documents the bounded, self-clearing lifecycle of
callbacksWaitingForLoadingOfAllRacesToRestoreToStart.
2026-08-04 17:52:39 +02:00
..
2025-09-24 16:08:59 +02:00
…
…