When trying to test our language fallback scenario using spring-test, I've noticed that the following scenario is failing, while it works just fine when reproduced with curl (the actual content of the test has been replaced due to the proprietary nature of the project):
After the locale is set, unlike in the first two if cases, the header is not actually added to the response, causing failure in the tests. For reference this is how the header is set in the controller:
I would expect the header to actually be set, unless there's something I've missed when browsing through the mechanism - if so, I would love if you could point me to the relevant resources to understand this better.
#19773 Mock MVC / RequestBuilder should handle Accept-Language header appropriately
Support for setting the Content-Language header was introduced relatively recently, in 5.0 RC1 #19773. Then it looks like an accidental regression was introduced in #cc74a2 in 5.0 RC3, so in effect this never did work as expected in a GA release.
This seems like an accident indeed, dating back to the original code that meant to be able to set null there. After this having been changed to Locale.getDefault() thereafter anyway, I see no issue with a straight setLocale call now.