aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanek.Schumann <atlassian@famschumann.info>2022-04-18 00:27:55 +0200
committerJanek.Schumann <atlassian@famschumann.info>2022-04-18 01:27:58 +0200
commit84e49aa2636e8f5358c6aea0889c58a61a73c4bd (patch)
tree3235b3959612f43d26d92b56c38deada55e94052
parentbb5a9d605e756b9bd36eef976870162f9d398da3 (diff)
downloadapache-velocity-engine-84e49aa2636e8f5358c6aea0889c58a61a73c4bd.tar.gz
Fixes VELOCITY-953 where VelocimacroProxy polutes context stack due to wrong handling of #break or exceptions
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java9
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;
}
/**