You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/01/28 08:45:39 UTC

[jira] [Commented] (THRIFT-3377) Deep copy is actually shallow when using typedef members

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

ASF GitHub Bot commented on THRIFT-3377:
----------------------------------------

GitHub user roshan opened a pull request:

    https://github.com/apache/thrift/pull/823

    THRIFT-3377 Make typedef'd structures correctly deepcopy

    Container structures which are `typedef`'d don't correctly deep copy.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/roshan/thrift THRIFT-3377_fix_typedef_deepcopy

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/823.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #823
    
----
commit 19ba72816c2152276d13d9abb818dabe55fd90a9
Author: Roshan George <ro...@arjie.com>
Date:   2016-01-28T07:53:34Z

    Make typedef'd structures correctly deepcopy

----


> Deep copy is actually shallow when using typedef members
> --------------------------------------------------------
>
>                 Key: THRIFT-3377
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3377
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Compiler
>    Affects Versions: 0.9.2
>            Reporter: Vincent Dumont
>
> Consider the following structures:
> {code:title=thrift|borderStyle=solid}
> typedef set<i32> sset;
> struct Test {
>   1: set<i32> myset;
> }
> struct Test2 {
>   1: sset myset;
> }
> {code}
> The generated code for Test's copy constructor looks fine, it deep copies the set. However, Test2, which should be equivalent, actually does not deep-copy the set and instead simply does a shallow assignment like if it was a POD type. 
> {code:title=Test.java -- deep|borderStyle=solid}
>   /** 
>    * Performs a deep copy on <i>other</i>.
>    */
>   public Test(Test other) {
>     if (other.isSetMyset()) {
>       Set<Integer> __this__myset = new HashSet<Integer>(other.myset);
>       this.myset = __this__myset;
>     }   
>   }
> {code}
> VS
> {code:title=Test2.java -- shallow..?|borderStyle=solid}
>   /**
>    * Performs a deep copy on <i>other</i>.
>    */
>   public Test2(Test2 other) {
>     if (other.isSetMyset()) {
>       this.myset = other.myset;
>     }
>   }
> {code}



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