[ http://issues.apache.org/jira/browse/MYFACES-338?page=comments#action_12319247 ]
Mike Youngstrom commented on MYFACES-338: ----------------------------------------- Below is a patch that fixes several problems with MessageUtils.getMessage() 1. ResourceBundle.getBundle() throws a MissingResourceException when the resource bundle cannot be found. It doesn't return null. 2. Added ClassUtils.getCurrentLoader(bundleName) to the bundleName. To fix the bug this issue was originally submitted for. 3. set summary to the messageId if the message was not found instead of returning null. This was causing a NullPointerException for me when the message was not found. I think it would be better to either return the messageId like I have it hear or throw some other message not found exception. Mike /current/share/src/java/org/apache/myfaces/util/MessageUtils.java =================================================================== --- /current/share/src/java/org/apache/myfaces/util/MessageUtils.java (revision 230382) +++ /current/share/src/java/org/apache/myfaces/util/MessageUtils.java (working copy) @@ -160,9 +160,9 @@ if (bundleName != null) { - bundle = ResourceBundle.getBundle(bundleName, locale); try { + bundle = ResourceBundle.getBundle(bundleName, locale, ClassUtils.getCurrentLoader(bundleName)); summary = bundle.getString(messageId); } catch (MissingResourceException e) {} @@ -170,14 +170,14 @@ if (summary == null) { - bundle = ResourceBundle.getBundle(DEFAULT_BUNDLE, locale, ClassUtils.getCurrentLoader(bundleName)); - if(bundle == null) - { - throw new NullPointerException(); - } - try { + bundle = ResourceBundle.getBundle(DEFAULT_BUNDLE, locale, ClassUtils.getCurrentLoader(DEFAULT_BUNDLE)); + if(bundle == null) + { + throw new NullPointerException(); + } + summary = bundle.getString(messageId); } catch(MissingResourceException e) { } @@ -185,7 +185,7 @@ if(summary == null) { - return null; + summary = messageId; } if (bundle == null) > MessageUtils should force Thread.currentThread().getContextClassLoader() on > ResourceBundle > ------------------------------------------------------------------------------------------ > > Key: MYFACES-338 > URL: http://issues.apache.org/jira/browse/MYFACES-338 > Project: MyFaces > Type: Bug > Components: JSF 1.1 > Versions: 1.0.9 beta > Reporter: Mike Youngstrom > > MessageUtils should use the thread's getContextClassLoader() when loading a > ResrouceBundle instead of MessageUtil's classloader. > Mike -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira