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

Protect Against NPE in Iteration #215

Merged
merged 1 commit into from
Jul 5, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/main/java/org/altbeacon/beacon/service/BeaconService.java
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,15 @@ private List<Region> matchingRegions(Beacon beacon, Collection<Region> regions)
Iterator<Region> regionIterator = regions.iterator();
while (regionIterator.hasNext()) {
Region region = regionIterator.next();
if (region.matchesBeacon(beacon)) {
matched.add(region);
} else {
LogManager.d(TAG, "This region (%s) does not match beacon: %s", region, beacon);
// 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;
Expand Down