- Locale locale = subject.getPublicCredentials(Locale.class).iterator().next();
- localeChangeService.changeApplicationLocale(locale);
- UiContext.setLocale(locale);
+ Set<Locale> locales = subject.getPublicCredentials(Locale.class);
+ if (!locales.isEmpty()) {
+ Locale locale = locales.iterator().next();
+ localeChangeService.changeApplicationLocale(locale);
+ UiContext.setLocale(locale);
+ }