Mykhailo Kozik created THRIFT-3674:
--------------------------------------

             Summary: 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


Minimum reproducible scenario

I have an IDL called test.thrift

```
struct A {
  1: required B b;
}

struct B {
  1: required string id;
}
```

Then I generate java file

```
thrift -gen java -out src/main/java/gen src/main/resources/test.thrift
```

Generated object for A contains method called deepCopy, which is calling copy 
constructor, which is actually just shallow copy (copy references)

```
class A {

//...

public A(A other) {
    if (other.isSetB()) {
      this.b = other.b;
    }
  }

  public A deepCopy() {
    return new A(this);
  }

//...

}
```

Instead of copying references we need copy deepCopy recursively.



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

Reply via email to