schildbach / public-transport-enabler

Unleash public transport data in your Java project.
https://groups.google.com/forum/#!forum/public-transport-enabler-discuss
GNU General Public License v3.0
383 stars 133 forks source link

NPE if (Public) leg.line.product is null #215

Open jaller94 opened 6 years ago

jaller94 commented 6 years ago

The new dataset from British Columbia, Canada includes SkyTrains. These are the light rail lines in Vancouver.

By error the product type can not be read and causes a NullPointerException. While the data source should be fixed on it’s own, the library should not crash when a product cannot be read.

Where it happens: https://github.com/schildbach/public-transport-enabler/blob/9fbd1f1864197b03cb6e25554991235894ccd161/enabler/src/de/schildbach/pte/dto/Trip.java#L227 How it was found: grote/Transportr#466

schildbach commented 6 years ago

A line product can be null, and in this case it's even documented.

grote commented 6 years ago

Yep, it can be null, but Trip#products() doesn't check for null and crashes.

schildbach commented 6 years ago

Good point. That's indeed a bug.

anjandev commented 6 years ago

@grote Hi, I would be happy to look at this. However, I am having some trouble setting up my development environment. I am able to clone the public-transport-enabler repository and add my changes. However, I am uncertain about how to import a local dependancy (my modified public-transport-enabler) into build.gradle for transportr. I have tried googling and researching for the past two days and I keep getting errors syncing my build.gradle.

If you could help me out. I would be happy to fix this bug and another bug I have found. Please provide me with contact information whenever you can. I can communicate via email, irc, xmpp, or matrix.

Thanks