package org.synyx.urlaubsverwaltung.user;

import org.springframework.web.servlet.i18n.SessionLocaleResolver;

import javax.servlet.http.HttpServletRequest;
import java.security.Principal;
import java.util.Locale;

class UserSettingsAwareSessionLocaleResolver extends SessionLocaleResolver {

    private final UserSettingsService userSettingsService;

    UserSettingsAwareSessionLocaleResolver(UserSettingsService userSettingsService) {
        this.userSettingsService = userSettingsService;
    }

    @Override
    protected Locale determineDefaultLocale(HttpServletRequest request) {

        final Principal userPrincipal = request.getUserPrincipal();
        if (userPrincipal == null) {
            return request.getLocale();
        }

        final Locale locale = userSettingsService.findLocaleForUsername(userPrincipal.getName())
            .orElseGet(request::getLocale);

        setLocaleContext(request, null, () -> locale);

        return locale;
    }
}

@@ -100,24 +100,57 @@
 eResolver;%0A%0A
+import javax.annotation.Nonnull;%0A
 import javax
@@ -524,24 +524,37 @@
 ice;%0A    %7D%0A%0A
+    @Nonnull%0A
     @Overrid

Add @Nonnull annotation to determineDefaultLocale