I see this snippet of code in ServiceReferenceInstance;

    private volatile ServiceInstance serviceInstance;
    private CompositeInstance instance;

    private CompositeInstance getInstance()
        throws ServiceImporterException
    {
        // DCL that works with Java 1.5 volatile semantics
        if( instance == null )
        {
            synchronized( this )
            {
                if( instance == null )
                {
                    serviceInstance = serviceModel.newInstance( module );
                    CompositeInstance providedInstance =
serviceInstance.instance();

                    if( providedInstance.<T>proxy() instanceof Activatable )
                    {
                        try
                        {
                            activator.activate( (Activatable)
providedInstance.proxy() );
                        }
                        catch( Exception e )
                        {
                            serviceInstance = null;
                            throw new ServiceImporterException( e );
                        }
                    }

                    instance = providedInstance;
                }
            }
        }

Is the volatile keyword really on the right variable here??


Cheers
Niclas
-- 
http://www.qi4j.org - New Energy for Java

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to