我正在尝试编年史地图 2.0.0.a,并设置了一个玩具示例地图。我想设置一个乒乓示例,我在一个 JVM 中设置一个值并从另一个 JVM 中读取。我在下面的代码中得到了一个调用 map.get 的 NPE。这很奇怪,因为地图不为空(在命令行上打印出“{}”)......有人见过这个吗?
boolean target = true;
File file = new File(...);
ChronicleMapBuilder<Integer, Boolean> builder = ChronicleMapBuilder
.of(Integer.class, Boolean.class);
ChronicleMap<Integer, Boolean> map = builder.create(file);
if (map == null) {
System.out.println("map is null. giving up...");
return;
} else {
System.out.println("map is " + map); // this prints out "{}"
}
while(! Thread.currentThread().isInterrupted()) {
boolean currentValue = map.get(7); // NPE here...
...
Thread.sleep(500);
}
更多信息......如果我在 while 循环之前添加一行到map.put(7, true)
,然后map.get(7)
抛出一个不同的异常:
Exception in thread "main" java.lang.IllegalStateException: java.lang.IllegalStateException: Unknown type ¬
at net.openhft.lang.io.AbstractBytes.readInstance(AbstractBytes.java:1909)
at net.openhft.lang.io.AbstractBytes.readEnum(AbstractBytes.java:1764)
at net.openhft.lang.io.serialization.BytesMarshallableSerializer.readSerializable(BytesMarshallableSerializer.java:109)
at net.openhft.chronicle.map.SerializationBuilder$SerializableMarshaller.read(SerializationBuilder.java:348)
at net.openhft.chronicle.map.serialization.BytesReaders$SimpleBytesReader.read(BytesReaders.java:44)
at net.openhft.chronicle.map.VanillaChronicleMap$Segment.readValue(VanillaChronicleMap.java:947)
at net.openhft.chronicle.map.VanillaChronicleMap$Segment.readValue(VanillaChronicleMap.java:940)
at net.openhft.chronicle.map.VanillaChronicleMap$Segment.onKeyPresentOnAcquire(VanillaChronicleMap.java:752)
at net.openhft.chronicle.map.VanillaChronicleMap$Segment.acquire(VanillaChronicleMap.java:710)
at net.openhft.chronicle.map.VanillaChronicleMap.lookupUsing(VanillaChronicleMap.java:373)
at net.openhft.chronicle.map.VanillaChronicleMap.get(VanillaChronicleMap.java:350)
at com.getco.risk.common.contract.Contracts.main(Contracts.java:233)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
引起:java.lang.IllegalStateException:net.openhft.lang.io.serialization.BytesMarshallableSerializer.readSerializable(BytesMarshallableSerializer.java:119) 处的未知类型 ¬ net.openhft.lang.io.AbstractBytes.readInstance(AbstractBytes.java: 1907) ... 16 更多