Program: 171088
Project: 171088
Buggy source:
/** 
 * Deletes the edge between outvertex and inVertex. The edge is for attribute attributeName of outVertex
 * @param outVertex
 * @param inVertex
 * @param attributeName
 * @throws AtlasException
 */
protected void deleteEdgeBetweenVertices(AtlasVertex outVertex,AtlasVertex inVertex,String attributeName) throws AtlasBaseException {
  LOG.debug("String_Node_Str",string(outVertex),string(inVertex),attributeName);
  String typeName=GraphHelper.getTypeName(outVertex);
  String outId=GraphHelper.getGuid(outVertex);
  AtlasEntity.Status state=AtlasGraphUtilsV1.getState(outVertex);
  if ((outId != null && RequestContextV1.get().isDeletedEntity(outId)) || state == AtlasEntity.Status.DELETED) {
    return;
  }
  AtlasStructType parentType=(AtlasStructType)typeRegistry.getType(typeName);
  String propertyName=AtlasGraphUtilsV1.getQualifiedAttributePropertyKey(parentType,attributeName);
  String edgeLabel=EDGE_LABEL_PREFIX + propertyName;
  AtlasEdge edge=null;
  AtlasAttributeDef attrDef=parentType.getAttributeDef(attributeName);
  AtlasType attrType=typeRegistry.getType(attrDef.getTypeName());
switch (attrType.getTypeCategory()) {
case ENTITY:
    if (attrDef.getIsOptional()) {
      edge=graphHelper.getEdgeForLabel(outVertex,edgeLabel);
      if (shouldUpdateReverseAttribute) {
        GraphHelper.setProperty(outVertex,propertyName,null);
      }
    }
 else {
      throw new AtlasBaseException("String_Node_Str" + propertyName + "String_Node_Str"+ GraphHelper.getVertexDetails(outVertex)+ "String_Node_Str"+ edgeLabel);
    }
  break;
case ARRAY:
List<String> elements=GraphHelper.getListProperty(outVertex,propertyName);
if (elements != null) {
elements=new ArrayList<>(elements);
for (String elementEdgeId : elements) {
  AtlasEdge elementEdge=graphHelper.getEdgeByEdgeId(outVertex,edgeLabel,elementEdgeId);
  if (elementEdge == null) {
    continue;
  }
  AtlasVertex elementVertex=elementEdge.getInVertex();
  if (elementVertex.equals(inVertex)) {
    edge=elementEdge;
    if (!attrDef.getIsOptional() && elements.size() <= attrDef.getValuesMinCount()) {
      throw new AtlasBaseException("String_Node_Str" + propertyName + "String_Node_Str"+ GraphHelper.getVertexDetails(outVertex)+ "String_Node_Str"+ GraphHelper.getEdgeDetails(elementEdge));
    }
    if (shouldUpdateReverseAttribute) {
      LOG.debug("String_Node_Str",string(elementEdge),attributeName);
      elements.remove(elementEdge.getId().toString());
      GraphHelper.setProperty(outVertex,propertyName,elements);
      break;
    }
  }
}
}
break;
case MAP:
List<String> keys=GraphHelper.getListProperty(outVertex,propertyName);
if (keys != null) {
keys=new ArrayList<>(keys);
for (String key : keys) {
String keyPropertyName=GraphHelper.getQualifiedNameForMapKey(propertyName,key);
String mapEdgeId=GraphHelper.getSingleValuedProperty(outVertex,keyPropertyName,String.class);
AtlasEdge mapEdge=graphHelper.getEdgeByEdgeId(outVertex,keyPropertyName,mapEdgeId);
if (mapEdge != null) {
AtlasVertex mapVertex=mapEdge.getInVertex();
if (mapVertex.getId().toString().equals(inVertex.getId().toString())) {
if (attrDef.getIsOptional() || keys.size() > attrDef.getValuesMinCount()) {
  edge=mapEdge;
}
 else {
  throw new AtlasBaseException("String_Node_Str" + keyPropertyName + "String_Node_Str"+ propertyName+ "String_Node_Str"+ GraphHelper.getVertexDetails(outVertex)+ "String_Node_Str"+ GraphHelper.getEdgeDetails(mapEdge));
}
if (shouldUpdateReverseAttribute) {
  LOG.debug("String_Node_Str",string(mapEdge),key,attributeName);
  keys.remove(key);
  GraphHelper.setProperty(outVertex,propertyName,keys);
  GraphHelper.setProperty(outVertex,keyPropertyName,null);
}
break;
}
}
}
}
break;
case STRUCT:
case CLASSIFICATION:
break;
default :
throw new IllegalStateException("String_Node_Str" + GraphHelper.getVertexDetails(outVertex) + "String_Node_Str"+ GraphHelper.getVertexDetails(inVertex)+ "String_Node_Str"+ attributeName+ "String_Node_Str");
}
if (edge != null) {
deleteEdge(edge,false);
RequestContextV1 requestContext=RequestContextV1.get();
GraphHelper.setProperty(outVertex,Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY,requestContext.getRequestTime());
GraphHelper.setProperty(outVertex,Constants.MODIFIED_BY_KEY,requestContext.getUser());
requestContext.recordEntityUpdate(outId);
}
}

Fixed version (ground truth):
/** 
 * Deletes the edge between outvertex and inVertex. The edge is for attribute attributeName of outVertex
 * @param outVertex
 * @param inVertex
 * @param attributeName
 * @throws AtlasException
 */
protected void deleteEdgeBetweenVertices(AtlasVertex outVertex,AtlasVertex inVertex,String attributeName) throws AtlasBaseException {
  LOG.debug("String_Node_Str",string(outVertex),string(inVertex),attributeName);
  String typeName=GraphHelper.getTypeName(outVertex);
  String outId=GraphHelper.getGuid(outVertex);
  AtlasEntity.Status state=AtlasGraphUtilsV1.getState(outVertex);
  if ((outId != null && RequestContextV1.get().isDeletedEntity(outId)) || state == AtlasEntity.Status.DELETED) {
    return;
  }
  AtlasStructType parentType=(AtlasStructType)typeRegistry.getType(typeName);
  String propertyName=AtlasGraphUtilsV1.getQualifiedAttributePropertyKey(parentType,attributeName);
  String edgeLabel=EDGE_LABEL_PREFIX + propertyName;
  AtlasEdge edge=null;
  AtlasAttributeDef attrDef=parentType.getAttributeDef(attributeName);
  AtlasType attrType=typeRegistry.getType(attrDef.getTypeName());
switch (attrType.getTypeCategory()) {
case ENTITY:
    if (attrDef.getIsOptional()) {
      edge=graphHelper.getEdgeForLabel(outVertex,edgeLabel);
      if (shouldUpdateReverseAttribute) {
        GraphHelper.setProperty(outVertex,propertyName,null);
      }
    }
 else {
      throw new AtlasBaseException("String_Node_Str" + propertyName + "String_Node_Str"+ GraphHelper.getVertexDetails(outVertex)+ "String_Node_Str"+ edgeLabel);
    }
  break;
case ARRAY:
List<String> elements=GraphHelper.getListProperty(outVertex,propertyName);
if (elements != null) {
elements=new ArrayList<>(elements);
for (String elementEdgeId : elements) {
  AtlasEdge elementEdge=graphHelper.getEdgeByEdgeId(outVertex,edgeLabel,elementEdgeId);
  if (elementEdge == null) {
    continue;
  }
  AtlasVertex elementVertex=elementEdge.getInVertex();
  if (elementVertex.equals(inVertex)) {
    edge=elementEdge;
    if (!attrDef.getIsOptional() && elements.size() <= attrDef.getValuesMinCount()) {
      throw new AtlasBaseException("String_Node_Str" + propertyName + "String_Node_Str"+ GraphHelper.getVertexDetails(outVertex)+ "String_Node_Str"+ GraphHelper.getEdgeDetails(elementEdge));
    }
    if (shouldUpdateReverseAttribute) {
      LOG.debug("String_Node_Str",string(elementEdge),attributeName);
      elements.remove(elementEdge.getId().toString());
      GraphHelper.setProperty(outVertex,propertyName,elements);
      break;
    }
  }
}
}
break;
case MAP:
List<String> keys=GraphHelper.getListProperty(outVertex,propertyName);
if (keys != null) {
keys=new ArrayList<>(keys);
for (String key : keys) {
String keyPropertyName=GraphHelper.getQualifiedNameForMapKey(propertyName,key);
String mapEdgeId=GraphHelper.getSingleValuedProperty(outVertex,keyPropertyName,String.class);
AtlasEdge mapEdge=graphHelper.getEdgeByEdgeId(outVertex,keyPropertyName,mapEdgeId);
if (mapEdge != null) {
AtlasVertex mapVertex=mapEdge.getInVertex();
if (mapVertex.getId().toString().equals(inVertex.getId().toString())) {
if (attrDef.getIsOptional() || keys.size() > attrDef.getValuesMinCount()) {
  edge=mapEdge;
}
 else {
  throw new AtlasBaseException("String_Node_Str" + keyPropertyName + "String_Node_Str"+ propertyName+ "String_Node_Str"+ GraphHelper.getVertexDetails(outVertex)+ "String_Node_Str"+ GraphHelper.getEdgeDetails(mapEdge));
}
if (shouldUpdateReverseAttribute) {
  LOG.debug("String_Node_Str",string(mapEdge),key,attributeName);
  keys.remove(key);
  GraphHelper.setProperty(outVertex,propertyName,keys);
  GraphHelper.setProperty(outVertex,keyPropertyName,null);
}
break;
}
}
}
}
break;
case STRUCT:
case CLASSIFICATION:
break;
default :
throw new IllegalStateException("String_Node_Str" + GraphHelper.getVertexDetails(outVertex) + "String_Node_Str"+ GraphHelper.getVertexDetails(inVertex)+ "String_Node_Str"+ attributeName+ "String_Node_Str");
}
if (edge != null) {
deleteEdge(edge,false);
RequestContextV1 requestContext=RequestContextV1.get();
GraphHelper.setProperty(outVertex,Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY,requestContext.getRequestTime());
GraphHelper.setProperty(outVertex,Constants.MODIFIED_BY_KEY,requestContext.getUser());
requestContext.recordEntityUpdate(new AtlasObjectId(typeName,outId));
}
}