[ https://issues.apache.org/jira/browse/VELOCITY-953?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Janek Schumann updated VELOCITY-953: ------------------------------------ Description: 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} was: 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} > 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: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org