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.91k stars 875 forks source link

ClassCastException mapd 1.0.8 #548

Closed Skerberus closed 9 years ago

Skerberus commented 9 years ago

In mapdb 1.0.7 this works fine

private Var<byte[]> lastBlockVar; private byte[] lastBlockSignature;

this.lastBlockVar = database.getAtomicVar("lastBlock"); this.lastBlockSignature = lastBlockVar.get();

(here null is returned, which is OK)

In mapdb 1.0.8 an empty String is returned but should be null (starting from scratch). java.lang.ClassCastException: java.lang.String cannot be cast to [B at database.BlockMap.(BlockMap.java:46) at database.DBSet.(DBSet.java:95)

agran commented 9 years ago

https://github.com/Qoracoin/Qora/blob/0.22.0/Qora/src/database/BlockMap.java

jankotek commented 9 years ago

There were some problems with persisting nulls. So I changed default value for Atomic.Var from null to "". Solution for this is to supply your own default value as second parameter: DB.createAtomicVar("lastBlock",new byte[0]);

Or use 2.0 which has this problem solved and allows null.s