Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.4, 1.4.1
-
Fix Version/s: 1.4.3
-
Component/s: None
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
After a lot of research I've found that with current Jackson implementation is not possible to override default DOM serializers with annotations on mixins.
Because annotation based serializer lookup is done after matching against builtin DOM serializer so no matter what customizations you do it always uses DOMSerializer.
To be more specific, org.codehaus.jackson.map.ser.BeanSerializerFactory.createSerializer(Class<T>, SerializationConfig) first calls org.codehaus.jackson.map.ser.BasicSerializerFactory.findSerializerByPrimaryType(Class<?>, SerializationConfig) (which always returns a DOMSerializer) and if that call did not return a serializer (returned a null) then calls org.codehaus.jackson.map.ser.BeanSerializerFactory.findBeanSerializer(Class<?>, SerializationConfig) which actually looks on annotations to create a serializer.
So you cannot override DOM objects or Joda DateTime serializers embedded in jackson. I believe this is a bug/misfeature. DOM and Joda serializer should have lower precedence than user configured ones through annotations on mixins, otherwise you can not customize.
Yes, it does indeed sound like a bug. Thank you for reporting this: intention definitely is to allow overriding.