jankotek / mapdb

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap-memory. It is a fast and easy to use embedded Java database engine.
https://mapdb.org
Apache License 2.0
4.87k stars 872 forks source link

NullPointerException in HTreeMap.get #963

Open franck102 opened 4 years ago

franck102 commented 4 years ago

Hi,

I am getting an NPE in HTreeMap.get, the stack trace is below.

The map is created using this code:

_mapdb = DBMaker.fileDB(filePath.toFile()).
            allocateStartSize(ALLOCATE_START_SIZE).
            allocateIncrement(ALLOCATE_INCREMENT).
            closeOnJvmShutdown().
            transactionEnable().
            fileMmapEnableIfSupported().
            make();
        _metricsMap = _mapdb.
            hashMap("metrics", Serializer.STRING, new JacksonSerializer<>(MetricDefinition.class)).
            createOrOpen();

The key supplied to get() is non null, and it doesn't exist in the map. This is during load tests and there are many concurrent calls to

map.get(String key)
map.put(key, value);
map.values().stream()...
map.size()```

The stack trace:

java.lang.NullPointerException: null at org.mapdb.volume.ByteBufferVol.getSlice(ByteBufferVol.java:43) at org.mapdb.volume.ByteBufferVol.getLong(ByteBufferVol.java:122) at org.mapdb.volume.ReadOnlyVolume.getLong(ReadOnlyVolume.java:62) at org.mapdb.StoreWAL.getIndexVal(StoreWAL.kt:167) at org.mapdb.StoreWAL.get(StoreWAL.kt:499) at org.mapdb.IndexTreeListJava.treeGetNonBinary(IndexTreeListJava.java:254) at org.mapdb.IndexTreeListJava.treeGet(IndexTreeListJava.java:189) at org.mapdb.IndexTreeLongLongMap.get(IndexTreeLongLongMap.kt:82) at org.mapdb.HTreeMap.getprotected(HTreeMap.kt:629) at org.mapdb.HTreeMap.get(HTreeMap.kt:603)```