-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Milestone
Description
There seem to be a problem (checked and doesn't seem to be fixed in latest version) with the serialize method of the Dynamic static class of the StdKeySerializer.
@Override
public void serialize(Object value, JsonGenerator g, SerializerProvider provider)
throws IOException
{
Class<?> cls = value.getClass();
PropertySerializerMap m = _dynamicSerializers;
JsonSerializer<Object> ser = m.serializerFor(cls);
if (ser == null) {
ser = _findAndAddDynamic(m, cls, provider);
}
ser.serialize(value, g, provider);
}
The problem comes from the fact that when ser
is null
, the new ser
returned by _findAndAddDynamic
is incorrectly filled.
protected JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map,
Class<?> type, SerializerProvider provider) throws JsonMappingException
{
PropertySerializerMap.SerializerAndMapResult result =
// null -> for now we won't keep ref or pass BeanProperty; could change
map.findAndAddKeySerializer(type, provider, null);
// did we get a new map of serializers? If so, start using it
if (map != result.map) {
_dynamicSerializers = result.map;
}
return result.serializer;
}
So say we are in ser#1
, ser#1._dynamicSerializers
now has the correct PropertySerializerMap$Single
. However, result.serializer._dynamicSerializers
has PropertySerializerMap$Empty
.
Therefore, a new call with that result ser#2
is made which ends up creating an infinite loop.
Possible fix:
- replace
_dynamicSerializers = result.map;
byresult.serializer._dynamicSerializers = result.map
If I'm mistaken please let me know, but It seems obvious when debugging that something's is not working as intended
Metadata
Metadata
Assignees
Labels
No labels