[ https://issues.apache.org/jira/browse/THRIFT-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12638387#action_12638387 ]
David Reiss commented on THRIFT-138: ------------------------------------ I'm not sure whether this implementation produces a deep copy for nested structures. For example, this code is in Hello.java {noformat} for (Map.Entry<Integer, HashMap<Integer,Integer>> entry : other.complexer.entrySet()) { complexer.put(new Integer(entry.getKey()), new HashMap<Integer,Integer>(entry.getValue())); } {noformat} I suspect that "new HashMap<Integer,Integer>(entry.getValue())" only does a shallow copy of the inner map, based on what the .clone() method for HashMap does. It's seems pretty shameful that there is no standard way to do a deep copy in Java. I'm not really sure how to resolve this. > Generated Thrift structs should have a deep-copy constructor > ------------------------------------------------------------ > > Key: THRIFT-138 > URL: https://issues.apache.org/jira/browse/THRIFT-138 > Project: Thrift > Issue Type: New Feature > Components: Compiler (Java) > Reporter: Bryan Duxbury > Assignee: Bryan Duxbury > Priority: Minor > Attachments: thrift-138-v2.patch, thrift-138-v3.patch, > thrift-138.patch > > > It'd be nice to be able to make a copy of a Thrift object by passing it as an > argument to the constructor of the same object. Right now, we have to use a > serialize/deserialize approach to making a deep object copy, and that seems > really inefficient. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.