Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bad date NPE #143

Merged
merged 11 commits into from
Jan 4, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ select durations.service_id, duration_seconds, days_active from (
LocalDate firstDate = LocalDate.MAX;
LocalDate lastDate = LocalDate.MIN;
for (LocalDate date : dateInfoForDate.keySet()) {
// If the date is invalid, skip.
if (date == null) continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this error happening? Shouldn't the computeIfAbsent method for adding keys and values never yield a null key? It'd be very helpful to add a failing test case to illustrate what is causing the problem here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evansiroky, there are now tests that load feeds with bad date values. When you run canLoadFeedWithBadDates, you'll see that it does encounter a null key.

if (date.isBefore(firstDate)) firstDate = date;
if (date.isAfter(lastDate)) lastDate = date;
}
Expand Down