Bugfix when the parent bundle is missing.
When I had added this feature I verified that it would be OK to look up a non-existant bundle, and even added a little note in the code. But, it's the ResourceBundle that will be null, a MessageBundle is always returned. And so, when it tried to initialize that bogus MessageBundle and recursed into this same patch of code, the newly added check for __parent would cause an NPE.
This commit is contained in:
@@ -186,15 +186,15 @@ public class MessageManager
|
||||
*/
|
||||
protected void initBundle (MessageBundle bundle, String path, ResourceBundle rbundle)
|
||||
{
|
||||
MessageBundle parentBundle = null;
|
||||
try {
|
||||
parentBundle = getBundle(rbundle.getString("__parent"));
|
||||
// Note: if getBundle() fails to find our parent it will log a warning and return null
|
||||
} catch (MissingResourceException mre ) {
|
||||
// no resource named __parent: it's ok.
|
||||
}
|
||||
if (parentBundle == null) {
|
||||
parentBundle = _global;
|
||||
MessageBundle parentBundle = _global;
|
||||
if (rbundle != null) {
|
||||
try {
|
||||
parentBundle = getBundle(rbundle.getString("__parent"));
|
||||
// Note: getBundle() won't fail, if the parent bundle doesn't exist it will
|
||||
// log warning and return a new MessageBundle containing a null ResourceBundle.
|
||||
} catch (MissingResourceException mre ) {
|
||||
// no resource named __parent: perfectly ok, we'll fall back to using the global
|
||||
}
|
||||
}
|
||||
bundle.init(this, path, rbundle, parentBundle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user