Skip to content
This repository was archived by the owner on Sep 28, 2022. It is now read-only.

Commit dbc0710

Browse files
author
Dominik František Bučík
authored
Merge pull request #76 from dBucik/fix_locales
fix: 🐛 Fix fallbacking of locale to the code to prevent errors
2 parents 2553b0e + ceb01c7 commit dbc0710

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

perun-oidc-server/src/main/java/cz/muni/ics/openid/connect/config/JsonMessageSource.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public JsonMessageSource(ConfigurationPropertiesBean config) {
5858
this.config = config;
5959
}
6060

61+
62+
6163
@Override
6264
protected MessageFormat resolveCode(String code, Locale locale) {
6365

@@ -73,7 +75,7 @@ protected MessageFormat resolveCode(String code, Locale locale) {
7375

7476
if (value == null) {
7577
// if it's still null, return null
76-
return null;
78+
return new MessageFormat(code, locale);
7779
} else {
7880
// otherwise format the message
7981
return new MessageFormat(value, locale);

perun-oidc-server/src/test/java/cz/muni/ics/openid/connect/config/TestJsonMessageSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public void verifyWhenLocaleExists_canResolveCode() {
4343

4444
@Test
4545
public void verifyWhenLocaleDoesNotExist_cannotResolveCode() {
46+
String code = "test";
4647
MessageFormat mf = jsonMessageSource.resolveCode("test", localeThatDoesNotHaveAFile);
47-
assertNull(mf);
48+
assertEquals(code, mf.toPattern());
4849
}
4950
}

0 commit comments

Comments
 (0)