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
Merged

Fix bad date NPE #143

merged 11 commits into from
Jan 4, 2019

Conversation

landonreed
Copy link
Contributor

Ensure that only non-null dates are processed by the ServiceValidator so that we don't cause exceptions when finding first/last dates.

@codecov-io
Copy link

codecov-io commented Sep 26, 2018

Codecov Report

❗ No coverage uploaded for pull request base (dev@057a962). Click here to learn what that means.
The diff coverage is 58.33%.

Impacted file tree graph

@@          Coverage Diff           @@
##             dev     #143   +/-   ##
======================================
  Coverage       ?   55.76%           
  Complexity     ?      749           
======================================
  Files          ?      144           
  Lines          ?     7212           
  Branches       ?      835           
======================================
  Hits           ?     4022           
  Misses         ?     2852           
  Partials       ?      338
Impacted Files Coverage Δ Complexity Δ
.../java/com/conveyal/gtfs/loader/JdbcGtfsLoader.java 70.33% <0%> (ø) 27 <0> (?)
src/main/java/com/conveyal/gtfs/loader/Feed.java 75% <0%> (ø) 6 <0> (?)
.../com/conveyal/gtfs/validator/ServiceValidator.java 89.59% <100%> (ø) 29 <0> (?)
.../java/com/conveyal/gtfs/error/SQLErrorStorage.java 72.22% <100%> (ø) 12 <1> (?)
src/main/java/com/conveyal/gtfs/GTFS.java 46.44% <100%> (ø) 10 <0> (?)
.../java/com/conveyal/gtfs/loader/SnapshotResult.java 100% <100%> (ø) 1 <1> (?)
...ava/com/conveyal/gtfs/loader/JdbcGtfsExporter.java 83.43% <33.33%> (ø) 23 <0> (?)
.../com/conveyal/gtfs/loader/JdbcGtfsSnapshotter.java 82.88% <50%> (ø) 27 <1> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 057a962...0311a68. Read the comment docs.

@@ -181,6 +181,8 @@ public void complete(ValidationResult validationResult) {
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.

@evansiroky
Copy link
Contributor

Reassigning to Landon. Would like an answer to #143 (comment) so I can do a better review.

@evansiroky evansiroky assigned landonreed and unassigned evansiroky Oct 27, 2018
@landonreed landonreed assigned evansiroky and unassigned landonreed Nov 26, 2018
Copy link
Contributor

@evansiroky evansiroky left a comment

Choose a reason for hiding this comment

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

See comments about changes requested.

@evansiroky evansiroky assigned landonreed and unassigned evansiroky Nov 26, 2018
@landonreed landonreed changed the base branch from some-stuff to dev December 18, 2018 21:36
@landonreed landonreed assigned evansiroky and unassigned landonreed Dec 18, 2018
@evansiroky
Copy link
Contributor

Assigning back to you @landonreed regarding #143 (comment).

@evansiroky evansiroky assigned landonreed and unassigned evansiroky Dec 20, 2018
@landonreed landonreed assigned evansiroky and unassigned landonreed Jan 3, 2019
@landonreed
Copy link
Contributor Author

Thanks for catching that, @evansiroky. I addressed that comment and fixed some merge conflicts. Let me know if it looks good.

Multimap<String, ValuePair> fieldsWithMismatches = ArrayListMultimap.create();
// Check that no validators failed during validation.
assertThat(
"No validators failed during GTFS import.",
Copy link
Contributor

Choose a reason for hiding this comment

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

This string should be reworded as it is a failure message to display in the event that the assertion fails.

Copy link
Contributor

@evansiroky evansiroky left a comment

Choose a reason for hiding this comment

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

Approved assuming #143 (comment) is addressed.

@evansiroky evansiroky assigned landonreed and unassigned evansiroky Jan 4, 2019
@landonreed landonreed merged commit 44bdd4b into dev Jan 4, 2019
@landonreed
Copy link
Contributor Author

🎉 This PR is included in version 4.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants