我正在尝试编年史地图2.0.0.a,并设置了一个玩具示例地图。我想设置一个乒乓球示例,我在一个JVM中设置一个值并从另一个JVM中读取。我在下面的代码中获得了一个NPE调用map.get。这很奇怪,因为地图不是空的(在命令行上打印出“{}”)......之前有人见过这个吗?
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:未知类型¬ at net.openhft.lang.io.serialization.BytesMarshallableSerializer.readSerializable(BytesMarshallableSerializer.java:119) at net.openhft.lang.io.AbstractBytes.readInstance(AbstractBytes.java:1907) ......还有16个
答案 0 :(得分:1)
我们希望尽快解决此问题,如果您执行以下操作,也会发生此问题:
ChronicleMap<Integer, Boolean> map = ChronicleMapBuilder.of(Integer.class, Boolean.class).create();
map.put(7, true);
Boolean currentValue = map.get(7); // IllegalStateException here
答案 1 :(得分:1)
以下版本已修复此问题:
<artifactId>java-parent-pom</artifactId>
<artifactId>chronicle-map</artifactId>
<version>2.0.1a</version>