You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Jan-Kees van Andel (JIRA)" <de...@myfaces.apache.org> on 2010/02/24 14:42:28 UTC

[jira] Created: (MYFACES-2576) Race condition in _ExternalSpecifications methods

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.


[jira] Commented: (MYFACES-2576) Race condition in _ExternalSpecifications methods

Posted by "Jan-Kees van Andel (JIRA)" <de...@myfaces.apache.org>.
    [ 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.


[jira] Commented: (MYFACES-2576) Race condition in _ExternalSpecifications methods

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12837807#action_12837807 ] 

Jakob Korherr commented on MYFACES-2576:
----------------------------------------

How would you be able to get a NullPointerException with the current state of _ExternalSpecifications? From my point of view the only thing which could happen is that the properties get configured more than once, which should not be a problem!

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