[
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)