You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Claude Brisson (JIRA)" <ji...@apache.org> on 2016/07/21 22:45:21 UTC

[jira] [Comment Edited] (VELOCITY-835) Velocity Macro Stack Traces Patch

    [ https://issues.apache.org/jira/browse/VELOCITY-835?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15388557#comment-15388557 ] 

Claude Brisson edited comment on VELOCITY-835 at 7/21/16 10:45 PM:
-------------------------------------------------------------------

Nice, but I see two problems with this patch:

1) it will calculate the stacktrace line String at each macro call, which can have a big performance impact, whereas we'd want to do that only if we know we have a stacktrace to display
2) storing a macroNameStack along with a macroCallStack in InternalContextBase seems a bit redundant, better store a single stack

The way to go would be to store a single stack of pairs ( name, Info ), I guess, which would solve both problems.

Ah, and if you are to re-submitch a patch, please attach a *real* patch file, not a diff output, it's much more convenient to integrate.



was (Author: claude):
Nice, but I see two problems with this patch:

1) it will calculate the stacktrace line String at each macro call, which can have a big performance impact, whereas we'd want to do that only if we know we have a stacktrace to display
2) storing a macroNameStack along with a macroCallStack in InternalContextBase seems a bit redundant, better store a single stack

The way to go would be to store a single stack of pairs { name, Info }, I guess, which would solve both problems.

Ah, and if you are to re-submitch a patch, please attach a *real* patch file, not a diff output, it's much more convenient to integrate.


> Velocity Macro Stack Traces Patch
> ---------------------------------
>
>                 Key: VELOCITY-835
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-835
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: 1.7
>            Reporter: Luke Perkins
>              Labels: patch
>             Fix For: 1.7.x
>
>         Attachments: patchVelocityStackTraces.diff
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> Hey guys I made a patch to Velocity 1.7 to enable you to print out velocity stack traces. If you dump a stack trace in a Java function that was called from a velocity file, you usually see a bunch of calls to velocity parser functions like this in the Java stack trace:
> ...
>         at org.apache.velocity.runtime.parser.node.ASTIdentifier.execute(ASTIdentifier.java:209)
>         at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
>         at org.apache.velocity.runtime.parser.node.ASTReference.evaluate(ASTReference.java:530)
>         at org.apache.velocity.runtime.parser.node.ASTExpression.evaluate(ASTExpression.java:62)
>         at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:85)
>         at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
>         at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:87)
>         at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
>         at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:216)
>         at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:312)
>         at org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:230)
>         at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:207)
>         at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
>         at org.apache.velocity.runtime.parser.node.ASTStringLiteral.value(ASTStringLiteral.java:330)
> ...
> The velocity stack trace created by this patches is much more informative:
> Velocity Stack Trace: Invocation of method 'getAvatarUrl' in class Member
>         at avatarUrl called at common/Macros.vm[line 426, column 29]
>         at simpleAvatarUrl called at common/Macros.vm[line 487, column 22]
>         at drawSimpleImage called at common/Macros.vm[line 487, column 3]
>         at simpleMemberAvatar called at site/photo_pane.vm[line 153, column 32]
>         at displayAvatarImage called at site/photo_pane.vm[line 162, column 3]
> This sort of stack trace is very useful when debugging code and trying to figure out which sequence of macros called into the currently executing Java code that dumped out the Java stack trace. Please consider adding something like this to a future release of Velocity - it would be very useful!
> Thanks,
> Luke



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org