When a PersistentCollection (PC) is loaded and is cloned before it is initialized, anything that is already in that collection will be duplicated if the collection is initialized after it has been marked dirty. The cause is a too late clone operation on the internal (Array)Collection (AC) in the PC.
- PC is loaded, but not initialized. The internal AC is empty.
- PC is cloned. PC' calls initialize() in __clone()
- PC' fills AC (as that has not been cloned yet)
- PC' clones AC
As a result the AC in PC now contains elements, but PC still is uninitialized. If PC is afterwards initialized and dirty, the elements already in AC will be considered new and added again to the AC.
The effect will be constraint violations in join tables due to duplicate entries.
The clone method causing this has been introduced with commit 647bd2b2f295d2cbe7d0ee67f21be8a48bae3db5 on February 17th.
|Field||Original Value||New Value|
|Status||Open [ 1 ]||Resolved [ 5 ]|
|Fix Version/s||2.1.7 [ 10198 ]|
|Fix Version/s||2.2.3 [ 10196 ]|
|Resolution||Fixed [ 1 ]|
|Workflow||jira [ 13725 ]||jira-feedback [ 15356 ]|
|Workflow||jira-feedback [ 15356 ]||jira-feedback2 [ 17220 ]|
|Workflow||jira-feedback2 [ 17220 ]||jira-feedback3 [ 19475 ]|