-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
Uwe Grünheid opened SPR-16448 and commented
Hey,
maybe I am totally wrong in my expectations of using rest APIs so sorry if this request sounds to stupid but I was actually working on a legacy project and got a problem with having two media types produces via @RequestMapping
-Annotation.
In my opinion the actual delivering of request mapping especially it's handling of produced media types could be improved if there would be a check in AbstractMessageConverterMethodProcessor.writeWithMessageConverters(...) if an explicit content type was given in the response entity.
I made a little showcase which could be found in the referenced URL. Normally my old legacy service just returned a string like media type text/plain. But for getting this service towards REST I also inserted a application/json resource in my exception handler. I know that there are some other ways to get it working. For example I could just wrap my String into an resource object or just deliver also a string as error response.
But the funny fact that everything works perfectly fine if just removing the produces flag in the annotation (like picture 3) made me thinking that this could also be handled in the HttpEntityMethodProcessor.
Cheers & Thanks for taking a look :)
Uwe
Affects: 4.3.14
Reference URL: https://github.com/mixaaaa/produces-problem
Attachments:
- 2018-01-31 17_11_38-produces-problem.png (68.89 kB)
- 2018-01-31 17_11_38-produces-problem-2.png (58.62 kB)
- 2018-01-31 17_11_38-produces-problem-3.png (88.85 kB)
Issue Links:
- AbstractMessageConverterMethodProcessor ignores HttpEntityMethodProcessor's Content-Type header [SPR-16172] #20720 AbstractMessageConverterMethodProcessor ignores HttpEntityMethodProcessor's Content-Type header ("duplicates")