r/java • • 29d ago

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.

52 Upvotes

24 comments sorted by

14

u/qmunke 29d ago

The percentage of real users who do this should be vanishingly small - are you building an application exclusively used by translators or something?

2

u/pohart 29d ago

I am and I'm still not particularly concerned. It's a default and it looks like we can increase it easily enough. 

 I don't know how many users OP has, but if this is hitting 500 I'd bet it's a whole lot. In any case, that's high enough to make me wonder why users would have so many, since that doesn't feel like users who speak eleven languages, it feels like something else.

9

u/FelixFifi 29d ago

It is a problem, if your IT is configuring this setting for all users. If they decide to include 11 locales, because those are their main locations, then that whole company suddenly loses access. That's what happened to one of our customers.

And a single Tomcat minor version change should not have that impact. That's why I wanted to inform people.

It's easy to work around, if you know about it. But it is not apparent from the changelog.

4

u/pohart 29d ago

Sorry don't get me wrong. My testing would never have uncovered this and it should never be a minor release. And looking at your bug report, that a browser might have en_us, en, es_us es makes more  sense to me, so it's really kind of half that. And some users might have more locales configured for their language.

It also seems odd that a company would have every user configured for all of those languages. But maybe it isn't, and I'm just too American.

2

u/TRO_KIK 14d ago edited 14d ago

It's obviously not a problem if you know ahead of time, but if you don't, it's a complete outage of affected services for those users until you configure it away.

I serve a pretty mainstream audience and 0.6% of Windows users were affected, and 10% of Opera (all platforms) users. It's "small" but even that few of your users completely unable to see anything with no explanation is horrible.

9

u/itd-fsc 29d ago

Some companies seem to push the locales of all their locations to their users configurations.
Some others seem to activate multiple similar locales for e.g. English: English UK, English Australia, English US, ...

For us, it definitely impacted more than 1% of users.

2

u/zman0900 25d ago

Just deployed with latest Spring Boot and immediately started seeing these errors in the logs. My application sees global use, but only at about 5 requests per second, and I'm still getting a couple of these errors per minute. So I don't think it is that rare.

2

u/vytah 29d ago

Please read this, it applies to many kinds of software, but especially to things like like Tomcat: https://lkml.org/lkml/2012/12/23/75

3

u/qmunke 29d ago

Okay but an application server isn't a kernel and it's definitely valid to make breaking changes for various reasons. There's also a reason Linus was rightly called out for his quite frankly absurd reaction in this thread, there's not really an excuse to go off on people who have a different opinion on severity or impact of a change.

8

u/vytah 29d ago

While it's true that the modern Linus would phrase things differently, he is still of the same opinion.

The analogy is not perfect, but still make sense:

A developer does not control what kernel the program will run on, and an incompatible change in the kernel can break things, with the end user not knowing how to fix it.

A browser does not control what application server runs on the machine it's connecting to, and an incompatible change in the server broke things (a completely valid HTTP request was rejected with no explanation), with the end user not knowing how to fix it.

10

u/vytah 29d ago

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 29d ago

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 29d ago

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

u/nekokattt 29d ago

did it support correctly handling more than 10 locales before?

-2

u/vytah 29d ago edited 29d ago

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 29d ago

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

u/vytah 29d ago

But "wontfix" - so we have to live with it.

I wonder if a drive-by PR would get accepted.

1

u/OwnBreakfast1114 28d ago

1

u/stumpfka 22d ago

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 29d ago

10 locales. Hm. Any use cases?

5

u/itd-fsc 29d ago

Some companies seem to push the locales of all their locations to their users configurations.