In my application I set up the locale when the user get into the system to localize the components. Recently I was giving a demo and noticed that the language was switching from English to Dutch without apparent reason. It turned out that the demo server (hosted in a German server) was being accessed at the same time by another person that set it to Dutch and was affecting my English demo and viceversa.
I gave it a try on my machine with different browsers, using Chrome normal and incognito modes, etc to simulate different sessions and the issue is present. Any ideas on how to handle/fix this? I thought Vaadin already handled user sessions on its own but it seems that the application's variables are shared?
Here's what I do in my application to change the locale:
@Override
public void setLocale(Locale locale) {
super.setLocale(locale);
xerb = ResourceBundle.getBundle("com.bluecubs.xinco.messages.XincoMessages", getLocale());
}
Then the xerb resource bundle is used to internationalize the UI. I tried not doing the super call but the result is the same, as if xerb was being modified by various sessions and shared among them.
Any ideas?
Same question on Vaadin's forum: https://vaadin.com/forum/-/message_boards/view_message/1091312
Edit
Using ThreadLocal pattern I added outputs to when each instance is obtained and I see different instances for each browser. (i.e. com.bluecubs.xinco.core.server.vaadin.Xinco@2114ed for the first one and com.bluecubs.xinco.core.server.vaadin.Xinco@fd68fe for the second browser) so I believe the model is used correctly. Sadly I still see the same issue.