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

Nathan Bubna commented on VELOCITY-536:
---------------------------------------

Null check?  I see boolean checks...

Anyway, double-checked locking is apparently OK in JDK 1.5 if you are checking 
a field declared as volatile.  I learned this here:
http://crazybob.org/2007/01/lazy-loading-singletons.html    Since we are not 
targetting JDK 1.5 yet, we probably should not use DCL.

Regardless of that, i thought the issues with double-checked locking were 
surrounding lack of atomicity in construction of the checked object (and 
perhaps other surprising memory model nuances).   Since the object being 
checked is an already created boolean primitive, i don't think this is a 
problem.  Also, it solved the problem they were experiencing...

Of course, i'm definitely not a memory model expert and would happily take 
correction here in order to learn better. :)

> Velocity Engine throws NullPointer Exception when two people click on the 
> same page at the same time for the first time
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: VELOCITY-536
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-536
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.5
>            Reporter: Lei Gu
>         Attachments: 536-patch.txt, ASTDirective.java, ASTSetDirective.java, 
> VelocimacroProxy.java
>
>
> Multi-thread concurrency issue
> During our concurrency testing, we observed NullPointer exceptions being 
> thrown when two people hit the same page at the same time for the first time. 
> Upon further investigation, it turns out that we need to synchronize the init 
> method on ASTDirective, ASTSetDirective, and render method on 
> ASTSetDirective, and VelocimacroProxy.
>  Basically, the problem is introduced as the following; when two threads 
> attempts to parse and render the same template at the same time. Thread1 
> finishes parsing first and proceeds to the render method call, while thread 2 
> is still busy parsing and will overwrite the existing parse tree that is 
> being used by thread 1 for rendering purpose. Thus under certainly condition 
> a NullPointer exception will be thrown. 

-- 
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