GSON converter only serialises fields of controller method return type, ignoring subclass fields of response object [SPR-16461] #21006
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: backported
An issue that has been backported to maintenance branches
type: regression
A bug that is also a regression
Milestone
Fleur Kelpin opened SPR-16461 and commented
The GSON message converter used to serialise using the class of the object that was being serialised. Now it uses the return type of the controller method.
So when I have
the Cat-specific fields do not get serialised, only Animal fields.
Workarounds:
the Cat fields get serialized again.
Probably introduced in #17408, the last version that serialized Cats as Cats was 4.1.9.
To reproduce:
Run the repro project, and GET
http://localhost:8080/SPR-16461/animal
Response should be the same as
http://localhost:8080/SPR-16461/cat
but isn't.Affects: 4.3.14, 5.0.3
Reference URL: spring-attic/spring-framework-issues#175
Issue Links:
@ResponseBody
method return type available to message convertersReferenced from: commits 817a836, fd964ca
Backported to: 4.3.15
The text was updated successfully, but these errors were encountered: