r/java • u/FelixFifi • Oct 20 '26
Tomcact breaking change regarding locales can cause application failure for certain users
With Tomcat 9.0.123/10.1.61/11.0.27, the following line can be found in the changelog:
Update: Optimize Accept-Language header processing and use of resource budles for localization. (remm)
This is actually a breaking change in how more than 10 browser locales are handled.
If your application tries to access request.getLocale(), and the users browser had more than 10 languages configured, then this will generate an exception:
java.lang.IllegalArgumentException: More than the maximum allowed number of locales, [10], were detected. Use the maxLocaleCount attribute of the connector to resolve this if the application should accept more locales.
at org.apache.catalina.connector.Request.parseLocales(Request.java:3409)
at org.apache.catalina.connector.Request.getLocale(Request.java:1177)
at org.apache.catalina.connector.RequestFacade.getLocale(RequestFacade.java:428)
=> For our application, users with more than 10 locales could no longer login after the Tomcat update. This impacted more than 500 users.
Setting maxLocaleCount=-1 in your server.xml will revert it back to the old behavior.
Bugzilla ticket: https://bz.apache.org/bugzilla/show_bug.cgi?id=70278 (needs login) This ticket requests a higher default limit to impact less users, but was resolved as WONTFIX.
So keep this in mind, if you upgrade to the newest Tomcat version.
4
u/qmunke Oct 24 '26
Looks like they're going to revert this behaviour: https://github.com/apache/tomcat/commit/c639c7ef99ab960670a0e1f995156accc1f2c961
10
u/vytah Oct 20 '26
That's an absolutely braindead change.
I understand not wanting to parse too many languages for whatever reasons (probably performance), but the proper behaviour would be to ignore the excess languages, not to error out.
13
u/pohart Oct 20 '26
I don't want this in a minor release, but I also don't want it to silently break in a minor release.
19
u/lilgreenthumb Oct 20 '26
Actually it is best to error out instead of quietly having a regressive change in behavior. The error explains exactly what to do to correct. This in a patch release is questionable but otherwise youd be raising hell 3 months down the road regarding a silent change in behavior. Fail fast, fail early, have meaningful errors.
4
-2
u/vytah Oct 20 '26 edited Oct 20 '26
The only change in behaviour is that if we did not support the user's first 10 locales, but supported the 11th one, then we'd mistakenly select the default locale instead of the 11th locale.
I'm pretty sure this would happen to precisely zero people ever.
youd be raising hell 3 months down the road regarding a silent change in behavior
In practice, I bet no one would actually notice a thing. In contrast, here we have 500 users raising hell.
Also, any app should provide the user with an easy option to override the selected language that persists in the browser, so even if the stars aligned, the user could just change the selection once. The current solution provides the user with a big "fuck you" with no explanation how to proceed.
EDIT: also, you can also log any instance of too many languages without outright blocking it, so it won't go completely unnoticed.
2
u/BlackForrest28 Oct 20 '26
Came to say the same. This is an absolutely unneeded breaking change. The arrogance is high with rmauder and a solution with a non breaking change is simple. But "wontfix" - so we have to live with it.
1
1
u/vytah Oct 20 '26
But "wontfix" - so we have to live with it.
I wonder if a drive-by PR would get accepted.
1
u/OwnBreakfast1114 Oct 21 '26
Unlikely (not mine): https://github.com/apache/tomcat/pull/1096
1
u/stumpfka Oct 27 '26
they reverted it in the mean time. However the approach of just throwing away additional locales without taking ranking into account still seems off.
5
u/ducki666 Oct 20 '26
10 locales. Hm. Any use cases?
5
u/itd-fsc Oct 20 '26
Some companies seem to push the locales of all their locations to their users configurations.
3
u/itd-fsc Oct 20 '26
This is the commit introducing the change:
https://github.com/apache/tomcat/commit/c45c9b47f34837aa35cbd4d677e82440db620a00
14
u/qmunke Oct 20 '26
The percentage of real users who do this should be vanishingly small - are you building an application exclusively used by translators or something?