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

Byron Foster commented on VELOCITY-669:
---------------------------------------

This should work now, give it a shot.

The basic flow of the problem is as follows:

thread 1 attempts to render template 'foo.vm' which contains macro 'bar'
thread 2 attempts to render template 'foo.vm' 
thread 1 'foo.vm' get parsed, during parsing 'bar' is added to 
VelocimacroManager
thread 1 After parsing 'foo.vm' 'bar' gets initialized
thread 1 begins rendering 'foo.vm'
thread 2 'foo.vm' gets parsed, during parsing 'bar' is added to 
VelocimacroManager
thread 1 during rendering the initialized macro 'bar' is received from 
VelocimacroManager
thread 1 attempts to render 'bar', NullPointerException

The cleanup code I believe exaggerated an existing issue.  Before the cleanup, 
while it was not possible to execute an uninitialized macro, it was possible to 
have multiple threads in any SimpleNode.init method or Directive.init method, 
which means of course these method previously would have been required to be 
thread safe.  As it stands now any init method will only be called ounce.



> 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