Skip to content

NPE on Array deserialization #93

Closed
orabelt opened this Issue Aug 27, 2012 · 0 comments

2 participants

@orabelt
orabelt commented Aug 27, 2012
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;

@jankotek jankotek added a commit that referenced this issue Aug 28, 2012
@jankotek Fixed issue #93 f5fdf17
@jankotek jankotek closed this Aug 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.