Search code examples
javacircular-listmapdb

MapDB doesn't accept Serializer when creating CircularQueue


When I create circular queue in direct memory. What I have done:

BlockingQueue<String> queue = DBMaker.newMemoryDirectDB().make().getCircularQueue("my-queue");
queue.add("sdfsd");
queue.add("345345");
queue.add("dfgdfg");
queue.add("dfgdgfdgdf");
System.out.println(queue.take());

This is working fine. But when I create queue like this:

BlockingQueue<String> queue = DBMaker.newMemoryDirectDB().make().createCircularQueue("my-queue", Serializer.STRING, 1000);

It throws NullPointerException:

Exception in thread "main" java.lang.NullPointerException
    at org.mapdb.DataOutput2.writeUTF(DataOutput2.java:147)
    at org.mapdb.Serializer$1.serialize(Serializer.java:70)
    at org.mapdb.Serializer$1.serialize(Serializer.java:67)
    at org.mapdb.Queues$SimpleQueue$NodeSerializer.serialize(Queues.java:63)
    at org.mapdb.Queues$SimpleQueue$NodeSerializer.serialize(Queues.java:52)
    at org.mapdb.Store.serialize(Store.java:154)
    at org.mapdb.StoreWAL.put(StoreWAL.java:232)
    at org.mapdb.Caches$HashTable.put(Caches.java:216)
    at org.mapdb.DB.createCircularQueue(DB.java:1208)
    at com.mycompany.testjoda.Main.main(Main.java:11)

Am I missing something?


Solution

  • There is a bug in queues. It does not take null elements