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:
Ray J. Greenwell
2013-03-22 16:28:24 -07:00
parent 218f6dd354
commit e5dbb27da2
@@ -186,15 +186,15 @@ public class MessageManager
*/ */
protected void initBundle (MessageBundle bundle, String path, ResourceBundle rbundle) protected void initBundle (MessageBundle bundle, String path, ResourceBundle rbundle)
{ {
MessageBundle parentBundle = null; MessageBundle parentBundle = _global;
try { if (rbundle != null) {
parentBundle = getBundle(rbundle.getString("__parent")); try {
// Note: if getBundle() fails to find our parent it will log a warning and return null parentBundle = getBundle(rbundle.getString("__parent"));
} catch (MissingResourceException mre ) { // Note: getBundle() won't fail, if the parent bundle doesn't exist it will
// no resource named __parent: it's ok. // log warning and return a new MessageBundle containing a null ResourceBundle.
} } catch (MissingResourceException mre ) {
if (parentBundle == null) { // no resource named __parent: perfectly ok, we'll fall back to using the global
parentBundle = _global; }
} }
bundle.init(this, path, rbundle, parentBundle); bundle.init(this, path, rbundle, parentBundle);
} }