aucd29 / cloning

Automatically exported from code.google.com/p/cloning
Other
0 stars 0 forks source link

Collection fast cloners and non-cloned objects #30

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The fast cloners for Sets and Lists should check for a null response from 
cloner.cloneInternal() before attempting to add to the collection as it's 
possible that null would be returned due to ignoredInstances or ignored classes.

The behavior for a Map is a bit more questionable-- but again would think that 
storing a null value for a key would not be the expected result. In addition, 
it's possible the key itself would not be cloned.

Original issue reported on code.google.com by jklap...@gmail.com on 22 May 2014 at 4:43

GoogleCodeExporter commented 9 years ago
hmm, but what would happen if cloneInternal() returns null? If we don't add the 
item, the cloned list will contain less items than the original

Original comment by kostas.k...@googlemail.com on 21 Jun 2014 at 8:42

GoogleCodeExporter commented 9 years ago
It would. But adding null is likely going to cause more issues then a different 
sized collection. If an object was set up to not be cloned and set to null- and 
since that is behavior explicitly set up I would think the cloner user would 
expect the collection to be smaller.

Original comment by jklap...@gmail.com on 21 Jun 2014 at 9:06

GoogleCodeExporter commented 9 years ago
maybe it is worth filtering out nulls and see how it goes. Seems to me to be a 
bad practice if an instance in a list is configured to be null-ed instead of 
cloned. But if it is so, maybe it is better to filter it out.

Original comment by kostas.k...@googlemail.com on 22 Jun 2014 at 4:45