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

NullPointerException in BTreeMap.get() #5

Open
pcernocky opened this issue May 18, 2020 · 1 comment
Open

NullPointerException in BTreeMap.get() #5

pcernocky opened this issue May 18, 2020 · 1 comment

Comments

@pcernocky
Copy link

This code:

    BTreeMap<Integer, Integer> map = BTreeMap.create();

    for (int i = 0; i < 1000; i++) {
      map.put(i, i);
    }

    for (int i = 0; i < 481; i++) {
      map.remove(i);
    }

    map.get(481);  // this line fails with NullPointerException

fails with exception:

Exception in thread "main" java.lang.NullPointerException
	at uk.co.omegaprime.btreemap.BTreeMap$Internal.find(BTreeMap.java:221)
	at uk.co.omegaprime.btreemap.BTreeMap.findLeaf(BTreeMap.java:491)
	at uk.co.omegaprime.btreemap.BTreeMap.getOrDefault(BTreeMap.java:501)
	at uk.co.omegaprime.btreemap.BTreeMap.get(BTreeMap.java:470)
	at Test.main(Test.java:22)
@batterseapower
Copy link
Owner

You're right. It's not immediately clear to me why this happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants