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

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

                Author: ASF GitHub Bot
            Created on: 24/Aug/26 12:30
            Start Date: 24/Aug/26 12:30
    Worklog Time Spent: 10m 
      Work Description: lukaszlenart merged PR #1864:
URL: https://github.com/apache/struts/pull/1864




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

    Worklog Id:     (was: 1037469)
    Time Spent: 40m  (was: 0.5h)

> 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: 40m
>  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)

Reply via email to