gpt4 book ai didi

java - Chronicle Map 玩具代码中的奇怪 NPE

转载 作者:行者123 更新时间:2023-12-02 05:24:11 25 4
gpt4 key购买 nike

我正在尝试编年史 map 2.0.0.a,并设置了一个玩具示例 map 。我想设置一个乒乓示例,在一个 JVM 中设置一个值并从另一个 JVM 中读取值。我在下面的代码中收到一个 NPE 调用 map.get 。这很奇怪,因为 map 不为空(在命令行上打印出“{}”)...以前有人见过这个吗?

    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.readSerialized(BytesMarshallableSerializer.java:119) 在net.openhft.lang.io.AbstractBytes.readInstance(AbstractBytes.java:1907) ... 16 更多

最佳答案

此问题已在以下版本中修复:

<artifactId>java-parent-pom</artifactId>
<artifactId>chronicle-map</artifactId>
<version>2.0.1a</version>

关于java - Chronicle Map 玩具代码中的奇怪 NPE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26219313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com