Issue #474: Fix -1 no-prediction sentinel corrupted into a bogus pred… - #475
Open
JRroony wants to merge 1 commit into
Open
Issue #474: Fix -1 no-prediction sentinel corrupted into a bogus pred…#475JRroony wants to merge 1 commit into
JRroony wants to merge 1 commit into
Conversation
…bogus predicted time TimepointPredictionRecord uses -1 to mean "no realtime prediction." When a record had neither a real arrival nor departure (e.g. a SKIPPED stop, or a dynamic/added trip update with no times populated), setPredictedTimes... FromTimepointPredictionRecords computed departureTime = arrivalTime + slack, turning -1 into slack*1000-1 (e.g. 29999ms). That value passes every downstream "is this a real prediction" check and gets served to API clients as if it were a genuine timestamp near the Unix epoch; one Android client turned it into an ETA of roughly -496,000 hours. - Only synthesize departureTime from arrivalTime when arrivalTime is a real prediction (> 0), and normalize any remaining non-positive time to this class's own "no prediction" sentinel (0) instead of leaking -1 downstream, matching the convention already used by this method's existing "no match found" fallback and the public API's documented behavior for predictedArrivalTime/predictedDepartureTime. - Guard the scheduled-time side effect in setPredictedArrivalTimeForInstance/ setPredictedDepartureTimeForInstance so that clearing a prediction to 0 no longer stomps a frequency-based trip's computed schedule (a latent bug that the above normalization would otherwise have newly triggered). - Fix a related copy-paste bug where ArrivalAndDepartureBeanV1 and ArrivalAndDepartureV2Bean's hasPredictedDepartureTime() checked predictedArrivalTime instead of predictedDepartureTime. Adds regression tests covering all arrival/departure combinations, including the frequency-schedule interaction, plus unit tests for the hasPredictedDepartureTime() fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThe change corrects predicted departure detection in both API beans. It also normalizes missing realtime predictions in arrival processing and preserves frequency schedules. Regression tests cover API beans, timepoint predictions, frequency service results, and singular stop-arrival output. ChangesPrediction time handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant TimepointPredictionRecord
participant ArrivalAndDepartureServiceImpl
participant ArrivalAndDepartureInstance
TimepointPredictionRecord-->>ArrivalAndDepartureServiceImpl: predicted arrival and departure times
ArrivalAndDepartureServiceImpl->>ArrivalAndDepartureServiceImpl: normalize missing predictions and apply stop slack
ArrivalAndDepartureServiceImpl->>ArrivalAndDepartureInstance: set predicted arrival and departure times
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TimepointPredictionRecorduses-1to represent a missing realtime prediction. When a matching record contained neither a valid arrival nor departure prediction,ArrivalAndDepartureServiceImpladded the stop slack to the-1arrival sentinel. For a stop with 30 seconds of slack, this produced29999, which was then exposed through the API as a genuine predicted timestamp near the Unix epoch.This caused clients to display invalid arrival information, including an Android ETA of approximately -496,000 hours. This change prevents arithmetic on the no-prediction sentinel while preserving the existing behavior for valid partial predictions.
Fixes #474
Changes
arrival + slackwhen the arrival prediction is a valid positive timestamp.0, the no-prediction value used by the arrival/departure service and API.hasPredictedDepartureTime()in the V1 and V2 arrival/departure beans to checkpredictedDepartureTimeinstead ofpredictedArrivalTime.Test plan
Ran the affected-module Maven verification on JDK 11:
mvn -pl onebusaway-api-core,onebusaway-api-webapp,onebusaway-transit-data-federation -am verify -Dgpg.skip=trueAll 17 selected modules and dependencies completed with
BUILD SUCCESS.Verified the four directly affected test classes: 34 tests passed with 0 failures, 0 errors, and 0 skipped.
ArrivalAndDepartureServiceImplTest: 25 testsArrivalsAndDeparturesBeanServiceImplTest: 5 testsArrivalAndDepartureBeanV1Test: 2 testsArrivalAndDepartureV2BeanTest: 2 testsgit diff --checkSummary by CodeRabbit
Bug Fixes
Tests