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

"Claude Brisson (Jira)" <[email protected]>
Newsgroups gmane.comp.jakarta.velocity.devel
Message-ID <[email protected]>
     [ https://issues.apache.org/jira/browse/VELOCITY-953?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claude Brisson closed VELOCITY-953.
-----------------------------------
    Resolution: Fixed

PR has been merged

> 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
>            Priority: Major
>
> 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
> {             
>     // if MacroOverflowException was thrown then it already empties the stack
>     // for everything else - e.g. other exceptions - we clean up after ourself
>     if (context.getCurrentMacroCallDepth() > 0)
>        context.popCurrentMacroName();
>     [...]
> }{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.