myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de>
Subject lazy initialisation in MyFaces-core
Date Wed, 26 Oct 2011 15:31:18 GMT
Hi!

checkstyle just found another kind of gems 


for example in AbstractAttributeMap.java


    private Collection<V> _values;

    @Override
    public Collection<V> values()
    {
        return (_values != null) ? _values : (_values = new Values());
    }

This code is not thread safe! 
_values is neither volatile nor is there any synchronized used on it!

What shall we do?
Either we declare _values volatile and use synchronized double lock idiom, or we just create
the new Values() at class initialisation.

I don't know enough about the usage of this class to make any decission - who takes over?

LieGrue,
strub


Mime
View raw message