diff --git a/engine/src/networking/com/jme3/network/serializing/Serializer.java b/engine/src/networking/com/jme3/network/serializing/Serializer.java index 02b91ab38..edac3ed25 100644 --- a/engine/src/networking/com/jme3/network/serializing/Serializer.java +++ b/engine/src/networking/com/jme3/network/serializing/Serializer.java @@ -57,6 +57,8 @@ import java.util.logging.Logger; public abstract class Serializer { protected static final Logger log = Logger.getLogger(Serializer.class.getName()); + private static final SerializerRegistration NULL_CLASS = new SerializerRegistration( null, Void.class, (short)-1 ); + private static final Map idRegistrations = new HashMap(); private static final Map classRegistrations = new HashMap(); @@ -267,7 +269,7 @@ public abstract class Serializer { */ public static SerializerRegistration readClass(ByteBuffer buffer) { short classID = buffer.getShort(); - if (classID == -1) return null; + if (classID == -1) return NULL_CLASS; return idRegistrations.get(classID); } @@ -280,7 +282,8 @@ public abstract class Serializer { */ public static Object readClassAndObject(ByteBuffer buffer) throws IOException { SerializerRegistration reg = readClass(buffer); - if (reg == null) return null; + if (reg == NULL_CLASS) return null; + if (reg == null) throw new SerializerException( "Class not found for buffer data." ); return reg.getSerializer().readObject(buffer, reg.getType()); }