I have the following piece of code:
map = db_.treeMapCreate(validMapName_)
.keySerializer(Serializer.LONG)
.valueSerializer(Serializer.LONG)
.make(); //mapDB
protected void onTaskCompletion(TaskInfo task)
{
long startBlk = task.blkId;
long count = task.count;
for (int i=0; i < count; ++i)
{
long blk = startBlk + i;
Long oldVal = map.get(blk); //NPE here
...
...
}
}
How is it possible to get an NPE while autoboxing? I can understand getting an NPE on unboxing i.e. if I had:
long oldVal = map.get(blk)
then that can throw an NPE.
Edit: Map isn't null. To be more specific, inside the BTreeMap code of mapDB, this line gets executed:
if(key==null) throw new NullPointerException();
In case someone wants to take a look: BtreeMap of mapDB Line: 1024
Partial stacktrace:
java.lang.NullPointerException
at org.mapdb.BTreeMap.get(BTreeMap.java:1024)
at org.mapdb.BTreeMap.get(BTreeMap.java:1013)
at com.service.onTaskCompletion(TaskHandler.java:312)
I'm unable to reproduce it so I cannot give a minimal, verifiable example. I have tried to run it so that I perform a get() for a key that doesn't exist, and it DOESN'T give an NPE.