You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Janek Schumann (Jira)" <ji...@apache.org> on 2022/04/17 22:10:00 UTC

[jira] [Created] (VELOCITY-953) VelocimacroProxy polutes context stack due to wrong handling of #break and exceptions

Janek Schumann created VELOCITY-953:
---------------------------------------

             Summary: VelocimacroProxy polutes context stack due to wrong handling of #break and exceptions
                 Key: VELOCITY-953
                 URL: https://issues.apache.org/jira/browse/VELOCITY-953
             Project: Velocity
          Issue Type: Bug
          Components: Engine
    Affects Versions: 2.3
            Reporter: Janek Schumann


The render method of org.apache.velocity.runtime.directive.VelocimacroProxy contains the following code:
{code:java}
        try
        {
            // render the velocity macro
            context.pushCurrentMacroName(macroName);
            nodeTree.render(context, writer);
            context.popCurrentMacroName();
            return true;
        }{code}
Everytime, a VM is exited via #break - or any other exception for that matter - the context stack isn't cleaned up properly.

{{This will lead to a fatal error fast because the max call depth is reached quite soon. Even with a max call depth of 200 or more this will happen, depending on the complexity of the template and the usage of #break etc.}}

*{{Proposed solution}}*

{{Similar to #parse, move the popCurrentMacroName to finally like so}}
{code:java}
        finally
        {
            context.popCurrentTemplateName();
            [...]
        }{code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org