Skip to content

Commit

Permalink
[core] Fix LocaleMessageText.getDisplay when no LocaleManger (tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
skerdudou committed Apr 2, 2024
1 parent 4276e7a commit 4eee48d
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,16 @@ public String getDisplay() {
* Si LocaleManager n'est pas enregistré ou génère une exception
* alors on se contente de retourner la clé du message.
*/
final var locale = getLocaleManager().getCurrentLocale(); // (locale can be null)
return getDisplayOpt().orElse(getPanicMessage(locale));
return getDisplayOpt().orElseGet(() -> getPanicMessage());
}

private String getPanicMessage(final Locale locale) {
private String getPanicMessage() {
Locale locale = null;
try {
locale = getLocaleManager().getCurrentLocale();
} catch (final Exception e) {
// nothing
}
return new StringBuilder()
.append("<<")
.append(locale != null ? locale.getLanguage() : "xx")
Expand All @@ -169,7 +174,7 @@ private String getPanicMessage(final Locale locale) {
/** {@inheritDoc} */
@Override
public String toString() {
return getPanicMessage(null);
return getPanicMessage();
}

private LocaleManager getLocaleManager() {
Expand Down

0 comments on commit 4eee48d

Please sign in to comment.