8000 Fix generated admin API v2 OpenAPI document locale dependency (#54852) by sanidhya02 · Pull Request #55002 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
Expand Down Expand Up @@ -81,7 +82,7 @@ public ValidationAnnotationScanner(IndexView indexView) {

private ResourceBundle loadValidationMessages() {
try {
return ResourceBundle.getBundle("org.hibernate.validator.ValidationMessages");
return ResourceBundle.getBundle("org.hibernate.validator.ValidationMessages", Locale.ROOT);
} catch (MissingResourceException e) {
log.warn("Could not load ValidationMessages resource bundle", e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,4 +587,18 @@ public static class TestWithRepeatableServerManagedFieldUnmodified {
private String protocol;
private Long createdTimestamp;
}

@Test
public void loadValidationMessages_usesRootLocaleEvenWhenDefaultLocaleIsDifferent() {
java.util.Locale originalLocale = java.util.Locale.getDefault();
try {
java.util.Locale.setDefault(java.util.Locale.GERMAN);
ValidationAnnotationScanner germanScanner = new ValidationAnnotationScanner(index);
ClassInfo classInfo = index.getClassByName(TestRepresentation.class);
String description = germanScanner.buildDescription(classInfo, "notBlankField");
assertTrue(description.contains("must not be blank"));
} finally {
java.util.Locale.setDefault(originalLocale);
}
}
}
0