mapdb icon indicating copy to clipboard operation
mapdb copied to clipboard

NPE when creating a database if parent path does not exist

Open andygrove opened this issue 12 years ago • 4 comments

Code:

DBMaker .newFileDB(file) .snapshotEnable() .syncOnCommitDisable() .makeTxMaker();

If file refers to /tmp/a/mydb.db and /tmp/a does not exist then the code fails with:

java.lang.NullPointerException at org.mapdb.StoreWAL.close(StoreWAL.java:1081) at org.mapdb.StoreDirect.(StoreDirect.java:217) at org.mapdb.StoreWAL.(StoreWAL.java:57) at org.mapdb.DBMaker.extendStoreWAL(DBMaker.java:857) at org.mapdb.DBMaker.makeEngine(DBMaker.java:639) at org.mapdb.DBMaker.makeTxMaker(DBMaker.java:606)

This is using mapdb-0.9.9-20140104.115606-2.jar

andygrove avatar Feb 11 '14 18:02 andygrove

MapDB 0.9.10 is out

jankotek avatar Feb 18 '14 14:02 jankotek

I got stung by this on an upgrade from 0.9.9. I was using just a filename in the call to DBMaker.newFileDB() and NOT a fully specified path. So the call to File.getParentFile in Volume.checkFolder() throws an NPE for me now. I think this was to fix another bug but its has now created another. Should I be required to specify some path?

Caused by: java.lang.NullPointerException at org.mapdb.Volume$FileChannelVol.checkFolder(Volume.java:681) at org.mapdb.Volume$FileChannelVol.(Volume.java:671) at org.mapdb.Volume.volumeForFile(Volume.java:184) at org.mapdb.Volume$1.createIndexVolume(Volume.java:206) at org.mapdb.StoreDirect.(StoreDirect.java:204) at org.mapdb.StoreWAL.(StoreWAL.java:58) at org.mapdb.DBMaker.extendStoreWAL(DBMaker.java:923) at org.mapdb.DBMaker.makeEngine(DBMaker.java:720) at org.mapdb.DBMaker.make(DBMaker.java:669)

scancmdr avatar Feb 27 '14 12:02 scancmdr

I think NPE exception is already fixed.

jankotek avatar Mar 09 '14 11:03 jankotek

I see the new null check, tested and works for the simple case of using just a filename in CWD, e.g. DBMaker.newFileDB(new File(filename))

Great!

scancmdr avatar Mar 09 '14 12:03 scancmdr