Jackson JSON Processor

CoreXML, DOM and Joda serializers and deserializers cannot be overridden

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major 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 :
    1

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.

Activity

Hide
Tatu Saloranta added a comment -

Yes, it does indeed sound like a bug. Thank you for reporting this: intention definitely is to allow overriding.

Show
Tatu Saloranta added a comment - Yes, it does indeed sound like a bug. Thank you for reporting this: intention definitely is to allow overriding.
Hide
Tatu Saloranta added a comment -

Interesting: does not seem to fail on 1.3.4, or trunk (pre-1.5.0). But does fail on 1.4. So need to only fix in 1.4 branch.

Show
Tatu Saloranta added a comment - Interesting: does not seem to fail on 1.3.4, or trunk (pre-1.5.0). But does fail on 1.4. So need to only fix in 1.4 branch.
Hide
Tatu Saloranta added a comment -

One more note; related to http://jira.codehaus.org/browse/JACKSON-220. Interesting to note that fix was good for 1.3, but not for 1.4 it seems.

Show
Tatu Saloranta added a comment - One more note; related to http://jira.codehaus.org/browse/JACKSON-220. Interesting to note that fix was good for 1.3, but not for 1.4 it seems.
Hide
Tatu Saloranta added a comment -

Fixed in 1.4 branch; was working as expected in 1.3 and trunk (1.5), as per unit test (this was fixed as part of 1.5 refactorings, but I am not sure why 1.4 had regression – bug itself was present in 1.2, as per JACKSON-220).

Show
Tatu Saloranta added a comment - Fixed in 1.4 branch; was working as expected in 1.3 and trunk (1.5), as per unit test (this was fixed as part of 1.5 refactorings, but I am not sure why 1.4 had regression – bug itself was present in 1.2, as per JACKSON-220).
Hide
Pablo I. Lalloni added a comment -

Great news! Maybe I can drop Jettison now

In 1.3 the test works as expected because DOM de/serializers were introduced in 1.4.0, so the bug was actually there. I guess...

I don't know if JACKSON-220 is actually related.

Show
Pablo I. Lalloni added a comment - Great news! Maybe I can drop Jettison now In 1.3 the test works as expected because DOM de/serializers were introduced in 1.4.0, so the bug was actually there. I guess... I don't know if JACKSON-220 is actually related.
Hide
Tatu Saloranta added a comment -

Ah. That explains 1.3 then. And obviusly 220 fix did not cover this thing; it just happened to be in same area (but map/collection serialiers are somewhat differently handled from other serializers so code path is different).

Show
Tatu Saloranta added a comment - Ah. That explains 1.3 then. And obviusly 220 fix did not cover this thing; it just happened to be in same area (but map/collection serialiers are somewhat differently handled from other serializers so code path is different).
Hide
Tatu Saloranta added a comment -

Released in 1.4.3.

Show
Tatu Saloranta added a comment - Released in 1.4.3.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: