Something I'm seeing in the wild is a trailing semicolon for Accept-Language
headers. Partial example stack trace:
java.lang.IllegalArgumentException: range=en;
at java.util.Locale$LanguageRange.<init>(Locale.java:3099)
at sun.util.locale.LocaleMatcher.parse(LocaleMatcher.java:525)
at java.util.Locale$LanguageRange.parse(Locale.java:3214)
at org.springframework.http.HttpHeaders.getAcceptLanguage(HttpHeaders.java:505)
at org.springframework.http.HttpHeaders.getAcceptLanguageAsLocales(HttpHeaders.java:526)
I don't think it would hurt to be more lenient here and drop the trailing semicolon before attempting to parse it.
Comment From: pivotal-cla
@schnapster Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
Comment From: pivotal-cla
@schnapster Thank you for signing the Contributor License Agreement!
Comment From: schnapster
@rstoyanchev apologies for the late follow-up, I'm a bit out of the loop on this by now. Could you please provide a concrete header to demonstrate your example? Or ideally a (pseudo-cody) test case similar to the one I added? I'd be happy to take another stab at this if I understand better what the additional faults are that you want Spring to be able to handle. We can also handle that in another issue / PR, imho this one already provides incremental value by itself.
Comment From: poutsma
@schnapster Thank you for submitting a PR. I have combined your code and the suggestions of @rstoyanchev into 099d0168577ab498529f18a48439a8235c14839a.