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

Inconsistent .close() behavior for HTreeMap with .memoryDB() and .heapDB() #954

Open puzpuzpuz opened 4 years ago

puzpuzpuz commented 4 years ago

The DB#close() method behaves in inconsistent manner in MapDB 3.0.7 behavior for HTreeMap with .memoryDB() and .heapDB().

Here is a simple reproducer:

DB db = DBMaker.memoryDB()
               .make();
HTreeMap<String, String> store = db.hashMap(TREE_NAME)
                                   .keySerializer(Serializer.STRING)
                                   .valueSerializer(Serializer.STRING)
                                   .create();
store.close();
// the next call throws java.lang.IllegalAccessError:
store.put("foo", "bar");

If you change .memoryDB() to .heapDB() the exception is not thrown (you can continue to call any operations on the store as if it's not closed). I'd expect the behavior to be the same, despite of the store type.