[ 
https://issues.apache.org/jira/browse/FC-32?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14188525#comment-14188525
 ] 

Shawn McKinney commented on FC-32:
----------------------------------

We will need to be careful here and fix one attribute at a time.  (fix one var, 
regression test, repeat). There are many internal functions that expect the 
get/set to operate on object reference as opposed to copy.  Per your 
recommendation we could have setX and unsafeSetX, getX and unsafeGetX.  The 
unsafe methods should be package private preventing external clients from using 
though allowing the internal fortress apis to continue use.  

> 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