diff options
author | DoItWithASmile <36856607+DoItWithASmile@users.noreply.github.com> | 2022-04-18 01:30:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-18 01:30:45 +0200 |
commit | 5869860fb224c9443d8505aa126332bde2c965df (patch) | |
tree | 3235b3959612f43d26d92b56c38deada55e94052 | |
parent | bb5a9d605e756b9bd36eef976870162f9d398da3 (diff) | |
parent | 84e49aa2636e8f5358c6aea0889c58a61a73c4bd (diff) | |
download | apache-velocity-engine-5869860fb224c9443d8505aa126332bde2c965df.tar.gz |
Merge pull request #1 from DoItWithASmile/main
Fixes VELOCITY-953 where VelocimacroProxy polutes context stack due t…
-rw-r--r-- | velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java index 0cad8a43..d3b8ff5c 100644 --- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java +++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java @@ -216,8 +216,6 @@ public class VelocimacroProxy extends Directive // render the velocity macro context.pushCurrentMacroName(macroName); nodeTree.render(context, writer); - context.popCurrentMacroName(); - return true; } catch (RuntimeException e) { @@ -231,6 +229,11 @@ public class VelocimacroProxy extends Directive } 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(); + // clean up after the args and bodyRef // but only if they weren't overridden inside Object current = context.get(bodyReference); @@ -283,6 +286,8 @@ public class VelocimacroProxy extends Directive } } } + + return true; } /** |