Program: 35338
Project: 35338
Buggy source:
public List<ContactDuplicatedProperty> extractProperties(Contact newContact,Contact oldContact,Language language){
  List<ContactDuplicatedProperty> properties=new ArrayList<>();
  for (  LayoutGroup group : newContact.getContactModel().getDetails().getLayout().getGroups()) {
    if (group.getHasIterations()) {
      continue;
    }
    for (    LayoutConstraint layoutConstraint : group.getConstraints()) {
      FlexibleElement element=layoutConstraint.getElement();
      String serializedNewValue;
      String serializedOldValue;
      String formattedNewValue;
      String formattedOldValue;
      ContactDuplicatedProperty.ValueType valueType=ContactDuplicatedProperty.ValueType.STRING;
      if (element instanceof DefaultContactFlexibleElement) {
        DefaultContactFlexibleElement defaultContactFlexibleElement=(DefaultContactFlexibleElement)element;
        serializedNewValue=defaultContactFlexibleElement.getSerializedValue(newContact);
        serializedOldValue=defaultContactFlexibleElement.getSerializedValue(oldContact);
        formattedNewValue=defaultContactFlexibleElement.getFormattedValue(newContact);
        formattedOldValue=defaultContactFlexibleElement.getFormattedValue(oldContact);
        if (((DefaultContactFlexibleElement)element).getType() == DefaultContactFlexibleElementType.PHOTO) {
          valueType=ContactDuplicatedProperty.ValueType.IMAGE;
        }
      }
 else {
        Value newValue=valueDAO.getValueByElementAndContainer(element.getId(),newContact.getId());
        Value oldValue=valueDAO.getValueByElementAndContainer(element.getId(),oldContact.getId());
        serializedNewValue=newValue.getValue();
        serializedOldValue=oldValue.getValue();
        formattedNewValue=modelPropertyService.getFormattedValue(element,newValue.getValue(),language);
        formattedOldValue=modelPropertyService.getFormattedValue(element,oldValue.getValue(),language);
      }
      if (serializedOldValue != null && serializedOldValue.isEmpty()) {
        serializedOldValue=null;
      }
      if (serializedNewValue != null && serializedNewValue.isEmpty()) {
        serializedNewValue=null;
      }
      if (Objects.equals(serializedNewValue,serializedOldValue)) {
        continue;
      }
      String propertyLabel=element.getLabel();
      if (propertyLabel == null && element instanceof DefaultContactFlexibleElement) {
        propertyLabel=modelPropertyService.getDefaultContactPropertyLabel(((DefaultContactFlexibleElement)element).getType(),language);
      }
      ContactDuplicatedProperty contactDuplicatedProperty=new ContactDuplicatedProperty();
      contactDuplicatedProperty.setPropertyLabel(propertyLabel);
      contactDuplicatedProperty.setSerializedNewValue(serializedNewValue);
      contactDuplicatedProperty.setSerializedOldValue(serializedOldValue);
      contactDuplicatedProperty.setFormattedNewValue(formattedNewValue);
      contactDuplicatedProperty.setFormattedOldValue(formattedOldValue);
      contactDuplicatedProperty.setFlexibleElementId(element.getId());
      contactDuplicatedProperty.setValueType(valueType);
      properties.add(contactDuplicatedProperty);
    }
  }
  return properties;
}

Fixed version (ground truth):
public List<ContactDuplicatedProperty> extractProperties(Contact newContact,Contact oldContact,Language language){
  List<ContactDuplicatedProperty> properties=new ArrayList<>();
  for (  LayoutGroup group : newContact.getContactModel().getDetails().getLayout().getGroups()) {
    if (group.getHasIterations()) {
      continue;
    }
    for (    LayoutConstraint layoutConstraint : group.getConstraints()) {
      FlexibleElement element=layoutConstraint.getElement();
      String serializedNewValue=null;
      String serializedOldValue=null;
      String formattedNewValue=null;
      String formattedOldValue=null;
      ContactDuplicatedProperty.ValueType valueType=ContactDuplicatedProperty.ValueType.STRING;
      if (element instanceof DefaultContactFlexibleElement) {
        DefaultContactFlexibleElement defaultContactFlexibleElement=(DefaultContactFlexibleElement)element;
        serializedNewValue=defaultContactFlexibleElement.getSerializedValue(newContact);
        serializedOldValue=defaultContactFlexibleElement.getSerializedValue(oldContact);
        formattedNewValue=defaultContactFlexibleElement.getFormattedValue(newContact);
        formattedOldValue=defaultContactFlexibleElement.getFormattedValue(oldContact);
        if (((DefaultContactFlexibleElement)element).getType() == DefaultContactFlexibleElementType.PHOTO) {
          valueType=ContactDuplicatedProperty.ValueType.IMAGE;
        }
      }
 else {
        Value newValue=valueDAO.getValueByElementAndContainer(element.getId(),newContact.getId());
        Value oldValue=valueDAO.getValueByElementAndContainer(element.getId(),oldContact.getId());
        if (newValue != null) {
          serializedNewValue=newValue.getValue();
          formattedNewValue=modelPropertyService.getFormattedValue(element,newValue.getValue(),language);
        }
        if (oldValue != null) {
          serializedOldValue=oldValue.getValue();
          formattedOldValue=modelPropertyService.getFormattedValue(element,oldValue.getValue(),language);
        }
      }
      if (serializedOldValue != null && serializedOldValue.isEmpty()) {
        serializedOldValue=null;
      }
      if (serializedNewValue != null && serializedNewValue.isEmpty()) {
        serializedNewValue=null;
      }
      if (Objects.equals(serializedNewValue,serializedOldValue)) {
        continue;
      }
      String propertyLabel=element.getLabel();
      if (propertyLabel == null && element instanceof DefaultContactFlexibleElement) {
        propertyLabel=modelPropertyService.getDefaultContactPropertyLabel(((DefaultContactFlexibleElement)element).getType(),language);
      }
      ContactDuplicatedProperty contactDuplicatedProperty=new ContactDuplicatedProperty();
      contactDuplicatedProperty.setPropertyLabel(propertyLabel);
      contactDuplicatedProperty.setSerializedNewValue(serializedNewValue);
      contactDuplicatedProperty.setSerializedOldValue(serializedOldValue);
      contactDuplicatedProperty.setFormattedNewValue(formattedNewValue);
      contactDuplicatedProperty.setFormattedOldValue(formattedOldValue);
      contactDuplicatedProperty.setFlexibleElementId(element.getId());
      contactDuplicatedProperty.setValueType(valueType);
      properties.add(contactDuplicatedProperty);
    }
  }
  return properties;
}