You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (JIRA)" <ji...@apache.org> on 2017/06/13 19:37:00 UTC

[jira] [Resolved] (WICKET-6393) NestedStringResourceLoader ignores hard-coded default values and throws MissingResourceException

     [ https://issues.apache.org/jira/browse/WICKET-6393?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov resolved WICKET-6393.
-------------------------------------
       Resolution: Fixed
    Fix Version/s: 8.0.0-M7
                   7.8.0

> NestedStringResourceLoader ignores hard-coded default values and throws MissingResourceException
> ------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-6393
>                 URL: https://issues.apache.org/jira/browse/WICKET-6393
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 7.7.0
>            Reporter: Richard Eckart de Castilho
>            Assignee: Martin Grigorov
>             Fix For: 7.8.0, 8.0.0-M7
>
>
> The NestedStringResourceLoader ignores hard-coded default values and throws a MissingResourceException.
> Consider FormComponen.getString()
> {noformat}
> 		private String getString(Localizer localizer, String key, Component component)
> 		{
> 			triedKeys.add(key);
> 			// Note: It is important that the default value of "" is
> 			// provided to getString() not to throw a MissingResourceException or to
> 			// return a default string like "[Warning: String ..."
> 			return localizer.getString(key, component, "");
> 		}
> {noformat}
> The default value provided here actually gets lost in the call hierarchy in `Localizer.getString()` (line 232). That seems to be ok because the code there seems to expect that any code it calls will not take into account the `ThrowExceptionOnMissingResource` setting (at least that is what I infer from the method name `getStringIgnoreSettings`. However, again further down the hierarchy, `NestedStringResourceLoader.handleMissingKey()` (line 166) is called which throws a MissingResourceException and defies the default-value handling code in `Localizer.getString()`.
> Here is a stack trace:
> {noformat}
> NestedStringResourceLoader.handleMissingKey(String, Locale, String, Component, String) line: 186	
> NestedStringResourceLoader.loadNestedStringResource(Object, String, Locale, String, String) line: 130	
> NestedStringResourceLoader.loadStringResource(Component, String, Locale, String, String) line: 79	
> Localizer.getStringIgnoreSettings(String, Component, IModel<?>, Locale, String, String) line: 397	
> Localizer.getString(String, Component, IModel<?>, Locale, String, IModel<String>) line: 232	
> Localizer.getString(String, Component, IModel<?>, Locale, String, String) line: 201	
> Localizer.getString(String, Component, String) line: 150	
> FormComponent$MessageSource.getString(Localizer, String, Component) line: 201	
> FormComponent$MessageSource.getMessage(String, Map<String,Object>) line: 138	
> ValidationError.getErrorMessage(IErrorMessageSource) line: 230	
> TextField<T>(FormComponent<T>).error(IValidationError) line: 657	
> TextField<T>(FormComponent<T>).reportRequiredError() line: 1488	
> TextField<T>(FormComponent<T>).validateRequired() line: 1479	
> TextField<T>(FormComponent<T>).validate() line: 1127	
> ...
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)