Emmanuel Lecharny created FC-32:
-----------------------------------

             Summary: setters that take a list as an argument does not copy it 
internally
                 Key: FC-32
                 URL: https://issues.apache.org/jira/browse/FC-32
             Project: FORTRESS-CORE
          Issue Type: Bug
    Affects Versions: 1.0.0-RC39
            Reporter: Emmanuel Lecharny
             Fix For: 1.0.0


There are many methods like :

{code}
    public void setReqMod( List<String> reqMod )
    {
        this.reqMod = reqMod;
    }
{code}

Storing the list that is passed is doom to major issues when the original list 
is modified outside of the instance, as the stored value will also be modified, 
even if it was not intended.

Here, we should copy the list internally :

{code}
    public void setReqMod( List<String> reqMod )
    {
        if ( reqMod != null )
        {
            this.reqMod = new ArrayList<String>( reqMod.size() );
            
            System.arraycopy( reqMod, 0, this.reqMod, 0, reqMod.size() );
        }
        else
        {
            this.reqMod = reqMod;
        }
    }
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to