Vincent Dumont created THRIFT-3377:
--------------------------------------
Summary: 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 generate 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|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|borderStyle=solid}
/**
* Performs a deep copy on <i>other</i>.
*/
public Test2(Test2 other) {
if (other.isSetMyset()) {
this.myset = other.myset; // Not deep...
}
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)