Omertron / api-themoviedb

API for TheMovieDb.org website
GNU General Public License v3.0
154 stars 65 forks source link

NullPointerException when i retrieve trailers for MovieDb id : 1983 #3

Closed fcojean closed 11 years ago

fcojean commented 11 years ago

I'm using tag "3.5" version of the api.

When i try to call getTrailers() on MovieDb class for the specific movieDb identifier 1983, i get a NullPointerException. Indeed, trailers is null, so the call "trailer.getAll()" fail as well.

Do you think the api should do a null check on trailers attribute before trying to call getAll() method, or is it the dababase who doesn't return the right data ?

Stacktrace : java.lang.NullPointerException at com.omertron.themoviedbapi.model.MovieDb.getTrailers(MovieDb.java:337)

The following code snippet fix the problem, but i'm not sure if it is the right way to go :

public List getTrailers() { List trailerList = new ArrayList(); if(trailers != null) { trailerList = trailers.getAll(); }

    return trailerList;
}
Omertron commented 11 years ago

This is fixed in the next release of the api (v3.6) You can download the snapshot version, which is pretty stable, or wait for the proper release.

Note: The new version does change the interface to present you with a wrapper around the results, so you can query the number of results returned.