Program: 35387
Project: 35387
Buggy source:
private void applyProperties(List<ContactDuplicatedProperty> properties,Contact contact){
  for (  ContactDuplicatedProperty property : properties) {
    DefaultContactFlexibleElement flexibleElement=(DefaultContactFlexibleElement)flexibleElementDAO.findById(property.getFlexibleElementId());
switch (flexibleElement.getType()) {
case FIRST_NAME:
      contact.setFirstname(property.getSerializedNewValue());
    break;
case ORGANIZATION_NAME:
case FAMILY_NAME:
  contact.setName(property.getSerializedNewValue());
break;
case MAIN_ORG_UNIT:
if (property.getSerializedNewValue() == null) {
contact.setMainOrgUnit(null);
continue;
}
int mainOrgUnitId=Integer.parseInt(property.getSerializedNewValue());
contact.setMainOrgUnit(orgUnitDAO.findById(mainOrgUnitId));
break;
case SECONDARY_ORG_UNITS:
if (property.getSerializedNewValue() == null) {
contact.setSecondaryOrgUnits(null);
continue;
}
ArrayList<OrgUnit> orgUnits=new ArrayList<>();
for (String serializedId : property.getSerializedNewValue().split(ValueResultUtils.DEFAULT_VALUE_SEPARATOR)) {
int secondaryOrgUnitId=Integer.parseInt(serializedId);
orgUnits.add(orgUnitDAO.findById(secondaryOrgUnitId));
}
contact.setSecondaryOrgUnits(orgUnits);
break;
case LOGIN:
contact.setLogin(property.getSerializedNewValue());
break;
case EMAIL_ADDRESS:
contact.setEmail(property.getSerializedNewValue());
break;
case PHONE_NUMBER:
contact.setPhoneNumber(property.getSerializedNewValue());
break;
case POSTAL_ADDRESS:
contact.setPostalAddress(property.getSerializedNewValue());
break;
case PHOTO:
contact.setPhoto(property.getSerializedNewValue());
break;
case COUNTRY:
if (property.getSerializedNewValue() == null) {
contact.setCountry(null);
continue;
}
int countryId=Integer.parseInt(property.getSerializedNewValue());
contact.setCountry(countryDAO.findById(countryId));
break;
case DIRECT_MEMBERSHIP:
if (property.getSerializedNewValue() == null) {
contact.setParent(null);
continue;
}
int parentId=Integer.parseInt(property.getSerializedNewValue());
contact.setParent(contactDAO.findById(parentId));
break;
case CREATION_DATE:
case TOP_MEMBERSHIP:
break;
default :
throw new IllegalStateException("String_Node_Str" + flexibleElement.getType());
}
}
}

Fixed version (ground truth):
private void applyProperties(List<ContactDuplicatedProperty> properties,Contact contact,User user){
  for (  ContactDuplicatedProperty property : properties) {
    DefaultContactFlexibleElement flexibleElement=(DefaultContactFlexibleElement)flexibleElementDAO.findById(property.getFlexibleElementId());
switch (flexibleElement.getType()) {
case FIRST_NAME:
      contact.setFirstname(property.getSerializedNewValue());
    break;
case ORGANIZATION_NAME:
case FAMILY_NAME:
  contact.setName(property.getSerializedNewValue());
break;
case MAIN_ORG_UNIT:
if (property.getSerializedNewValue() == null) {
contact.setMainOrgUnit(null);
continue;
}
int mainOrgUnitId=Integer.parseInt(property.getSerializedNewValue());
contact.setMainOrgUnit(orgUnitDAO.findById(mainOrgUnitId));
break;
case SECONDARY_ORG_UNITS:
if (property.getSerializedNewValue() == null) {
contact.setSecondaryOrgUnits(null);
continue;
}
ArrayList<OrgUnit> orgUnits=new ArrayList<>();
for (String serializedId : property.getSerializedNewValue().split(ValueResultUtils.DEFAULT_VALUE_SEPARATOR)) {
int secondaryOrgUnitId=Integer.parseInt(serializedId);
orgUnits.add(orgUnitDAO.findById(secondaryOrgUnitId));
}
contact.setSecondaryOrgUnits(orgUnits);
break;
case LOGIN:
contact.setLogin(property.getSerializedNewValue());
break;
case EMAIL_ADDRESS:
contact.setEmail(property.getSerializedNewValue());
break;
case PHONE_NUMBER:
contact.setPhoneNumber(property.getSerializedNewValue());
break;
case POSTAL_ADDRESS:
contact.setPostalAddress(property.getSerializedNewValue());
break;
case PHOTO:
contact.setPhoto(property.getSerializedNewValue());
break;
case COUNTRY:
if (property.getSerializedNewValue() == null) {
contact.setCountry(null);
continue;
}
int countryId=Integer.parseInt(property.getSerializedNewValue());
contact.setCountry(countryDAO.findById(countryId));
break;
case DIRECT_MEMBERSHIP:
if (property.getSerializedNewValue() == null) {
contact.setParent(null);
continue;
}
int parentId=Integer.parseInt(property.getSerializedNewValue());
contact.setParent(contactDAO.findById(parentId));
break;
case CREATION_DATE:
case TOP_MEMBERSHIP:
break;
default :
throw new IllegalStateException("String_Node_Str" + flexibleElement.getType());
}
}
contactDAO.persist(contact,user);
}