* fix potential NPE

This commit is contained in:
Reinhard Pointner 2014-08-06 14:07:17 +00:00
parent e8749aa435
commit d1bead2d64
2 changed files with 10 additions and 5 deletions

View File

@ -118,11 +118,16 @@ public class EpisodeMatcher extends Matcher<File, Object> {
// check episode sequence integrity
Integer seqIndex = null;
for (Episode ep : episodes) {
if (seqIndex != null && !ep.getEpisode().equals(seqIndex + 1))
for (Episode it : episodes) {
// any illegal episode object breaks the chain
if (it == null || it.getEpisode() == null || it.getSpecial() != null)
return false;
seqIndex = ep.getEpisode();
// non-sequential episode index breaks the chain
if (seqIndex != null && !it.getEpisode().equals(seqIndex + 1))
return false;
seqIndex = it.getEpisode();
}
// check drill-down integrity

View File

@ -73,13 +73,13 @@ public class AnidbClient extends AbstractEpisodeListProvider {
}
@Override
public List<SearchResult> search(String query, final Locale locale) throws Exception {
public List<SearchResult> search(String query, Locale locale) throws Exception {
// bypass automatic caching since search is based on locally cached data anyway
return fetchSearchResult(query, locale);
}
@Override
public List<SearchResult> fetchSearchResult(String query, final Locale locale) throws Exception {
public List<SearchResult> fetchSearchResult(String query, Locale locale) throws Exception {
LocalSearch<SearchResult> index = new LocalSearch<SearchResult>(getAnimeTitles()) {
@Override