Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6393

NestedStringResourceLoader ignores hard-coded default values and throws MissingResourceException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 7.7.0
    • 7.8.0, 8.0.0-M7
    • wicket
    • None

    Description

      The NestedStringResourceLoader ignores hard-coded default values and throws a MissingResourceException.

      Consider FormComponen.getString()

      		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, "");
      		}
      

      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:

      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	
      ...
      

      Attachments

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            rec Richard Eckart de Castilho
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: