Click Listener Thread?

String lang1= LocaleContextHolder.getLocale().getLanguage(); button.addClickListener(e -> { String lang2= LocaleContextHolder.getLocale().getLanguage(); My project uses spring boot and a SessionLocaleResolver to store the current locale in a session. Spring uses a threadlocal variable. This is why I have to get the locale from the session when my Vaadin component initializes. In the code above lang1 holds the correct locale, but lang2 has a different (mabe default) value. Why is that? Is there a special click listener thread? Is there a way to initialize the locale for that thread?


I think I can answer my own question. Vaadin uses a thread pool.
When I initialize or refresh my component I call VaadinSession.getCurrent().setLocale() and within the Vaadin component I should use VaadinSession.getCurrent().getLocale() instead of the Spring function