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

Handle possibily empty lists when iterating #57

Open
joshproehl opened this issue Mar 6, 2015 · 0 comments
Open

Handle possibily empty lists when iterating #57

joshproehl opened this issue Mar 6, 2015 · 0 comments

Comments

@joshproehl
Copy link
Member

In MapsActivity.drawHighway for example, we use for loops to run through the list, and assume that the list will contain elements!
This is only one example, the entire application should be checked for for loops like this which have the possibility of causing a NullPointerException!

This can cause the application to crash. A better use would be to use list iterators and account for the possibility that the list is empty.

Steps to reproduce:

  • Edit APIEntity.getNestedEntityUrlComponent(), change the URL. (Add an extra s before "s/")
    (This will force calls to highways/x/stations to fail.)
  • Observe in the log output that the application will handle the failures, but that this causes the list of highways to be empty.
  • Observe that the application crashes with a NullPointerException, caused by the for loop assuming that the list is non-empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant