[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-dev
Subject:    [jira] Commented: (VELOCITY-750)
From:       "Nathan Bubna (JIRA)" <dev () velocity ! apache ! org>
Date:       2009-12-31 21:11:29
Message-ID: 1467449428.1262293889912.JavaMail.jira () brutus ! apache ! org
[Download RAW message or body]


    [ https://issues.apache.org/jira/browse/VELOCITY-750?page=com.atlassian.jira.plugi \
n.system.issuetabpanels:comment-tabpanel&focusedCommentId=12795675#action_12795675 ] 

Nathan Bubna commented on VELOCITY-750:
---------------------------------------

The fundamental problem here is that anyone using a single RuntimeInstance in a \
multi-threaded environment should generally be manually init-ing the runtime.  The \
lazy initialization was not really intended for such situations, and the \
double-checked locking was meant more as a convenience than a guarantee.

With that said, i was under the impression this is NOT broken double checked locking \
in Java 1.5+.  See:

http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html  (section \
about volatile at the bottom)

Unless i've misunderstood that (or it's wrong), the init() method is synchronized and \
the initialized variable is marked volatile.   The assignment of the volatile \
initialized variable should not be reordered to happen before the initialize[Foo]() \
calls.  And the synchronized init() method shouldn't be executing simultaneously in \
multiple threads on the same instance.  But perhaps i have mis-implemented the fixed \
pattern?

> org.apache.velocity.runtime.RuntimeInstance initialization is not ThreadSafe
> ----------------------------------------------------------------------------
> 
> Key: VELOCITY-750
> URL: https://issues.apache.org/jira/browse/VELOCITY-750
> Project: Velocity
> Issue Type: Bug
> Components: Engine
> Affects Versions: 1.6.2, 1.6.x
> Environment: Vista, Java 1.6
> Reporter: Cenek Rauscher
> Fix For: 1.6.x
> 
> 
> Two threads call Velocity.evaluate() method.
> Call RuntimeInstance.parse() and requireInitialization() method.
> One thread trying make initialization, set "initializing" to true and the other \
> thread does not wait until initialization is done and go on. At next line Parser \
> parser = (Parser) parserPool.get() is NullPointerException 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: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic