Protect against a NPE on iteration of regions
@@ -394,12 +394,16 @@ class ScanHelper {
private List<Region> matchingRegions(Beacon beacon, Collection<Region> regions) {
List<Region> matched = new ArrayList<>();
for (Region region : regions) {
+ // Need to check if region is null in case it was removed from the collection by
+ // another thread during iteration
+ if (region != null) {
if (region.matchesBeacon(beacon)) {
matched.add(region);
} else {
LogManager.d(TAG, "This region (%s) does not match beacon: %s", region, beacon);
}
}
+ }
return matched;
}
