创建CircularQueue时,MapDB不接受Serializer

时间:2014-10-15 10:35:09

标签: java circular-list mapdb

当我在直接内存中创建循环队列时。我做了什么:

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());

这很好用。但是当我像这样创建队列时:

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

抛出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)

我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

队列中有一个错误。它不带空元素