jankotek / JDBM3

Embedded Key Value Java Database
367 stars 94 forks source link

NPE on Array deserialization #93

Closed orabelt closed 12 years ago

orabelt commented 12 years ago
public void testArrays() throws IOException {

        Object[][] odata = new Object[][] {
            {(int)25, (short)20, (short)32, (short)16, (short)20},
        };

        String testFile = TestCaseWithTestFile.newTestFile();

        // write
        DB db = DBMaker.openFile(testFile).disableTransactions().make();
        Map<Long, Object> map = db.createTreeMap("testArrays");
        map.put(1L, odata[0]);
        db.close();

        // read
        DB dbr = DBMaker.openFile(testFile).disableTransactions().make();
        Object arr = dbr.getTreeMap("testArrays").get(1L); // <- NPE
        dbr.close();
    }

java.lang.NullPointerException at java.lang.reflect.Array.newArray(Native Method) at java.lang.reflect.Array.newInstance(Array.java:52) at org.apache.jdbm.Serialization.deserializeArrayObject(Serialization.java:1092) at org.apache.jdbm.Serialization.deserialize(Serialization.java:910) at org.apache.jdbm.Serialization.deserialize(Serialization.java:614) at org.apache.jdbm.BTreeLazyRecord.fastDeser(BTreeLazyRecord.java:69) at org.apache.jdbm.BTreeNode.readValues(BTreeNode.java:1007) at org.apache.jdbm.BTreeNode.deserialize(BTreeNode.java:947) at org.apache.jdbm.BTreeNode.deserialize(BTreeNode.java:43) at org.apache.jdbm.DBStore.fetch2(DBStore.java:400) at org.apache.jdbm.DBStore.fetch(DBStore.java:366) at org.apache.jdbm.DBCacheMRU.fetch(DBCacheMRU.java:165) at org.apache.jdbm.BTree.getRoot(BTree.java:496) at org.apache.jdbm.BTree.get(BTree.java:385) at org.apache.jdbm.BTreeMap.get(BTreeMap.java:248)

patch: Serialization.java +1091 if (clazz == null) clazz = Object.class;