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

don't throw exceptions when missing keys for var substitution when throwExceptionOnMissingResource setting is false

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.3.0-beta1, 1.3.0-beta2
    • 1.3.0-beta3
    • wicket
    • None

    Description

      I'm not sure how long we've had this, but I bumped my head against the fact that if you provide invalid keys (or missing) for variable substitution you get a big fat error page. That is fine for development but absolutely not fine for production/ when resource setting throwExceptionOnMissingResource is false. Even though the name of this setting does not cover missing/ wrong keys, it has the same goal: when true, it fails fast so that when you're developing you'll have to fix it if you want to go on, but when in production, such errors should never cause the application to stop functioning.

      It looks to me like

      Index: /Users/eelcohillenius/Documents/workspace_wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
      ===================================================================
      — /Users/eelcohillenius/Documents/workspace_wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java (revision 567432)
      +++ /Users/eelcohillenius/Documents/workspace_wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java (working copy)
      @@ -26,6 +26,7 @@
      import java.util.Locale;
      import java.util.Map;

      +import org.apache.wicket.Application;
      import org.apache.wicket.Component;
      import org.apache.wicket.Localizer;
      import org.apache.wicket.MarkupContainer;
      @@ -196,7 +197,8 @@
      */
      public String substitute(String string, Map vars) throws IllegalStateException

      { - return new MapVariableInterpolator(string, addDefaultVars(vars), true).toString(); + return new MapVariableInterpolator(string, addDefaultVars(vars), Application.get() + .getResourceSettings().getThrowExceptionOnMissingResource()).toString(); }

      /**

      is the best fix.

      Attachments

        Activity

          People

            ehillenius Eelco Hillenius
            ehillenius Eelco Hillenius
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: