You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2026/08/24 10:35:00 UTC

[jira] [Work logged] (WW-5690) Defer loading the dev-mode error template until first use

     [ https://issues.apache.org/jira/browse/WW-5690?focusedWorklogId=1037413&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1037413 ]

ASF GitHub Bot logged work on WW-5690:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/Aug/26 10:34
            Start Date: 24/Aug/26 10:34
    Worklog Time Spent: 10m 
      Work Description: sonarqubecloud[bot] commented on PR #1864:
URL: https://github.com/apache/struts/pull/1864#issuecomment-5394012085

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=1864) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [B Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=1864) (required ≥ A)  
     
   <!

Issue Time Tracking
-------------------

    Worklog Id:     (was: 1037413)
    Time Spent: 20m  (was: 10m)

> Defer loading the dev-mode error template until first use
> ---------------------------------------------------------
>
>                 Key: WW-5690
>                 URL: https://issues.apache.org/jira/browse/WW-5690
>             Project: Struts 2
>          Issue Type: Task
>          Components: Core
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 7.4.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> {{DefaultDispatcherErrorHandler.init()}} built a FreeMarker configuration and loaded {{/org/apache/struts2/dispatcher/error.ftl}} on *every* startup — including production, where the problem report is never rendered. {{handleError(...)}} only reaches it when devMode is on; otherwise it delegates to the container's error page via {{sendErrorResponse(...)}}.
> So every Struts application paid to initialise FreeMarker for a page most of them never show.
> h2. Change
> {{init(ServletContext)}} now only stores the servlet context. A new {{protected getTemplate()}} loads the template on first use and caches it in a {{volatile}} field.
> No lock: two threads racing on the very first error may both load it, which is harmless — FreeMarker caches templates in its own {{Configuration}} — and cheaper than locking a path taken once per application lifetime.
> h2. Behavioural change
> A missing or unparsable {{error.ftl}} used to throw {{StrutsException}} from {{init()}} and fail the application at boot. It now surfaces on the first dev-mode error, where the existing {{catch}} in {{handleErrorInDevMode(...)}} degrades to {{sendError(code, "Unable to show problem report: ...")}}. A dev-only template should not stop a production application starting.
> h2. Scope
> Startup cost only. The {{FreemarkerManager}} injection, the {{freemarker.template.Template}} import and {{error.ftl}} itself all remain — removing them is WW-5693.
> This ticket was originally filed as "Remove core's FreeMarker dependency from DefaultDispatcherErrorHandler" and has been narrowed to the change that actually shipped.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)