Program: 35414
Project: 35414
Buggy source:
/** 
 * Save the value of a multivalued flexible element.
 * @param multivaluedIdsValue Value to save.
 * @param changeType Type of the modification (add, edit or remove).
 * @param historyDate Date of the modification.
 * @param element Flexible element to update.
 * @param containerId Identifier of the parent container.
 * @param iterationId Identifier of the iteration to update.
 * @param user Author of the modification.
 * @param comment Comment about the update.
 */
public void saveValue(final Set<Integer> multivaluedIdsValue,final ValueEventWrapper changeType,final Date historyDate,final FlexibleElement element,final Integer containerId,final Integer iterationId,final User user,final String comment){
  LOGGER.debug("String_Node_Str");
  final Value currentValue=retrieveOrCreateValue(containerId,element.getId(),iterationId,user);
  final Set<Integer> ids;
switch (changeType.getChangeType()) {
case ADD:
    ids=getCurrentIdsSet(currentValue);
  ids.addAll(multivaluedIdsValue);
break;
case REMOVE:
ids=getCurrentIdsSet(currentValue);
ids.removeAll(multivaluedIdsValue);
break;
case EDIT:
ids=multivaluedIdsValue;
break;
default :
throw new IllegalStateException("String_Node_Str" + changeType.getChangeType());
}
final String serializedValue=ValueResultUtils.mergeElements(new ArrayList<>(ids));
currentValue.setValue(serializedValue);
if (changeType.getChangeType() == ValueEventChangeType.EDIT) {
historize(historyDate,element,containerId,iterationId,user,changeType.getChangeType(),serializedValue,null,comment);
}
 else {
for (final Integer id : multivaluedIdsValue) {
historize(historyDate,element,containerId,iterationId,user,changeType.getChangeType(),String.valueOf(id),null,comment);
}
}
}

Fixed version (ground truth):
/** 
 * Save the value of a multivalued flexible element.
 * @param multivaluedIdsValue Value to save.
 * @param changeType Type of the modification (add, edit or remove).
 * @param historyDate Date of the modification.
 * @param element Flexible element to update.
 * @param containerId Identifier of the parent container.
 * @param iterationId Identifier of the iteration to update.
 * @param user Author of the modification.
 * @param comment Comment about the update.
 */
public void saveValue(final Set<Integer> multivaluedIdsValue,final ValueEventWrapper changeType,final Date historyDate,final FlexibleElement element,final Integer containerId,final Integer iterationId,final User user,final String comment){
  LOGGER.debug("String_Node_Str");
  final Value currentValue=retrieveOrCreateValue(containerId,element.getId(),iterationId,user);
  final Set<Integer> ids;
switch (changeType.getChangeType()) {
case ADD:
    ids=getCurrentIdsSet(currentValue);
  ids.addAll(multivaluedIdsValue);
break;
case REMOVE:
ids=getCurrentIdsSet(currentValue);
ids.removeAll(multivaluedIdsValue);
break;
case EDIT:
ids=multivaluedIdsValue;
break;
default :
throw new IllegalStateException("String_Node_Str" + changeType.getChangeType());
}
final String serializedValue=ValueResultUtils.mergeElements(new ArrayList<>(ids));
currentValue.setValue(serializedValue);
if (changeType.getChangeType() == ValueEventChangeType.EDIT) {
historize(historyDate,element,containerId,iterationId,user,changeType.getChangeType(),serializedValue,null,comment);
}
 else {
for (final Integer id : multivaluedIdsValue) {
historize(historyDate,element,containerId,iterationId,user,changeType.getChangeType(),String.valueOf(id),null,comment);
}
}
em().merge(currentValue);
}