Project: Birt
Bug 264836 clone() method of org.eclipse.birt.report.model.metadata.ChoiceSet
Reported: 2009-02-13 07:58:21 | Status: resolved fixed

Problem with clone() method of org.eclipse.birt.report.model.metadata.ChoiceSet. This method is adding values from ArrayList to the same ArrayList instance (attribute choices). Size of this ArrayList goes to infinity (OutOfMemory). /////////// CURRENT ChoiceSet CODE //////////////////// public Object clone( ) throws CloneNotSupportedException { ChoiceSet set = (ChoiceSet) super.clone( ); if ( choices != null ) { for ( int i = 0; i < choices.size( ); i++ ) set.choices.add( ( (IChoice) choices.get( i ) ).copy( ) ); } return set; } ////////////////////////////////////////////////////// /////////// ChoiceSet FIX //////////////////// public Object clone( ) throws CloneNotSupportedException { ChoiceSet set = (ChoiceSet) super.clone( ); // new instance of cloned ChoiceSet choices set.choices = new ArrayList(); if ( choices != null ) { for ( int i = 0; i < choices.size( ); i++ ) set.choices.add( ( (IChoice) choices.get( i ) ).copy( ) ); } return set; } //////////////////////////////////////////////////////

Files changed in fix:
model/org.eclipse.birt.report.model.tests/test/org/eclipse/birt/report/model/metadata/ChoiceSetTest.java model/org.eclipse.birt.report.model/src/org/eclipse/birt/report/model/metadata/ChoiceSet.java