diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2014-04-02 13:34:37 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2014-04-02 13:34:37 +0200 |
| commit | 6caf61a70647a901a4c2e7521c99c2fc39a3f571 (patch) | |
| tree | 4da41e2e431cc67c5efb6faac5c754d17cb79425 | |
| parent | d5fdf65e31d6ad77f116631efdf505170898df18 (diff) | |
| download | cgeo-6caf61a70647a901a4c2e7521c99c2fc39a3f571.zip cgeo-6caf61a70647a901a4c2e7521c99c2fc39a3f571.tar.gz cgeo-6caf61a70647a901a4c2e7521c99c2fc39a3f571.tar.bz2 | |
fix #3716: NPE in getCachedMissingFromSearch
| -rw-r--r-- | main/src/cgeo/geocaching/DataStore.java | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/main/src/cgeo/geocaching/DataStore.java b/main/src/cgeo/geocaching/DataStore.java index a822b5d..f627d7d 100644 --- a/main/src/cgeo/geocaching/DataStore.java +++ b/main/src/cgeo/geocaching/DataStore.java @@ -3044,28 +3044,25 @@ public class DataStore { // get cached CacheListActivity final Set<String> cachedGeocodes = new HashSet<String>(); - for (Tile tile : tiles) { + for (final Tile tile : tiles) { cachedGeocodes.addAll(cacheCache.getInViewport(tile.getViewport(), CacheType.ALL)); } // remove found in search result cachedGeocodes.removeAll(searchResult.getGeocodes()); // check remaining against viewports - Set<String> missingFromSearch = new HashSet<String>(); - for (String geocode : cachedGeocodes) { + final Set<String> missingFromSearch = new HashSet<String>(); + for (final String geocode : cachedGeocodes) { if (connector.canHandle(geocode)) { - Geocache geocache = cacheCache.getCacheFromCache(geocode); - if (geocache.getCoordZoomLevel() <= maxZoom) { - boolean found = false; - for (Tile tile : tiles) { + final Geocache geocache = cacheCache.getCacheFromCache(geocode); + // TODO: parallel searches seem to have the potential to make some caches be expunged from the CacheCache (see issue #3716). + if (geocache != null && geocache.getCoordZoomLevel() <= maxZoom) { + for (final Tile tile : tiles) { if (tile.containsPoint(geocache)) { - found = true; + missingFromSearch.add(geocode); break; } } - if (found) { - missingFromSearch.add(geocode); - } } } } |
