[ 
https://issues.apache.org/jira/browse/NETBEANS-5136?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Carsten Hammer closed NETBEANS-5136.
------------------------------------

> double checked locking idiom wrong in inspect and transform
> -----------------------------------------------------------
>
>                 Key: NETBEANS-5136
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-5136
>             Project: NetBeans
>          Issue Type: Bug
>          Components: java - Refactoring
>    Affects Versions: 12.2
>            Reporter: Carsten Hammer
>            Priority: Critical
>
> The pattern implemented in 
> [https://bz.apache.org/netbeans/show_bug.cgi?id=248740] seems to be wrong 
> according to 
> [https://docs.google.com/document/d/1mAeEgQu4H4ADxa03k7YaVDjIP5vJBvjVIjg3DIvoc8E/edit]
> The right pattern looks like this:
>  # 334, Second code example. *_This is a serious error!_* The current code 
> can return null if multiple threads race to initialize the field. Here’s how 
> the code should look:
>  
> {code:java}
> // Double-check idiom for lazy initialization of instance fields
> private volatile FieldType field;
>  
> private FieldType getField() {
>    FieldType result = field;
>    if (result != null)    // First check (no locking)
>        return result;
>  
>    synchronized(this){        
>       if (field == null) // Second check (with locking)           
>          field = computeFieldValue();        
>    return field;    
>    }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to