From 147e981e7e939016710f3ae73175c759105d19f0 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Fri, 26 Jul 2024 12:01:05 +0200 Subject: [PATCH] Fix race condition making it possible to return a non-ready future from BlueNBT --- src/main/java/de/bluecolored/bluenbt/BlueNBT.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/bluecolored/bluenbt/BlueNBT.java b/src/main/java/de/bluecolored/bluenbt/BlueNBT.java index 258d95b..1e438c9 100644 --- a/src/main/java/de/bluecolored/bluenbt/BlueNBT.java +++ b/src/main/java/de/bluecolored/bluenbt/BlueNBT.java @@ -165,7 +165,7 @@ public Optional> create(TypeToken createType @SuppressWarnings("unchecked") public TypeSerializer getTypeSerializer(TypeToken type) { TypeSerializer serializer = (TypeSerializer) typeSerializerMap.get(type); - if (serializer != null) return serializer; + if (serializer != null && (!(serializer instanceof FutureTypeSerializer))) return serializer; synchronized (this) { serializer = (TypeSerializer) typeSerializerMap.get(type); @@ -196,7 +196,7 @@ public TypeSerializer getTypeSerializer(TypeToken type) { @SuppressWarnings("unchecked") public TypeDeserializer getTypeDeserializer(TypeToken type) { TypeDeserializer deserializer = (TypeDeserializer) typeDeserializerMap.get(type); - if (deserializer != null) return deserializer; + if (deserializer != null && (!(deserializer instanceof FutureTypeDeserializer))) return deserializer; synchronized (this) { deserializer = (TypeDeserializer) typeDeserializerMap.get(type); @@ -227,7 +227,7 @@ public TypeDeserializer getTypeDeserializer(TypeToken type) { @SuppressWarnings("unchecked") public InstanceCreator getInstanceCreator(TypeToken type) { InstanceCreator instanceCreator = (InstanceCreator) instanceCreatorMap.get(type); - if (instanceCreator != null) return instanceCreator; + if (instanceCreator != null && (!(instanceCreator instanceof FutureInstanceCreator))) return instanceCreator; synchronized (this) { instanceCreator = (InstanceCreator) instanceCreatorMap.get(type);