directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (FC-32) setters that take a list as an argument does not copy it internally
Date Fri, 06 May 2016 15:24:13 GMT

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

Emmanuel Lecharny updated FC-32:
--------------------------------
    Fix Version/s:     (was: 1.0.0)
                   1.0.1

> 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
>          Issue Type: Bug
>    Affects Versions: 1.0.0-RC39
>            Reporter: Emmanuel Lecharny
>             Fix For: 1.0.1
>
>
> 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)

Mime
View raw message