Skip to content

Commit c00dab8

Browse files
committed
HV-1831 Ignore "null" resource bundles for locales
since the map won't be able to hold nulls Signed-off-by: marko-bekhta <[email protected]>
1 parent e88b995 commit c00dab8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

engine/src/main/java/org/hibernate/validator/internal/util/logging/Log.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,4 +946,8 @@ ConstraintDefinitionException getConstraintValidatorDefinitionConstraintMismatch
946946
@LogMessage(level = DEBUG)
947947
@Message(id = 269, value = "Unable to enable secure XML feature processing when loading %1$s: %2$s")
948948
void unableToEnableSecureFeatureProcessingSchemaXml(String fileName, String message);
949+
950+
@LogMessage(level = WARN)
951+
@Message(id = 270, value = "Message resource bundle for the %1$s locale is not available and was not pre-loaded.")
952+
void resourceBundleNotPreLoaded(Locale localeToPreload);
949953
}

engine/src/main/java/org/hibernate/validator/resourceloading/PlatformResourceBundleLocator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ public PlatformResourceBundleLocator(String bundleName,
149149
if ( !localesToInitialize.isEmpty() ) {
150150
Map<Locale, ResourceBundle> tmpPreloadedResourceBundles = CollectionHelper.newHashMap( localesToInitialize.size() );
151151
for ( Locale localeToPreload : localesToInitialize ) {
152-
tmpPreloadedResourceBundles.put( localeToPreload, doGetResourceBundle( localeToPreload ) );
152+
ResourceBundle bundle = doGetResourceBundle( localeToPreload );
153+
if ( bundle == null ) {
154+
LOG.resourceBundleNotPreLoaded( localeToPreload );
155+
continue;
156+
}
157+
tmpPreloadedResourceBundles.put( localeToPreload, bundle );
153158
}
154159
this.preloadedResourceBundles = CollectionHelper.toImmutableMap( tmpPreloadedResourceBundles );
155160
}

0 commit comments

Comments
 (0)