Program: 171059
Project: 171059
Buggy source:
private Object mapToVertexByTypeCategory(AttributeMutationContext ctx,EntityMutationContext context) throws AtlasBaseException {
  if (ctx.getOp() == CREATE && ctx.getValue() == null) {
    return null;
  }
switch (ctx.getAttrType().getTypeCategory()) {
case PRIMITIVE:
case ENUM:
    return mapPrimitiveValue(ctx);
case STRUCT:
{
    String edgeLabel=AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty());
    AtlasEdge currentEdge=graphHelper.getEdgeForLabel(ctx.getReferringVertex(),edgeLabel);
    AtlasEdge edge=currentEdge != null ? currentEdge : null;
    ctx.setExistingEdge(edge);
    AtlasEdge newEdge=mapStructValue(ctx,context);
    if (currentEdge != null && !currentEdge.equals(newEdge)) {
      deleteHandler.deleteEdgeReference(currentEdge,ctx.getAttrType().getTypeCategory(),false,true);
    }
    return newEdge;
  }
case OBJECT_ID_TYPE:
{
  String edgeLabel=ctx.getAttribute().getRelationshipEdgeLabel();
  if (StringUtils.isEmpty(edgeLabel)) {
    edgeLabel=AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty());
  }
  AtlasEdge currentEdge=graphHelper.getEdgeForLabel(ctx.getReferringVertex(),edgeLabel);
  AtlasEdge newEdge=null;
  if (ctx.getValue() != null) {
    AtlasEntityType instanceType=getInstanceType(ctx.getValue());
    AtlasEdge edge=currentEdge != null ? currentEdge : null;
    ctx.setElementType(instanceType);
    ctx.setExistingEdge(edge);
    newEdge=mapObjectIdValueUsingRelationship(ctx,context);
    if (ctx.getAttribute().getInverseRefAttribute() != null) {
      addInverseReference(ctx.getAttribute().getInverseRefAttribute(),newEdge);
    }
  }
  if (currentEdge != null && !currentEdge.equals(newEdge)) {
    deleteHandler.deleteEdgeReference(currentEdge,ctx.getAttrType().getTypeCategory(),ctx.getAttribute().isOwnedRef(),true);
  }
  return newEdge;
}
case MAP:
return mapMapValue(ctx,context);
case ARRAY:
return mapArrayValue(ctx,context);
default :
throw new AtlasBaseException(AtlasErrorCode.TYPE_CATEGORY_INVALID,ctx.getAttrType().getTypeCategory().name());
}
}

Fixed version (ground truth):
private Object mapToVertexByTypeCategory(AttributeMutationContext ctx,EntityMutationContext context) throws AtlasBaseException {
  if (ctx.getOp() == CREATE && ctx.getValue() == null) {
    return null;
  }
switch (ctx.getAttrType().getTypeCategory()) {
case PRIMITIVE:
case ENUM:
    return mapPrimitiveValue(ctx);
case STRUCT:
{
    String edgeLabel=AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty());
    AtlasEdge currentEdge=graphHelper.getEdgeForLabel(ctx.getReferringVertex(),edgeLabel);
    AtlasEdge edge=currentEdge != null ? currentEdge : null;
    ctx.setExistingEdge(edge);
    AtlasEdge newEdge=mapStructValue(ctx,context);
    if (currentEdge != null && !currentEdge.equals(newEdge)) {
      deleteHandler.deleteEdgeReference(currentEdge,ctx.getAttrType().getTypeCategory(),false,true);
    }
    return newEdge;
  }
case OBJECT_ID_TYPE:
{
  String edgeLabel=ctx.getAttribute().getRelationshipEdgeLabel();
  if (StringUtils.isEmpty(edgeLabel)) {
    edgeLabel=AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexProperty());
  }
  AtlasEdge currentEdge=graphHelper.getEdgeForLabel(ctx.getReferringVertex(),edgeLabel);
  AtlasEdge newEdge=null;
  if (ctx.getValue() != null) {
    AtlasEntityType instanceType=getInstanceType(ctx.getValue());
    AtlasEdge edge=currentEdge != null ? currentEdge : null;
    ctx.setElementType(instanceType);
    ctx.setExistingEdge(edge);
    newEdge=mapObjectIdValueUsingRelationship(ctx,context);
    if (newEdge != null && ctx.getAttribute().getInverseRefAttribute() != null) {
      addInverseReference(ctx.getAttribute().getInverseRefAttribute(),newEdge);
    }
  }
  if (currentEdge != null && !currentEdge.equals(newEdge)) {
    deleteHandler.deleteEdgeReference(currentEdge,ctx.getAttrType().getTypeCategory(),ctx.getAttribute().isOwnedRef(),true);
  }
  return newEdge;
}
case MAP:
return mapMapValue(ctx,context);
case ARRAY:
return mapArrayValue(ctx,context);
default :
throw new AtlasBaseException(AtlasErrorCode.TYPE_CATEGORY_INVALID,ctx.getAttrType().getTypeCategory().name());
}
}