Possible concurrency issue

28 views
Skip to first unread message

kossavot

unread,
Feb 28, 2024, 1:21:56 PMFeb 28
to onebusaway-developers
While investigating some missing trips in the bundle, as compared to trips defined in the GTFS static file, I discovered that the putTripEntry method in TransitGraphImpl.java could be called by different threads (jobs created in TripEntriesFactory), but _trips was not thread-safe as it was an ArrayList. Consequently, when processing a relatively large number of trips (approximately 200,000), some of them were getting 'lost'. To address this issue, I replaced _trips with a synchronized list:

private List<TripEntryImpl> _tripsBack = new ArrayList<TripEntryImpl>();
private List<TripEntryImpl> _trips = Collections.synchronizedList(_tripsBack);

This modification resolved the problem of missing trips.

Reply all
Reply to author
Forward
0 new messages