[
https://issues.apache.org/jira/browse/VELOCITY-953?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17523467#comment-17523467
]
Janek Schumann commented on VELOCITY-953:
-----------------------------------------
PR #28 did fail testing. Don't know why I didn't test it before. 😅
PR #29 is real though.
> 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.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]