Description
Simen Bekkhus opened SPR-13429 and commented
Not really a good title...
We have a @Controller
containing a method returning an abstract object (Foo). Another method returns an instance Bar (Bar extends Foo), and this is returned from the request-handler.
The bug is that the fields defined on Bar but not on Foo is dropped during serialization to JSON.
If I return List<Bar> instead of just Bar, it works (all fields are correctly serialized).
A workaround for us now is to return the correct type from the request-handler, manually casting it from Foo to Bar.
Manually calling new ObjectMapper().writeValueAsString on the object in the controller produces the correct JSON, but whatever Spring does to it does not.
Using Jackson 2.6.1
EDIT: Using Spring 4.2.1 fixes the problem. Sorry about the noise!
Affects: 4.2 GA
Issue Links:
- Jackson 2.6: message converter should use type only for collections [SPR-13318] #17903 Jackson 2.6: message converter should use type only for collections