You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "James E. King, III (JIRA)" <ji...@apache.org> on 2017/04/19 03:28:41 UTC

[jira] [Closed] (THRIFT-3674) Java generated deep copy is shallow

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

James E. King, III closed THRIFT-3674.
--------------------------------------
    Resolution: Duplicate
      Assignee: James E. King, III

Closing as a duplicate of another report, which has a pull request.

> Java generated deep copy is shallow
> -----------------------------------
>
>                 Key: THRIFT-3674
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3674
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Compiler
>    Affects Versions: 0.9.2
>            Reporter: Mykhailo Kozik
>            Assignee: James E. King, III
>
> Minimum reproducible scenario
> I have an IDL called test.thrift
> {code}
> struct A {
>   1: required B b;
> }
> struct B {
>   1: required string id;
> }
> {code}
> Then I generate java file
> {code}
> thrift -gen java -out src/main/java/gen src/main/resources/test.thrift
> {code}
> Generated object for A contains method called deepCopy, which is calling copy constructor, which is actually just shallow copy (copy references)
> {code}
> class A {
> //...
> public A(A other) {
>     if (other.isSetB()) {
>       this.b = other.b;
>     }
>   }
>   public A deepCopy() {
>     return new A(this);
>   }
> //...
> }
> {code}
> Instead of copying references we need copy deepCopy recursively.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)