Closing an HTreeMap instance also closes the associated DB instance
galfordliu opened this issue · 0 comments
I encountered an unexpected behavior when using MapDB 3.0.9 .
According to the documentation and design of MapDB, closing an HTreeMap instance should not affect the associated DB instance. The HTreeMap should no longer be usable after its close method is called, but the associated DB instance should remain open and usable.
However, I observed that when I close an HTreeMap, the DB instance also gets closed. Specifically, after closing an HTreeMap, calling DB.getAllNames throws an exception indicating that the DB was closed.
Here's a snippet of the code that reproduces the problem:
DB db = DBMaker.memoryDB().make();
HTreeMap<String, String> map = db.hashMap("map").createOrOpen();
// use the map...
map.put("key", "value");
// close the map
map.close();
// this throws an exception, saying that the DB was closed
db.getAllNames();
This behavior does not align with the design of MapDB, and I believe it's a bug. The DB should remain open even after the associated HTreeMap is closed. Please kindly look into this issue. Thank you.