Program: 171061
Project: 171061
Buggy source:
private void addInverseReference(AtlasAttribute inverseAttribute,AtlasEdge edge) throws AtlasBaseException {
  AtlasStructType inverseType=inverseAttribute.getDefinedInType();
  AtlasVertex inverseVertex=edge.getInVertex();
  String inverseEdgeLabel=inverseAttribute.getRelationshipEdgeLabel();
  AtlasEdge inverseEdge=graphHelper.getEdgeForLabel(inverseVertex,inverseEdgeLabel);
  String propertyName=AtlasGraphUtilsV1.getQualifiedAttributePropertyKey(inverseType,inverseAttribute.getName());
  AtlasEdge newEdge=createInverseReferenceUsingRelationship(inverseAttribute,edge);
  boolean inverseUpdated=true;
switch (inverseAttribute.getAttributeType().getTypeCategory()) {
case OBJECT_ID_TYPE:
    if (inverseEdge != null) {
      if (!inverseEdge.equals(newEdge)) {
        deleteHandler.deleteEdgeReference(inverseEdge,inverseAttribute.getAttributeType().getTypeCategory(),inverseAttribute.isOwnedRef(),true);
      }
 else {
        inverseUpdated=false;
      }
    }
  break;
case ARRAY:
List<String> elements=inverseVertex.getProperty(propertyName,List.class);
if (elements == null) {
elements=new ArrayList<>();
elements.add(newEdge.getId().toString());
inverseVertex.setProperty(propertyName,elements);
}
 else {
if (!elements.contains(newEdge.getId().toString())) {
  elements.add(newEdge.getId().toString());
  inverseVertex.setProperty(propertyName,elements);
}
 else {
  inverseUpdated=false;
}
}
break;
default :
break;
}
if (inverseUpdated) {
updateModificationMetadata(inverseVertex);
AtlasObjectId inverseEntityId=new AtlasObjectId(AtlasGraphUtilsV1.getIdFromVertex(inverseVertex),inverseType.getTypeName());
RequestContextV1.get().recordEntityUpdate(inverseEntityId);
}
}

Fixed version (ground truth):
private void addInverseReference(AtlasAttribute inverseAttribute,AtlasEdge edge) throws AtlasBaseException {
  AtlasStructType inverseType=inverseAttribute.getDefinedInType();
  AtlasVertex inverseVertex=edge.getInVertex();
  String inverseEdgeLabel=inverseAttribute.getRelationshipEdgeLabel();
  AtlasEdge inverseEdge=graphHelper.getEdgeForLabel(inverseVertex,inverseEdgeLabel);
  String propertyName=AtlasGraphUtilsV1.getQualifiedAttributePropertyKey(inverseType,inverseAttribute.getName());
  AtlasEdge newEdge=createInverseReferenceUsingRelationship(inverseAttribute,edge);
  boolean inverseUpdated=true;
switch (inverseAttribute.getAttributeType().getTypeCategory()) {
case OBJECT_ID_TYPE:
    if (inverseEdge != null) {
      if (!inverseEdge.equals(newEdge)) {
        deleteHandler.deleteEdgeReference(inverseEdge,inverseAttribute.getAttributeType().getTypeCategory(),inverseAttribute.isOwnedRef(),true);
      }
 else {
        inverseUpdated=false;
      }
    }
  break;
case ARRAY:
List<String> elements=inverseVertex.getProperty(propertyName,List.class);
if (newEdge != null && elements == null) {
elements=new ArrayList<>();
elements.add(newEdge.getId().toString());
inverseVertex.setProperty(propertyName,elements);
}
 else {
if (newEdge != null && !elements.contains(newEdge.getId().toString())) {
  elements.add(newEdge.getId().toString());
  inverseVertex.setProperty(propertyName,elements);
}
 else {
  inverseUpdated=false;
}
}
break;
default :
break;
}
if (inverseUpdated) {
updateModificationMetadata(inverseVertex);
AtlasObjectId inverseEntityId=new AtlasObjectId(AtlasGraphUtilsV1.getIdFromVertex(inverseVertex),inverseType.getTypeName());
RequestContextV1.get().recordEntityUpdate(inverseEntityId);
}
}