Federico Mariani created CAMEL-24109:
----------------------------------------

             Summary: camel-xslt-saxon: doInit()/doStart() duplicate the parent 
lifecycle - stylesheet loaded and compiled twice on startup
                 Key: CAMEL-24109
                 URL: https://issues.apache.org/jira/browse/CAMEL-24109
             Project: Camel
          Issue Type: Bug
          Components: camel-xslt
    Affects Versions: 4.21.0
            Reporter: Federico Mariani
         Attachments: XsltSaxonDuplicateResourceLoadTest.java

h3. Problem
{{XsltSaxonEndpoint.doInit()}} calls {{super.doInit()}}, which already runs the 
complete parent sequence - {{setXslt(createXsltBuilder())}} (virtual dispatch, 
so it already creates the *Saxon* builder), {{loadResource(...)}} for classpath 
URIs, {{setProcessor(...)}} - and then repeats all three steps itself: a second 
builder is created (the first is discarded) and the stylesheet is resolved and 
compiled a second time.

The same duplication exists in {{doStart()}} for non-classpath URIs: the parent 
{{doStart()}} dispatches to the overridden {{loadResource()}}, then 
{{XsltSaxonEndpoint.doStart()}} calls it again - an {{http:}} stylesheet is 
fetched and compiled *twice on every start*.

Copy-paste remnant from the CAMEL-14176 module split. Wasteful (double compile, 
double remote fetch) and doubles any load-failure window.

h3. Reproducer
Attached {{XsltSaxonDuplicateResourceLoadTest.java}} - a counting 
{{URIResolver}} observes 2 top-level resolves of the stylesheet on endpoint 
startup where 1 is expected.

h3. Fix direction
Delete the duplicated bodies of {{XsltSaxonEndpoint.doInit()}}/{{doStart()}} 
(keep the {{super}} calls) - the parent lifecycle already does everything 
through the overridden virtual methods.
----
_This issue was researched and filed by Claude Code on behalf of [~fmariani] 
(GitHub: Croway), as part of a code review of camel-xslt and camel-xslt-saxon. 
The attached JUnit reproducer fails deterministically on current main 
(4.22.0-SNAPSHOT); place it in 
{{components/camel-xslt-saxon/src/test/java/org/apache/camel/component/xslt/saxon/}}._



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

Reply via email to