RadiusNetworks/android-ibeacon-service — pull request #36 by keremgocen (2014-05-02 19:24:14+00:00)
Title: Fix for #29 ConcurrentModificationException

Synchronized rangeState object in the service to avoid modification by
AsyncTask while iterating over iBeacons.

ps:This happens rarely so it's hard to reproduce but I suspect the between scan period falls short when too many beacons are advertising, scan cycle is ended prematurely in those cases which results with ConcurrentModificationException on iBeacon collection via the rangeState object reference. While processRangeData() is trying to clear the iBeacon colllection, processIBeaconFromScan() is called from ScanProcessor()'s AsyncTask to add the beacon into the same collection. This update should fix it, tested for longer than 24h with ~50 beacons and 5 second between scan period without any exceptions. I suspect the excessive synchronization of iBeacon object is redundant but this is the safe setup I have tested with so far. Needs confirmation.