[MAGNOLIA-7044] Template exception handler is not set correctly after installation Created: 26/May/17  Updated: 06/Dec/22  Resolved: 24/Nov/22

Status: Closed
Project: Magnolia
Component/s: rendering
Affects Version/s: 5.4, 6.2.24
Fix Version/s: 6.3.0, 6.2.27

Type: Task Priority: Neutral
Reporter: Roman Kovařík Assignee: Adam Siska
Resolution: Fixed Votes: 0
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: 1d Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Issue Links:
Problem/Incident
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MAGNOLIA-8645 Implementation Sub-task Completed Adam Siska  
MAGNOLIA-8646 Code review Sub-task Completed Sang Ngo Huu  
MAGNOLIA-8647 Preintegration QA Sub-task Completed Sang Ngo Huu  
MAGNOLIA-8648 QA Sub-task Completed Roman Kovařík  
Template:
Acceptance criteria:
Empty
Task DoR:
Empty
Release notes required:
Yes
Date of First Response:
Sprint: Nucleus 24
Story Points: 1
Team: Nucleus
Work Started:

 Description   

Steps to reproduce

  1. Open https://nightly.magnolia-cms.com/.magnolia/admincentral#app:resources:edit;/travel-demo-marketing-tags/templates/pages/main-marketing-tags.ftl:edit
  2. Make the FTL produce an error, e.g. put unclosed expression (${nonExistingVariable}) in the body, save.
  3. Open https://nightly.magnolia-cms.com/.magnolia/admincentral#app:pages-app:detail;/travel:edit

Expected results

A yellow freemarker error is rendered.

Actual results

The freemarker error is not rendered, just logged.

Workaround

Restart the instance.

Development notes

The observed component for freemarkerConfig is not initialized at this point:

    public FreemarkerHelper(final FreemarkerConfig freemarkerConfig, TranslationService translationService, MagnoliaConfigurationProperties properties) {
...
        cfg.setTemplateExceptionHandler(freemarkerConfig.getTemplateExceptionHandler());
...

As a consequence, freemarker errors are not displayed in the page editor (it's using the default ignore handler).
After restart, FreemarkerConfig is initialized first, then FreemarkerHelper, correctly.
This has probably something to do with initialising the helper for the installation phase when the observed components are not yet initialised.



 Comments   
Comment by Roman Kovařík [ 06/Oct/22 ]

Solution: remove @Singleton annotation from the Freemarker helper so FreemarkerRenderer would get fresh/updated instance of FreemarkerHelper with the configured exception handler.

Generated at Mon Feb 12 04:20:12 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.