From e5dbb27da291b7cc3a2e72b0013a38833a5b40f4 Mon Sep 17 00:00:00 2001 From: "Ray J. Greenwell" Date: Fri, 22 Mar 2013 16:28:24 -0700 Subject: [PATCH] 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. --- .../com/threerings/util/MessageManager.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/threerings/util/MessageManager.java b/src/main/java/com/threerings/util/MessageManager.java index 846ea4f..82fac0f 100644 --- a/src/main/java/com/threerings/util/MessageManager.java +++ b/src/main/java/com/threerings/util/MessageManager.java @@ -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); }