[ 
https://issues.apache.org/jira/browse/MYFACES-2576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12837915#action_12837915
 ] 

Jan-Kees van Andel commented on MYFACES-2576:
---------------------------------------------

It has to do with safe publication of the variable on multicore systems. 
Synchronizing is more than just locking, it's also about visibility of 
variables over multiple processor caches.

Synchronizing also doesn't hurt performance in practice. I'm sure of that, 
because the expensive part is only executed once while holding the lock. If 
there happens to be a performance issue, we can always switch to some kind of 
other implementation, like Double Checked Locking, which is safe since Java 5.

The only issue I currently see is the risk of deadlock, because we're 
effectively invoking alien code within the initialization code (we can't know 
the).

> Race condition in _ExternalSpecifications methods
> -------------------------------------------------
>
>                 Key: MYFACES-2576
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2576
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0-beta-2
>         Environment: *
>            Reporter: Jan-Kees van Andel
>
> The static final fields in the _ExternalSpecifications have recently been 
> refactored into methods. But unfortunately, this has broken thread safety, 
> possibly leading to strange errors (like NPE).
> I think the only solution with the current implementation is to make the 
> methods synchronized. Volatile is not enough AFAICS...

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

Reply via email to