Can a Tomcat update break requests with lots of browser languages?

November 17, 2026 3 answers
Asked by r.526!portcog

I've heard that recent Tomcat releases can throw an exception when an application calls request.getLocale() and the browser sends more than 10 locales. Which versions are affected, and what can be done about it?

Answers

c.958!tundrawicket

The reported change affects Tomcat 9.0.123, 10.1.61, and 11.0.27. If the Accept-Language header contains more than the default limit of 10 locales, a call to request.getLocale() can throw an IllegalArgumentException instead of returning a locale.

Check the maxLocaleCount attribute on your connector in server.xml. You can raise it to a value such as 20, or set it to -1 to remove the limit and restore the earlier behavior. Test requests with more than 10 locales as part of the upgrade, especially on paths such as login that may depend on locale lookup.

r.526!portcog:

So the setting belongs on the connector, rather than in the application code?

2m!gimbalrivet_584:

Right. maxLocaleCount is a connector attribute, so check the configuration for the connector handling those requests.

Reply to this answer
Jessa

Don't assume eleven locales means someone speaks eleven languages. Browser settings can include several regional variants of one language, and organizational configurations may include locales for multiple locations. How many users that affects will depend on your audience.

Reply to this answer
5p!cacheferrule_384

The exception is the surprising part to me. A limit on parsing may be reasonable, but ignoring entries beyond the limit would avoid breaking a request that used to work. Raising the limit is a practical workaround, though it doesn't change that behavior if a request exceeds the new value.

Rivnex+4h:

A configurable default does at least let applications choose a higher limit or remove it if they need the old behavior.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions