Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4026

Exceptions swallowed in FreemarkerResult

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.12
    • 2.3.14
    • Value Stack
    • None

    Description

      I notice that exceptions parsing freemarker results are swallowed (ie: not reported, logged, or passed on). I put in a fix 2 years ago and have been updating my fix in the code ever since. This does work very well for me.

      @@ -118,6 +120,8 @@
           private String pContentType = "text/html";
           private static final String PARENT_TEMPLATE_WRITER = FreemarkerResult.class.getName() +  ".parentWriter";
       
      +    private static final Logger LOG = LoggerFactory.getLogger(FreemarkerResult.class);
      +
           public FreemarkerResult() {
               super();
           }
      @@ -200,6 +204,14 @@
                       } else {
                           template.process(model, writer);
                       }
      +            } catch (TemplateException e) {
      +                if (LOG.isErrorEnabled())
      +                    LOG.error("Error processing Freemarker result",e);
      +                throw e;
      +            } catch (IOException e) {
      +                if (LOG.isErrorEnabled())
      +                    LOG.error("Error processing Freemarker result",e);
      +                throw e;
                   } finally {
                       // Give subclasses a chance to hook into postprocessing
                       postTemplateProcess(template, model);
      

      Please consider implementing this. It would help a number of people who are having issues and need to debug their ftl files.

      Attachments

        Activity

          People

            lukaszlenart Lukasz Lenart
            xtianstone Christian Wolfgang Stone
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: