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

Jarkko Viinamäki commented on VELOCITY-669:
-------------------------------------------

Uhoh. Based on a quick peek I feel very uneasy about the changes you made. I'm 
afraid that they might change the engine behaviour/introduce new subtle bugs 
although tests seem to pass.

For instance in Parser.jjt you added that macroNames HashMap. Now 
escapedDirective method does not ask RuntimeServices anymore if some string is 
a macro or not. Instead it takes a look at macroNames. I think this is not the 
same thing since it is not guaranteed that the Parser instance knows about all 
macros.

You also removed Macro.processAndRegister and changed so that macro is 
registered late at init and it feels a bit out of place. This may have some 
side effects (unnecessary reparsing of macros etc)? Is it certain that the Node 
argument passed to init is the same argument passed to processAndRegister (the 
macro body?). 

--

I tested that by simply adding "nodeTree.init(null, rsvc);" to the last line of 
VelocimacroManager.MacroEntry constructor fixes this bug. Context can be null 
for init calls since init isn't (and should not be) context dependent. The only 
AST element that refers Context is ASTStringLiteral which can be changed to 
call super.getTemplateName() instead of getting it from the Context.

> Concurrency bug introduced in 1.7-dev
> -------------------------------------
>
>                 Key: VELOCITY-669
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-669
>             Project: Velocity
>          Issue Type: Bug
>    Affects Versions: 1.7
>            Reporter: Jarkko Viinamäki
>            Priority: Blocker
>
> Warning: current SVN head is broken - it fails under heavy load. I don't have 
> time to investigate right now but 1.6.1 release version does not have this 
> bug (1.6.2 release candidate may have it! - I'm not sure what's included 
> there). However, current SVN head fails consistently with my load testing 
> suite when I run it under JRat profiling:
> -------------------------------------------------------------------------------
> Test set: org.apache.velocity.test.load.Velocity24LoadTest
> -------------------------------------------------------------------------------
> Tests run: 250, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 71.032 sec 
> <<< FAILURE!
> testRendering(org.apache.velocity.test.load.Velocity24Test)  Time elapsed: 
> 0.125 sec  <<< ERROR!
> java.lang.NullPointerException
>       at java.io.Writer.write(Writer.java:110)
>       at 
> org.apache.velocity.runtime.parser.node.ASTText.render_$jrat(ASTText.java:83)
>       at org.apache.velocity.runtime.parser.node.ASTText.render(ASTText.java)
>       at 
> org.apache.velocity.runtime.parser.node.ASTBlock.render_$jrat(ASTBlock.java:72)
>       at 
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java)
>       at 
> org.apache.velocity.runtime.directive.VelocimacroProxy.render_$jrat(VelocimacroProxy.java:222)
>       at 
> org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java)
>       at 
> org.apache.velocity.runtime.directive.RuntimeMacro.render_$jrat(RuntimeMacro.java:295)
>       at 
> org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java)
>       at 
> org.apache.velocity.runtime.directive.RuntimeMacro.render_$jrat(RuntimeMacro.java:215)
>       at 
> org.apache.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java)
>       at 
> org.apache.velocity.runtime.parser.node.ASTDirective.render_$jrat(ASTDirective.java:198)
>       at 
> org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java)
>       at 
> org.apache.velocity.runtime.parser.node.SimpleNode.render_$jrat(SimpleNode.java:342)
>       at 
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java)
>       at org.apache.velocity.Template.merge_$jrat(Template.java:340)
>       at org.apache.velocity.Template.merge(Template.java)
>       at org.apache.velocity.Template.merge_$jrat(Template.java:248)
>       at org.apache.velocity.Template.merge(Template.java)
>       at 
> org.apache.velocity.test.load.Velocity24Test.testRendering_$jrat(Velocity24Test.java:52)
>       at 
> org.apache.velocity.test.load.Velocity24Test.testRendering(Velocity24Test.java)
> Although I'm not sure, I strongly suspect that this has got something to do 
> with refactoring done (2009-01-11) for VelocimacroProxy.init. In 1.6.1 the 
> init function initializes the nodeTree variable but if I'm not mistaken, in 
> current SVN head this does not happen(!). It seems that under certain 
> conditions the engine tries to render an ASTText node that has not been 
> initialized (char array is null) which causes this exception. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to