question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullPointerException in BeaconService.matchingRegions()

See original GitHub issue

Hello! I’ve got an issue which doesn’t seem to depend on Android version or AltBeaconLib version. Anyways, it is currently confirmed to occur on some of Kyocera and Samsung devices running Android 4.4 and Android 5.0 and AltBeaconLib 2.1.4. Here’s a stack trace:

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean org.altbeacon.beacon.Region.matchesBeacon(org.altbeacon.beacon.Beacon)' on a null object reference
at org.altbeacon.beacon.service.BeaconService.matchingRegions(BeaconService.java:462)
at org.altbeacon.beacon.service.BeaconService.processBeaconFromScan(BeaconService.java:399)
at org.altbeacon.beacon.service.BeaconService.access$400(BeaconService.java:66)
at org.altbeacon.beacon.service.BeaconService$ScanProcessor.doInBackground(BeaconService.java:439)
at org.altbeacon.beacon.service.BeaconService$ScanProcessor.doInBackground(BeaconService.java:422)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 3 more

So far it happens from time to time without any visible regularity, so i can’t reproduce it on purpose, but it happens quite often. Here’s some code details: // Start ranging mRegion = new Region(UUID.randomUUID().toString(), null, null, null); mBeaconManager.startRangingBeaconsInRegion(mRegion); (UUID is changed when a program is restarted)

After some time (could be minutes, could be hours) a program crashes with the above exception. Also it’s worth to say that scan is searching for iBeacons, and seams to happen when there are a lot of Bluetooth devices nearby .

This exception happens inside next loop:

           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);
                }
            }

Of course a quickfix would be to just check if a Region is null and continue the loop if it is. Or is there any purpose for null key in rangedRegionState and monitoredRegionState maps? Thank you!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
davidgyoungcommented, Apr 19, 2019

Ok, #770 merged to master now. closing this issue for the third time!

0reactions
davidgyoungcommented, Apr 19, 2019

Argh! It looks like my fix for this in #770 was never merged. I accidentally closed the PR without merging it

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - What is a NullPointerException, and how do I fix it?
new SomeInnerClass() throws a NullPointerException when foo is null. Method references of the form name1::name2 or primaryExpression::name throws a ...
Read more >
How to Fix and Avoid NullPointerException in Java - Rollbar
NullPointerException in Java occurs when a variable is accessed which is not pointing to any object and refers to nothing or null.
Read more >
Java NullPointerException - Detect, Fix, and Best Practices
The below code snippet shows the example where the valueOf() method is used instead of toString(). Object mutex = null; //prints null System.out ......
Read more >
How to debug java.lang.NullPointerException in business rule
Hello, When I've looked in the sytem log, I've found a lot of "debug java.lang.NullPointerException" triggered from a business rule. In.
Read more >
NullPointerException (Java Platform SE 7 ) - Oracle Help Center
public class NullPointerException extends RuntimeException ... NullPointerException(). Constructs a NullPointerException with no detail message.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found