nus-yam/ex-repair huggingface dataset:
Program: 171075
Project: 171075
Buggy source:
private AtlasEntity getEntity(String guid) throws AtlasBaseException {
  if (guidEntityJsonMap.containsKey(guid)) {
    return getEntityWithExtInfo(guid).getEntity();
  }
  return null;
}

Fixed version (ground truth):
private AtlasEntity getEntity(String guid) throws AtlasBaseException {
  if (guidEntityJsonMap.containsKey(guid)) {
    AtlasEntityWithExtInfo extInfo=getEntityWithExtInfo(guid);
    return (extInfo != null) ? extInfo.getEntity() : null;
  }
  return null;
}
Program: 171076
Project: 171076
Buggy source:
private AtlasEntityType getReferencedEntityType(AtlasType type){
  if (type instanceof AtlasArrayType) {
    type=((AtlasArrayType)type).getElementType();
  }
  return type instanceof AtlasEntityType ? (AtlasEntityType)type : null;
}

Fixed version (ground truth):
private AtlasEntityType getReferencedEntityType(AtlasType type){
  if (type instanceof AtlasArrayType) {
    type=((AtlasArrayType)type).getElementType();
  }
  if (type instanceof AtlasMapType) {
    type=((AtlasMapType)type).getValueType();
  }
  return type instanceof AtlasEntityType ? (AtlasEntityType)type : null;
}
Program: 171079
Project: 171079
Buggy source:
public static EntityResult fromString(String json) throws AtlasServiceException {
  return AtlasType.fromJson(json,EntityResult.class);
}

Fixed version (ground truth):
public static EntityResult fromString(String json) throws AtlasServiceException {
  return gson.fromJson(json,EntityResult.class);
}
Program: 171081
Project: 171081
Buggy source:
private Id createInstance(Referenceable referenceable) throws Exception {
  String typeName=referenceable.getTypeName();
  String entityJSON=InstanceSerialization.toJson(referenceable,true);
  System.out.println("String_Node_Str" + entityJSON);
  List<String> guids=metadataServiceClient.createEntity(entityJSON);
  System.out.println("String_Node_Str" + typeName + "String_Node_Str"+ guids);
  return new Id(guids.get(guids.size() - 1),referenceable.getId().getVersion(),referenceable.getTypeName());
}

Fixed version (ground truth):
private Id createInstance(Referenceable referenceable) throws Exception {
  String typeName=referenceable.getTypeName();
  String entityJSON=InstanceSerialization.toJson(referenceable,true);
  System.out.println("String_Node_Str" + entityJSON);
  List<String> guids=metadataServiceClient.createEntity(entityJSON);
  System.out.println("String_Node_Str" + typeName + "String_Node_Str"+ guids);
  if (guids.size() > 0) {
    return new Id(guids.get(guids.size() - 1),referenceable.getId().getVersion(),referenceable.getTypeName());
  }
  return null;
}
Program: 171082
Project: 171082
Buggy source:
private AtlasEntity createInstance(AtlasEntity entity,String[] traitNames) throws Exception {
  AtlasEntity ret=null;
  EntityMutationResponse response=entitiesClient.createEntity(new AtlasEntityWithExtInfo(entity));
  List<AtlasEntityHeader> entities=response.getEntitiesByOperation(EntityOperation.CREATE);
  if (CollectionUtils.isNotEmpty(entities)) {
    AtlasEntityWithExtInfo getByGuidResponse=entitiesClient.getEntityByGuid(entities.get(0).getGuid());
    ret=getByGuidResponse.getEntity();
    System.out.println("String_Node_Str" + ret.getTypeName() + "String_Node_Str"+ ret.getGuid());
  }
  if (ArrayUtils.isNotEmpty(traitNames)) {
    entitiesClient.addClassifications(ret.getGuid(),toAtlasClassifications(traitNames));
  }
  return ret;
}

Fixed version (ground truth):
private AtlasEntity createInstance(AtlasEntity entity,String[] traitNames) throws Exception {
  AtlasEntity ret=null;
  EntityMutationResponse response=entitiesClient.createEntity(new AtlasEntityWithExtInfo(entity));
  List<AtlasEntityHeader> entities=response.getEntitiesByOperation(EntityOperation.CREATE);
  if (CollectionUtils.isNotEmpty(entities)) {
    AtlasEntityWithExtInfo getByGuidResponse=entitiesClient.getEntityByGuid(entities.get(0).getGuid());
    ret=getByGuidResponse.getEntity();
    System.out.println("String_Node_Str" + ret.getTypeName() + "String_Node_Str"+ ret.getGuid());
  }
  return ret;
}
Program: 171083
Project: 171083
Buggy source:
public static void setConfigSectionRedirect(String name,String redirectTo){
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str",name,redirectTo);
  }
  if (name != null) {
    if (redirectTo != null) {
      configSectionRedirects.put(name,redirectTo);
    }
 else {
      configSectionRedirects.remove(name);
    }
  }
}

Fixed version (ground truth):
public static void setConfigSectionRedirect(String name,String redirectTo){
  if (LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str",name,redirectTo);
  }
  if (name != null) {
    if (redirectTo != null) {
      CONFIG_SECTION_REDIRECTS.put(name,redirectTo);
    }
 else {
      CONFIG_SECTION_REDIRECTS.remove(name);
    }
  }
}
Program: 171084
Project: 171084
Buggy source:
private static String getConfigSectionRedirect(String name){
  return name != null ? configSectionRedirects.get(name) : null;
}

Fixed version (ground truth):
private static String getConfigSectionRedirect(String name){
  return name != null ? CONFIG_SECTION_REDIRECTS.get(name) : null;
}
Program: 171086
Project: 171086
Buggy source:
public static AtlasEntity createColumnEntity(){
  AtlasEntity entity=new AtlasEntity(COLUMN_TYPE);
  entity.setAttribute(NAME,RandomStringUtils.randomAlphanumeric(10));
  entity.setAttribute("String_Node_Str","String_Node_Str");
  return entity;
}

Fixed version (ground truth):
public static AtlasEntity createColumnEntity(String tableId){
  AtlasEntity entity=new AtlasEntity(COLUMN_TYPE);
  entity.setAttribute(NAME,RandomStringUtils.randomAlphanumeric(10));
  entity.setAttribute("String_Node_Str","String_Node_Str");
  entity.setAttribute("String_Node_Str",new AtlasObjectId(TABLE_TYPE,tableId));
  return entity;
}
Program: 171087
Project: 171087
Buggy source:
private EntityMutationContext preCreateOrUpdate(final List<AtlasEntity> atlasEntities) throws AtlasBaseException {
  EntityGraphDiscoveryContext discoveredEntities=graphDiscoverer.discoverEntities(atlasEntities);
  EntityMutationContext context=new EntityMutationContext(discoveredEntities);
  for (  AtlasEntity entity : discoveredEntities.getRootEntities()) {
    AtlasVertex vertex=null;
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",entity);
    }
    AtlasEntityType entityType=typeRegistry.getEntityTypeByName(entity.getTypeName());
    if (entityType == null) {
      throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID,TypeCategory.ENTITY.name(),entity.getTypeName());
    }
    if (discoveredEntities.isResolved(entity.getGuid())) {
      vertex=discoveredEntities.getResolvedReference(entity.getGuid());
      context.addUpdated(entity,entityType,vertex);
      String guid=AtlasGraphUtilsV1.getIdFromVertex(vertex);
      RequestContextV1.get().recordEntityUpdate(guid);
    }
 else {
      vertex=graphMapper.createVertexTemplate(entity,entityType);
      context.addCreated(entity,entityType,vertex);
      discoveredEntities.addRepositoryResolvedReference(new AtlasObjectId(entityType.getTypeName(),entity.getGuid()),vertex);
      String guid=AtlasGraphUtilsV1.getIdFromVertex(vertex);
      RequestContextV1.get().recordEntityCreate(guid);
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",entity,vertex);
    }
  }
  return context;
}

Fixed version (ground truth):
private EntityMutationContext preCreateOrUpdate(final List<AtlasEntity> atlasEntities) throws AtlasBaseException {
  EntityGraphDiscoveryContext discoveredEntities=graphDiscoverer.discoverEntities(atlasEntities);
  EntityMutationContext context=new EntityMutationContext(discoveredEntities);
  for (  AtlasEntity entity : discoveredEntities.getRootEntities()) {
    AtlasVertex vertex=null;
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",entity);
    }
    AtlasEntityType entityType=typeRegistry.getEntityTypeByName(entity.getTypeName());
    if (entityType == null) {
      throw new AtlasBaseException(AtlasErrorCode.TYPE_NAME_INVALID,TypeCategory.ENTITY.name(),entity.getTypeName());
    }
    if (discoveredEntities.isResolved(entity.getGuid())) {
      vertex=discoveredEntities.getResolvedReference(entity.getGuid());
      context.addUpdated(entity,entityType,vertex);
      String guid=AtlasGraphUtilsV1.getIdFromVertex(vertex);
      RequestContextV1.get().recordEntityUpdate(new AtlasObjectId(entityType.getTypeName(),guid));
    }
 else {
      vertex=graphMapper.createVertexTemplate(entity,entityType);
      context.addCreated(entity,entityType,vertex);
      discoveredEntities.addRepositoryResolvedReference(new AtlasObjectId(entityType.getTypeName(),entity.getGuid()),vertex);
      String guid=AtlasGraphUtilsV1.getIdFromVertex(vertex);
      RequestContextV1.get().recordEntityCreate(new AtlasObjectId(entityType.getTypeName(),guid));
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",entity,vertex);
    }
  }
  return context;
}
Program: 171089
Project: 171089
Buggy source:
/** 
 * Deletes the specified entity vertices. Deletes any traits, composite entities, and structs owned by each entity. Also deletes all the references from/to the entity.
 * @param instanceVertices
 * @throws AtlasException
 */
public void deleteEntities(List<AtlasVertex> instanceVertices) throws AtlasBaseException {
  RequestContextV1 requestContext=RequestContextV1.get();
  Set<AtlasVertex> deletionCandidateVertices=new HashSet<>();
  for (  AtlasVertex instanceVertex : instanceVertices) {
    String guid=GraphHelper.getGuid(instanceVertex);
    AtlasEntity.Status state=AtlasGraphUtilsV1.getState(instanceVertex);
    if (requestContext.getDeletedEntityIds().contains(guid) || state == AtlasEntity.Status.DELETED) {
      LOG.debug("String_Node_Str",guid);
      continue;
    }
    Set<GraphHelper.VertexInfo> compositeVertices=getCompositeVertices(instanceVertex);
    for (    GraphHelper.VertexInfo vertexInfo : compositeVertices) {
      requestContext.recordEntityDelete(vertexInfo.getGuid());
      deletionCandidateVertices.add(vertexInfo.getVertex());
    }
  }
  for (  AtlasVertex deletionCandidateVertex : deletionCandidateVertices) {
    deleteAllTraits(deletionCandidateVertex);
    deleteTypeVertex(deletionCandidateVertex,false);
  }
}

Fixed version (ground truth):
/** 
 * Deletes the specified entity vertices. Deletes any traits, composite entities, and structs owned by each entity. Also deletes all the references from/to the entity.
 * @param instanceVertices
 * @throws AtlasException
 */
public void deleteEntities(List<AtlasVertex> instanceVertices) throws AtlasBaseException {
  RequestContextV1 requestContext=RequestContextV1.get();
  Set<AtlasVertex> deletionCandidateVertices=new HashSet<>();
  for (  AtlasVertex instanceVertex : instanceVertices) {
    String guid=GraphHelper.getGuid(instanceVertex);
    AtlasEntity.Status state=AtlasGraphUtilsV1.getState(instanceVertex);
    if (requestContext.getDeletedEntityIds().contains(guid) || state == AtlasEntity.Status.DELETED) {
      LOG.debug("String_Node_Str",guid);
      continue;
    }
    Set<GraphHelper.VertexInfo> compositeVertices=getCompositeVertices(instanceVertex);
    for (    GraphHelper.VertexInfo vertexInfo : compositeVertices) {
      requestContext.recordEntityDelete(new AtlasObjectId(vertexInfo.getTypeName(),vertexInfo.getGuid()));
      deletionCandidateVertices.add(vertexInfo.getVertex());
    }
  }
  for (  AtlasVertex deletionCandidateVertex : deletionCandidateVertices) {
    deleteAllTraits(deletionCandidateVertex);
    deleteTypeVertex(deletionCandidateVertex,false);
  }
}
Program: 171090
Project: 171090
Buggy source:
@Inject public EntityGraphMapper(ArrayVertexMapper arrayVertexMapper,MapVertexMapper mapVertexMapper){
  this.structVertexMapper=new StructVertexMapper(arrayVertexMapper,mapVertexMapper);
  arrayVertexMapper.init(structVertexMapper);
  mapVertexMapper.init(structVertexMapper);
}

Fixed version (ground truth):
@Inject public EntityGraphMapper(ArrayVertexMapper arrayVertexMapper,MapVertexMapper mapVertexMapper,DeleteHandlerV1 deleteHandler){
  this.structVertexMapper=new StructVertexMapper(arrayVertexMapper,mapVertexMapper,deleteHandler);
  arrayVertexMapper.init(structVertexMapper);
  mapVertexMapper.init(structVertexMapper);
}
Program: 171091
Project: 171091
Buggy source:
private AtlasEdge updateEdge(AtlasAttributeDef attributeDef,Object value,AtlasEdge currentEdge,final AtlasVertex entityVertex) throws AtlasBaseException {
  LOG.debug("String_Node_Str",attributeDef.getName());
  AtlasVertex currentVertex=currentEdge.getInVertex();
  String currentEntityId=AtlasGraphUtilsV1.getIdFromVertex(currentVertex);
  String newEntityId=getId(value);
  AtlasEdge newEdge=currentEdge;
  if (!currentEntityId.equals(newEntityId)) {
    if (entityVertex != null) {
      try {
        newEdge=graphHelper.getOrCreateEdge(currentEdge.getInVertex(),entityVertex,currentEdge.getLabel());
      }
 catch (      RepositoryException e) {
        throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR,e);
      }
    }
  }
  return newEdge;
}

Fixed version (ground truth):
private AtlasEdge updateEdge(AtlasAttributeDef attributeDef,Object value,AtlasEdge currentEdge,final AtlasVertex entityVertex) throws AtlasBaseException {
  LOG.debug("String_Node_Str",attributeDef.getName());
  AtlasVertex currentVertex=currentEdge.getInVertex();
  String currentEntityId=AtlasGraphUtilsV1.getIdFromVertex(currentVertex);
  String newEntityId=AtlasGraphUtilsV1.getIdFromVertex(entityVertex);
  AtlasEdge newEdge=currentEdge;
  if (!currentEntityId.equals(newEntityId)) {
    if (entityVertex != null) {
      try {
        newEdge=graphHelper.getOrCreateEdge(currentEdge.getOutVertex(),entityVertex,currentEdge.getLabel());
      }
 catch (      RepositoryException e) {
        throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR,e);
      }
    }
  }
  return newEdge;
}
Program: 171092
Project: 171092
Buggy source:
public EntityMutationResponse mapAttributes(EntityMutationContext ctx) throws AtlasBaseException {
  this.context=ctx;
  structVertexMapper.init(this);
  EntityMutationResponse resp=new EntityMutationResponse();
  if (ctx.getCreatedEntities() != null) {
    for (    AtlasEntity createdEntity : ctx.getCreatedEntities()) {
      AtlasVertex vertex=ctx.getVertex(createdEntity);
      structVertexMapper.mapAttributestoVertex(EntityMutations.EntityOperation.CREATE,ctx.getType(createdEntity),createdEntity,vertex);
      resp.addEntity(EntityMutations.EntityOperation.CREATE,constructHeader(createdEntity,ctx.getType(createdEntity),vertex));
    }
  }
  if (ctx.getUpdatedEntities() != null) {
    for (    AtlasEntity updated : ctx.getUpdatedEntities()) {
      AtlasVertex vertex=ctx.getVertex(updated);
      structVertexMapper.mapAttributestoVertex(EntityMutations.EntityOperation.UPDATE,ctx.getType(updated),updated,vertex);
      resp.addEntity(EntityMutations.EntityOperation.UPDATE,constructHeader(updated,ctx.getType(updated),vertex));
    }
  }
  return resp;
}

Fixed version (ground truth):
public EntityMutationResponse mapAttributes(EntityMutationContext ctx) throws AtlasBaseException {
  this.context=ctx;
  structVertexMapper.init(this);
  EntityMutationResponse resp=new EntityMutationResponse();
  if (ctx.getCreatedEntities() != null) {
    for (    AtlasEntity createdEntity : ctx.getCreatedEntities()) {
      AtlasVertex vertex=ctx.getVertex(createdEntity);
      structVertexMapper.mapAttributestoVertex(EntityMutations.EntityOperation.CREATE,ctx.getType(createdEntity),createdEntity,vertex);
      resp.addEntity(EntityMutations.EntityOperation.CREATE,constructHeader(createdEntity,ctx.getType(createdEntity),vertex));
    }
  }
  if (ctx.getUpdatedEntities() != null) {
    for (    AtlasEntity updated : ctx.getUpdatedEntities()) {
      AtlasVertex vertex=ctx.getVertex(updated);
      structVertexMapper.mapAttributestoVertex(EntityMutations.EntityOperation.UPDATE,ctx.getType(updated),updated,vertex);
      resp.addEntity(EntityMutations.EntityOperation.UPDATE,constructHeader(updated,ctx.getType(updated),vertex));
    }
  }
  RequestContextV1 req=RequestContextV1.get();
  for (  AtlasObjectId id : req.getDeletedEntityIds()) {
    resp.addEntity(EntityMutations.EntityOperation.DELETE,constructHeader(id));
  }
  return resp;
}
Program: 171093
Project: 171093
Buggy source:
@Override public AtlasEdge toGraph(GraphMutationContext ctx) throws AtlasBaseException {
  AtlasEdge result=null;
  String guid=getId(ctx.getValue());
  AtlasVertex entityVertex=context.getDiscoveryContext().getResolvedReference(guid);
  if (ctx.getCurrentEdge().isPresent()) {
    updateEdge(ctx.getAttributeDef(),ctx.getValue(),ctx.getCurrentEdge().get(),entityVertex);
    result=ctx.getCurrentEdge().get();
  }
 else   if (ctx.getValue() != null) {
    String edgeLabel=AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexPropertyKey());
    try {
      result=graphHelper.getOrCreateEdge(ctx.getReferringVertex(),entityVertex,edgeLabel);
    }
 catch (    RepositoryException e) {
      throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR,e);
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public AtlasEdge toGraph(GraphMutationContext ctx) throws AtlasBaseException {
  AtlasEdge result=null;
  String guid=getId(ctx.getValue());
  AtlasVertex entityVertex=context.getDiscoveryContext().getResolvedReference(guid);
  if (ctx.getCurrentEdge().isPresent()) {
    result=updateEdge(ctx.getAttributeDef(),ctx.getValue(),ctx.getCurrentEdge().get(),entityVertex);
  }
 else   if (ctx.getValue() != null) {
    String edgeLabel=AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexPropertyKey());
    try {
      result=graphHelper.getOrCreateEdge(ctx.getReferringVertex(),entityVertex,edgeLabel);
    }
 catch (    RepositoryException e) {
      throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR,e);
    }
  }
  return result;
}
Program: 171094
Project: 171094
Buggy source:
private AtlasEntityHeader constructHeader(AtlasEntity entity,final AtlasEntityType type,AtlasVertex vertex){
  AtlasEntityHeader header=new AtlasEntityHeader(entity.getTypeName(),AtlasGraphUtilsV1.getIdFromVertex(vertex),entity.getAttributes());
  final Map<String,AtlasStructType.AtlasAttribute> allAttributes=type.getAllAttributes();
  for (  String attribute : allAttributes.keySet()) {
    AtlasType attributeType=allAttributes.get(attribute).getAttributeType();
    AtlasAttributeDef attributeDef=allAttributes.get(attribute).getAttributeDef();
    if (header.getAttribute(attribute) == null && (TypeCategory.PRIMITIVE == attributeType.getTypeCategory())) {
      if (attributeDef.getIsOptional()) {
        header.setAttribute(attribute,attributeType.createOptionalDefaultValue());
      }
 else {
        header.setAttribute(attribute,attributeType.createDefaultValue());
      }
    }
  }
  return header;
}

Fixed version (ground truth):
private AtlasEntityHeader constructHeader(AtlasObjectId id){
  AtlasEntityHeader entity=new AtlasEntityHeader(id.getTypeName());
  entity.setGuid(id.getGuid());
  return entity;
}
Program: 171095
Project: 171095
Buggy source:
public StructVertexMapper(ArrayVertexMapper arrayVertexMapper,MapVertexMapper mapVertexMapper){
  this.graph=AtlasGraphProvider.getGraphInstance();
  ;
  this.mapVertexMapper=mapVertexMapper;
  this.arrVertexMapper=arrayVertexMapper;
}

Fixed version (ground truth):
public StructVertexMapper(ArrayVertexMapper arrayVertexMapper,MapVertexMapper mapVertexMapper,DeleteHandlerV1 deleteHandler){
  this.graph=AtlasGraphProvider.getGraphInstance();
  ;
  this.mapVertexMapper=mapVertexMapper;
  this.arrVertexMapper=arrayVertexMapper;
  this.deleteHandler=deleteHandler;
}
Program: 171096
Project: 171096
Buggy source:
protected Object mapToVertexByTypeCategory(GraphMutationContext ctx) throws AtlasBaseException {
  if (ctx.getOp() == EntityMutations.EntityOperation.CREATE && ctx.getValue() == null) {
    return null;
  }
switch (ctx.getAttrType().getTypeCategory()) {
case PRIMITIVE:
case ENUM:
    return primitivesToVertex(ctx);
case STRUCT:
  String edgeLabel=AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexPropertyKey());
AtlasEdge currentEdge=graphHelper.getEdgeForLabel(ctx.getReferringVertex(),edgeLabel);
Optional<AtlasEdge> edge=currentEdge != null ? Optional.of(currentEdge) : Optional.<AtlasEdge>absent();
ctx.setExistingEdge(edge);
return toGraph(ctx);
case ENTITY:
edgeLabel=AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexPropertyKey());
currentEdge=graphHelper.getEdgeForLabel(ctx.getReferringVertex(),edgeLabel);
AtlasEntityType instanceType=entityVertexMapper.getInstanceType(ctx.getValue());
edge=currentEdge != null ? Optional.of(currentEdge) : Optional.<AtlasEdge>absent();
ctx.setElementType(instanceType);
ctx.setExistingEdge(edge);
return entityVertexMapper.toGraph(ctx);
case MAP:
return mapVertexMapper.toGraph(ctx);
case ARRAY:
return arrVertexMapper.toGraph(ctx);
default :
throw new AtlasBaseException(AtlasErrorCode.TYPE_CATEGORY_INVALID,ctx.getAttrType().getTypeCategory().name());
}
}

Fixed version (ground truth):
protected Object mapToVertexByTypeCategory(GraphMutationContext ctx) throws AtlasBaseException {
  if (ctx.getOp() == EntityMutations.EntityOperation.CREATE && ctx.getValue() == null) {
    return null;
  }
switch (ctx.getAttrType().getTypeCategory()) {
case PRIMITIVE:
case ENUM:
    return primitivesToVertex(ctx);
case STRUCT:
  String edgeLabel=AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexPropertyKey());
AtlasEdge currentEdge=graphHelper.getEdgeForLabel(ctx.getReferringVertex(),edgeLabel);
Optional<AtlasEdge> edge=currentEdge != null ? Optional.of(currentEdge) : Optional.<AtlasEdge>absent();
ctx.setExistingEdge(edge);
AtlasEdge newEdge=toGraph(ctx);
if (currentEdge != null && !currentEdge.equals(newEdge)) {
deleteHandler.deleteEdgeReference(currentEdge,ctx.getAttrType().getTypeCategory(),false,true);
}
return newEdge;
case ENTITY:
edgeLabel=AtlasGraphUtilsV1.getEdgeLabel(ctx.getVertexPropertyKey());
currentEdge=graphHelper.getEdgeForLabel(ctx.getReferringVertex(),edgeLabel);
AtlasEntityType instanceType=entityVertexMapper.getInstanceType(ctx.getValue());
edge=currentEdge != null ? Optional.of(currentEdge) : Optional.<AtlasEdge>absent();
ctx.setElementType(instanceType);
ctx.setExistingEdge(edge);
newEdge=entityVertexMapper.toGraph(ctx);
if (currentEdge != null && !currentEdge.equals(newEdge)) {
deleteHandler.deleteEdgeReference(currentEdge,ctx.getAttrType().getTypeCategory(),shouldManageChildReferences(ctx.getParentType(),ctx.getAttributeDef().getName()),true);
}
return newEdge;
case MAP:
return mapVertexMapper.toGraph(ctx);
case ARRAY:
return arrVertexMapper.toGraph(ctx);
default :
throw new AtlasBaseException(AtlasErrorCode.TYPE_CATEGORY_INVALID,ctx.getAttrType().getTypeCategory().name());
}
}
Program: 171097
Project: 171097
Buggy source:
protected Map<String,Object> fromV2ToV1(AtlasStructType structType,Map attributes) throws AtlasBaseException {
  Map<String,Object> ret=null;
  if (MapUtils.isNotEmpty(attributes)) {
    ret=new HashMap<>();
    for (    AtlasStructDef.AtlasAttributeDef attrDef : getAttributeDefs(structType)) {
      AtlasType attrType=structType.getAttributeType(attrDef.getName());
      AtlasFormatConverter attrConverter=converterRegistry.getConverter(attrType.getTypeCategory());
      Object v2Value=attributes.get(attrDef.getName());
      Object v1Value=attrConverter.fromV2ToV1(v2Value,attrType);
      ret.put(attrDef.getName(),v1Value);
    }
  }
  return ret;
}

Fixed version (ground truth):
protected Map<String,Object> fromV2ToV1(AtlasStructType structType,Map attributes) throws AtlasBaseException {
  Map<String,Object> ret=null;
  if (MapUtils.isNotEmpty(attributes)) {
    ret=new HashMap<>();
    for (    AtlasStructDef.AtlasAttributeDef attrDef : getAttributeDefs(structType)) {
      AtlasType attrType=structType.getAttributeType(attrDef.getName());
      if (attrType == null) {
        LOG.warn("String_Node_Str",structType.getTypeName(),attrDef.getName());
        continue;
      }
      AtlasFormatConverter attrConverter=converterRegistry.getConverter(attrType.getTypeCategory());
      Object v2Value=attributes.get(attrDef.getName());
      Object v1Value=attrConverter.fromV2ToV1(v2Value,attrType);
      ret.put(attrDef.getName(),v1Value);
    }
  }
  return ret;
}
Program: 171098
Project: 171098
Buggy source:
/** 
 * Bulk retrieval API for searching on entities by certain predefined attributes ( typeName, superType, name, qualifiedName etc) + optional user defined attributes
 * @throws AtlasBaseException
 */
@GET @Produces(Servlets.JSON_MEDIA_TYPE) public AtlasEntityHeader.AtlasEntityHeaders searchEntities() throws AtlasBaseException {
  SearchFilter searchFilter=getSearchFilter();
  AtlasEntity.AtlasEntities atlasEntities=entitiesStore.searchEntities(searchFilter);
  AtlasEntityHeader.AtlasEntityHeaders entityHeaders=new AtlasEntityHeader.AtlasEntityHeaders();
  entityHeaders.setList(new LinkedList<AtlasEntityHeader>());
  for (  AtlasEntity atlasEntity : atlasEntities.getList()) {
    entityHeaders.getList().add(new AtlasEntityHeader(atlasEntity.getTypeName(),atlasEntity.getAttributes()));
  }
  return entityHeaders;
}

Fixed version (ground truth):
/** 
 * Bulk retrieval API for searching on entities by certain predefined attributes ( typeName, superType, name, qualifiedName etc) + optional user defined attributes
 * @throws AtlasBaseException
 */
@GET @Produces(Servlets.JSON_MEDIA_TYPE) public AtlasEntityHeader.AtlasEntityHeaders searchEntities() throws AtlasBaseException {
  SearchFilter searchFilter=getSearchFilter();
  AtlasEntity.AtlasEntities atlasEntities=entitiesStore.searchEntities(searchFilter);
  AtlasEntityHeader.AtlasEntityHeaders entityHeaders=new AtlasEntityHeader.AtlasEntityHeaders();
  entityHeaders.setList(new LinkedList<AtlasEntityHeader>());
  if (atlasEntities != null) {
    for (    AtlasEntity atlasEntity : atlasEntities.getList()) {
      entityHeaders.getList().add(new AtlasEntityHeader(atlasEntity.getTypeName(),atlasEntity.getAttributes()));
    }
  }
  return entityHeaders;
}
Program: 171099
Project: 171099
Buggy source:
@Override public void run(){
  try {
    fireAndForget(event);
  }
 catch (  Throwable e) {
    LOG.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Override public Object run() throws Exception {
  notifyEntities(event.getMessages());
  return event;
}
Program: 171100
Project: 171100
Buggy source:
/** 
 * Returns the user. Order of preference: 1. Given userName 2. ugi.getShortUserName() 3. UserGroupInformation.getCurrentUser().getShortUserName() 4. System.getProperty("user.name")
 */
public static String getUser(String userName,UserGroupInformation ugi){
  if (StringUtils.isNotEmpty(userName)) {
    return userName;
  }
  if (ugi != null && StringUtils.isNotEmpty(ugi.getShortUserName())) {
    return ugi.getShortUserName();
  }
  try {
    return UserGroupInformation.getCurrentUser().getShortUserName();
  }
 catch (  IOException e) {
    LOG.warn("String_Node_Str");
    return System.getProperty("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Returns the user. Order of preference: 1. Given userName 2. ugi.getShortUserName() 3. UserGroupInformation.getCurrentUser().getShortUserName() 4. System.getProperty("user.name")
 */
public static String getUser(String userName,UserGroupInformation ugi){
  if (StringUtils.isNotEmpty(userName)) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + userName);
    }
    return userName;
  }
  if (ugi != null && StringUtils.isNotEmpty(ugi.getShortUserName())) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str" + userName);
    }
    return ugi.getShortUserName();
  }
  try {
    return UserGroupInformation.getCurrentUser().getShortUserName();
  }
 catch (  IOException e) {
    LOG.warn("String_Node_Str",e);
    return System.getProperty("String_Node_Str");
  }
}
Program: 171102
Project: 171102
Buggy source:
@Test public void testUpdate() throws Exception {
  HierarchicalTypeDefinition<ClassType> typeDefinition=TypesUtil.createClassTypeDef(randomString(),ImmutableSet.<String>of(),TypesUtil.createUniqueRequiredAttrDef("String_Node_Str",DataTypes.STRING_TYPE));
  List<String> typesCreated=serviceClient.createType(TypesSerialization.toJson(typeDefinition,false));
  assertEquals(typesCreated.size(),1);
  assertEquals(typesCreated.get(0),typeDefinition.typeName);
  typeDefinition=TypesUtil.createClassTypeDef(typeDefinition.typeName,ImmutableSet.<String>of(),TypesUtil.createUniqueRequiredAttrDef("String_Node_Str",DataTypes.STRING_TYPE),createOptionalAttrDef("String_Node_Str",DataTypes.STRING_TYPE));
  TypesDef typeDef=TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(),ImmutableList.<StructTypeDefinition>of(),ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),ImmutableList.of(typeDefinition));
  List<String> typesUpdated=serviceClient.updateType(typeDef);
  assertEquals(typesUpdated.size(),1);
  Assert.assertTrue(typesUpdated.contains(typeDefinition.typeName));
  HierarchicalTypeDefinition<ClassType> updatedType=serviceClient.getType(typeDefinition.typeName).classTypesAsJavaList().get(0);
  assertEquals(updatedType.attributeDefinitions.length,2);
}

Fixed version (ground truth):
@Test public void testUpdate() throws Exception {
  HierarchicalTypeDefinition<ClassType> typeDefinition=TypesUtil.createClassTypeDef(randomString(),ImmutableSet.<String>of(),TypesUtil.createUniqueRequiredAttrDef("String_Node_Str",DataTypes.STRING_TYPE));
  List<String> typesCreated=serviceClient.createType(TypesSerialization.toJson(typeDefinition,false));
  assertEquals(typesCreated.size(),1);
  assertEquals(typesCreated.get(0),typeDefinition.typeName);
  typeDefinition=TypesUtil.createClassTypeDef(typeDefinition.typeName,ImmutableSet.<String>of(),TypesUtil.createUniqueRequiredAttrDef("String_Node_Str",DataTypes.STRING_TYPE),createOptionalAttrDef("String_Node_Str",DataTypes.STRING_TYPE));
  TypesDef typeDef=TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(),ImmutableList.<StructTypeDefinition>of(),ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),ImmutableList.of(typeDefinition));
  List<String> typesUpdated=serviceClient.updateType(typeDef);
  assertEquals(typesUpdated.size(),1);
  Assert.assertTrue(typesUpdated.contains(typeDefinition.typeName));
  TypesDef updatedTypeDef=serviceClient.getType(typeDefinition.typeName);
  assertNotNull(updatedTypeDef);
  HierarchicalTypeDefinition<ClassType> updatedType=updatedTypeDef.classTypesAsJavaList().get(0);
  assertEquals(updatedType.attributeDefinitions.length,2);
}
Program: 171103
Project: 171103
Buggy source:
PList<AtlasEntity> searchEntities(SearchFilter filter) throws AtlasBaseException ;

Fixed version (ground truth):
AtlasEntities searchEntities(SearchFilter filter) throws AtlasBaseException ;
Program: 171104
Project: 171104
Buggy source:
PList<AtlasStructDef> searchStructDefs(SearchFilter filter) throws AtlasBaseException ;

Fixed version (ground truth):
AtlasStructDefs searchStructDefs(SearchFilter filter) throws AtlasBaseException ;
Program: 171105
Project: 171105
Buggy source:
PList<AtlasEnumDef> searchEnumDefs(SearchFilter filter) throws AtlasBaseException ;

Fixed version (ground truth):
AtlasEnumDefs searchEnumDefs(SearchFilter filter) throws AtlasBaseException ;
Program: 171106
Project: 171106
Buggy source:
PList<AtlasEntityDef> searchEntityDefs(SearchFilter filter) throws AtlasBaseException ;

Fixed version (ground truth):
AtlasEntityDefs searchEntityDefs(SearchFilter filter) throws AtlasBaseException ;
Program: 171107
Project: 171107
Buggy source:
PList<AtlasClassificationDef> searchClassificationDefs(SearchFilter filter) throws AtlasBaseException ;

Fixed version (ground truth):
AtlasClassificationDefs searchClassificationDefs(SearchFilter filter) throws AtlasBaseException ;
Program: 171108
Project: 171108
Buggy source:
@Override public int hashCode(){
  int result=super.hashCode();
  result=31 * result + guid != null ? guid.hashCode() : 0;
  result=31 * result + (status != null ? status.hashCode() : 0);
  result=31 * result + (createdBy != null ? createdBy.hashCode() : 0);
  result=31 * result + (updatedBy != null ? updatedBy.hashCode() : 0);
  result=31 * result + (createTime != null ? createTime.hashCode() : 0);
  result=31 * result + (updateTime != null ? updateTime.hashCode() : 0);
  result=31 * result + (version != null ? version.hashCode() : 0);
  return result;
}

Fixed version (ground truth):
@Override public int hashCode(){
  int result=super.hashCode();
  result=31 * result + (guid != null ? guid.hashCode() : 0);
  result=31 * result + (status != null ? status.hashCode() : 0);
  result=31 * result + (createdBy != null ? createdBy.hashCode() : 0);
  result=31 * result + (updatedBy != null ? updatedBy.hashCode() : 0);
  result=31 * result + (createTime != null ? createTime.hashCode() : 0);
  result=31 * result + (updateTime != null ? updateTime.hashCode() : 0);
  result=31 * result + (version != null ? version.hashCode() : 0);
  return result;
}
Program: 171109
Project: 171109
Buggy source:
@VisibleForTesting static String getProcessQualifiedName(HiveMetaStoreBridge dgiBridge,HiveEventContext eventContext,final SortedSet<ReadEntity> sortedHiveInputs,final SortedSet<WriteEntity> sortedHiveOutputs,SortedMap<ReadEntity,Referenceable> hiveInputsMap,SortedMap<WriteEntity,Referenceable> hiveOutputsMap) throws HiveException {
  HiveOperation op=eventContext.getOperation();
  if (isCreateOp(eventContext)) {
    Table outTable=getEntityByType(sortedHiveOutputs,Type.TABLE).getTable();
    outTable=dgiBridge.hiveClient.getTable(outTable.getDbName(),outTable.getTableName());
    return HiveMetaStoreBridge.getTableProcessQualifiedName(dgiBridge.getClusterName(),outTable);
  }
  StringBuilder buffer=new StringBuilder(op.getOperationName());
  boolean ignoreHDFSPathsinQFName=ignoreHDFSPathsinQFName(op,sortedHiveInputs,sortedHiveOutputs);
  if (ignoreHDFSPathsinQFName && LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str",op,eventContext.getQueryStr());
  }
  addInputs(dgiBridge,op,sortedHiveInputs,buffer,hiveInputsMap,ignoreHDFSPathsinQFName);
  buffer.append(IO_SEP);
  addOutputs(dgiBridge,op,sortedHiveOutputs,buffer,hiveOutputsMap,ignoreHDFSPathsinQFName);
  LOG.info("String_Node_Str",buffer);
  return buffer.toString();
}

Fixed version (ground truth):
@VisibleForTesting static String getProcessQualifiedName(HiveMetaStoreBridge dgiBridge,HiveEventContext eventContext,final SortedSet<ReadEntity> sortedHiveInputs,final SortedSet<WriteEntity> sortedHiveOutputs,SortedMap<ReadEntity,Referenceable> hiveInputsMap,SortedMap<WriteEntity,Referenceable> hiveOutputsMap) throws HiveException {
  HiveOperation op=eventContext.getOperation();
  if (isCreateOp(eventContext)) {
    Entity entity=getEntityByType(sortedHiveOutputs,Type.TABLE);
    if (entity != null) {
      Table outTable=entity.getTable();
      outTable=dgiBridge.hiveClient.getTable(outTable.getDbName(),outTable.getTableName());
      return HiveMetaStoreBridge.getTableProcessQualifiedName(dgiBridge.getClusterName(),outTable);
    }
  }
  StringBuilder buffer=new StringBuilder(op.getOperationName());
  boolean ignoreHDFSPathsinQFName=ignoreHDFSPathsinQFName(op,sortedHiveInputs,sortedHiveOutputs);
  if (ignoreHDFSPathsinQFName && LOG.isDebugEnabled()) {
    LOG.debug("String_Node_Str",op,eventContext.getQueryStr());
  }
  addInputs(dgiBridge,op,sortedHiveInputs,buffer,hiveInputsMap,ignoreHDFSPathsinQFName);
  buffer.append(IO_SEP);
  addOutputs(dgiBridge,op,sortedHiveOutputs,buffer,hiveOutputsMap,ignoreHDFSPathsinQFName);
  LOG.info("String_Node_Str",buffer);
  return buffer.toString();
}
Program: 171110
Project: 171110
Buggy source:
private static List<Referenceable> getInputEntities(org.apache.falcon.entity.v0.cluster.Cluster cluster,Feed feed) throws Exception {
  org.apache.falcon.entity.v0.feed.Cluster feedCluster=FeedHelper.getCluster(feed,cluster.getName());
  final CatalogTable table=getTable(feedCluster,feed);
  if (table != null) {
    CatalogStorage storage=new CatalogStorage(cluster,table);
    return createHiveTableInstance(cluster.getName(),storage.getDatabase().toLowerCase(),storage.getTable().toLowerCase());
  }
 else {
    List<Location> locations=FeedHelper.getLocations(feedCluster,feed);
    Location dataLocation=FileSystemStorage.getLocation(locations,LocationType.DATA);
    final String pathUri=normalize(dataLocation.getPath());
    LOG.info("String_Node_Str",pathUri);
    return fillHDFSDataSet(pathUri,cluster.getName());
  }
}

Fixed version (ground truth):
private static List<Referenceable> getInputEntities(org.apache.falcon.entity.v0.cluster.Cluster cluster,Feed feed) throws Exception {
  org.apache.falcon.entity.v0.feed.Cluster feedCluster=FeedHelper.getCluster(feed,cluster.getName());
  if (feedCluster != null) {
    final CatalogTable table=getTable(feedCluster,feed);
    if (table != null) {
      CatalogStorage storage=new CatalogStorage(cluster,table);
      return createHiveTableInstance(cluster.getName(),storage.getDatabase().toLowerCase(),storage.getTable().toLowerCase());
    }
 else {
      List<Location> locations=FeedHelper.getLocations(feedCluster,feed);
      if (CollectionUtils.isNotEmpty(locations)) {
        Location dataLocation=FileSystemStorage.getLocation(locations,LocationType.DATA);
        if (dataLocation != null) {
          final String pathUri=normalize(dataLocation.getPath());
          LOG.info("String_Node_Str",pathUri);
          return fillHDFSDataSet(pathUri,cluster.getName());
        }
      }
    }
  }
  return null;
}
Program: 171111
Project: 171111
Buggy source:
private <T extends Entity>void processHiveEntity(HiveMetaStoreBridge dgiBridge,HiveEventContext event,T entity,Set<String> dataSetsProcessed,SortedMap<T,Referenceable> dataSets,Set<Referenceable> entities) throws Exception {
  if (entity.getType() == Type.TABLE || entity.getType() == Type.PARTITION) {
    final String tblQFName=dgiBridge.getTableQualifiedName(dgiBridge.getClusterName(),entity.getTable());
    if (!dataSetsProcessed.contains(tblQFName)) {
      LinkedHashMap<Type,Referenceable> result=createOrUpdateEntities(dgiBridge,event,entity,false);
      dataSets.put(entity,result.get(Type.TABLE));
      dataSetsProcessed.add(tblQFName);
      entities.addAll(result.values());
    }
  }
 else   if (entity.getType() == Type.DFS_DIR) {
    final String pathUri=lower(new Path(entity.getLocation()).toString());
    LOG.debug("String_Node_Str",pathUri);
    if (!dataSetsProcessed.contains(pathUri)) {
      Referenceable hdfsPath=dgiBridge.fillHDFSDataSet(pathUri);
      dataSets.put(entity,hdfsPath);
      dataSetsProcessed.add(pathUri);
      entities.add(hdfsPath);
    }
  }
}

Fixed version (ground truth):
private <T extends Entity>void processHiveEntity(HiveMetaStoreBridge dgiBridge,HiveEventContext event,T entity,Set<String> dataSetsProcessed,SortedMap<T,Referenceable> dataSets,Set<Referenceable> entities) throws Exception {
  if (entity.getType() == Type.TABLE || entity.getType() == Type.PARTITION) {
    final String tblQFName=dgiBridge.getTableQualifiedName(dgiBridge.getClusterName(),entity.getTable());
    if (!dataSetsProcessed.contains(tblQFName)) {
      LinkedHashMap<Type,Referenceable> result=createOrUpdateEntities(dgiBridge,event,entity,false);
      dataSets.put(entity,result.get(Type.TABLE));
      dataSetsProcessed.add(tblQFName);
      entities.addAll(result.values());
    }
  }
 else   if (entity.getType() == Type.DFS_DIR) {
    URI location=entity.getLocation();
    if (location != null) {
      final String pathUri=lower(new Path(location).toString());
      LOG.debug("String_Node_Str",pathUri);
      if (!dataSetsProcessed.contains(pathUri)) {
        Referenceable hdfsPath=dgiBridge.fillHDFSDataSet(pathUri);
        dataSets.put(entity,hdfsPath);
        dataSetsProcessed.add(pathUri);
        entities.add(hdfsPath);
      }
    }
  }
}
Program: 171113
Project: 171113
Buggy source:
private void parseUsers(String usersDef,PolicyDef def){
  if (isDebugEnabled) {
    LOG.debug("String_Node_Str");
  }
  String[] users=usersDef.split("String_Node_Str");
  String[] userAndRole=null;
  Map<String,List<AtlasActionTypes>> usersMap=new HashMap<String,List<AtlasActionTypes>>();
  if (validateEntity(usersDef)) {
    for (    String user : users) {
      if (!Pattern.matches("String_Node_Str",user)) {
        continue;
      }
      userAndRole=user.split("String_Node_Str");
      if (def.getUsers() != null) {
        usersMap=def.getUsers();
      }
      List<AtlasActionTypes> userAutorities=usersMap.get(userAndRole[USERNAME]);
      if (userAutorities == null) {
        userAutorities=new ArrayList<AtlasActionTypes>();
      }
      userAutorities=getListOfAutorities(userAndRole[USER_AUTHORITIES]);
      usersMap.put(userAndRole[USERNAME],userAutorities);
      def.setUsers(usersMap);
    }
  }
 else {
    def.setUsers(usersMap);
  }
  if (isDebugEnabled) {
    LOG.debug("String_Node_Str");
  }
}

Fixed version (ground truth):
private void parseUsers(String usersDef,PolicyDef def){
  if (isDebugEnabled) {
    LOG.debug("String_Node_Str");
  }
  String[] users=usersDef.split("String_Node_Str");
  String[] userAndRole=null;
  Map<String,List<AtlasActionTypes>> usersMap=new HashMap<String,List<AtlasActionTypes>>();
  if (validateEntity(usersDef)) {
    for (    String user : users) {
      if (!Pattern.matches("String_Node_Str",user)) {
        continue;
      }
      userAndRole=user.split("String_Node_Str");
      if (def.getUsers() != null) {
        usersMap=def.getUsers();
      }
      List<AtlasActionTypes> userAutorities=getListOfAutorities(userAndRole[USER_AUTHORITIES]);
      usersMap.put(userAndRole[USERNAME],userAutorities);
      def.setUsers(usersMap);
    }
  }
 else {
    def.setUsers(usersMap);
  }
  if (isDebugEnabled) {
    LOG.debug("String_Node_Str");
  }
}
Program: 171114
Project: 171114
Buggy source:
private void parseGroups(String groupsDef,PolicyDef def){
  if (isDebugEnabled) {
    LOG.debug("String_Node_Str");
  }
  String[] groups=groupsDef.split("String_Node_Str");
  String[] groupAndRole=null;
  Map<String,List<AtlasActionTypes>> groupsMap=new HashMap<String,List<AtlasActionTypes>>();
  if (validateEntity(groupsDef.trim())) {
    for (    String group : groups) {
      if (!Pattern.matches("String_Node_Str",group)) {
        continue;
      }
      groupAndRole=group.split("String_Node_Str");
      if (def.getGroups() != null) {
        groupsMap=def.getGroups();
      }
      List<AtlasActionTypes> groupAutorities=groupsMap.get(groupAndRole[GROUPNAME]);
      if (groupAutorities == null) {
        groupAutorities=new ArrayList<AtlasActionTypes>();
      }
      groupAutorities=getListOfAutorities(groupAndRole[GROUP_AUTHORITIES]);
      groupsMap.put(groupAndRole[GROUPNAME],groupAutorities);
      def.setGroups(groupsMap);
    }
  }
 else {
    def.setGroups(groupsMap);
  }
  if (isDebugEnabled) {
    LOG.debug("String_Node_Str");
  }
}

Fixed version (ground truth):
private void parseGroups(String groupsDef,PolicyDef def){
  if (isDebugEnabled) {
    LOG.debug("String_Node_Str");
  }
  String[] groups=groupsDef.split("String_Node_Str");
  String[] groupAndRole=null;
  Map<String,List<AtlasActionTypes>> groupsMap=new HashMap<String,List<AtlasActionTypes>>();
  if (validateEntity(groupsDef.trim())) {
    for (    String group : groups) {
      if (!Pattern.matches("String_Node_Str",group)) {
        continue;
      }
      groupAndRole=group.split("String_Node_Str");
      if (def.getGroups() != null) {
        groupsMap=def.getGroups();
      }
      List<AtlasActionTypes> groupAutorities=getListOfAutorities(groupAndRole[GROUP_AUTHORITIES]);
      groupsMap.put(groupAndRole[GROUPNAME],groupAutorities);
      def.setGroups(groupsMap);
    }
  }
 else {
    def.setGroups(groupsMap);
  }
  if (isDebugEnabled) {
    LOG.debug("String_Node_Str");
  }
}
Program: 171115
Project: 171115
Buggy source:
private boolean checkAccessForGroups(Set<String> groups,Set<AtlasResourceTypes> resourceType,String resource,Map<String,Map<AtlasResourceTypes,List<String>>> map){
  boolean isAccessAllowed=false;
  if (isDebugEnabled) {
    LOG.debug("String_Node_Str");
  }
  for (  String group : groups) {
    isAccessAllowed=checkAccess(group,resourceType,resource,map);
    if (isAccessAllowed) {
      break;
    }
  }
  if (isDebugEnabled) {
    LOG.debug("String_Node_Str");
  }
  return isAccessAllowed;
}

Fixed version (ground truth):
private boolean checkAccessForGroups(Set<String> groups,Set<AtlasResourceTypes> resourceType,String resource,Map<String,Map<AtlasResourceTypes,List<String>>> map){
  boolean isAccessAllowed=false;
  if (isDebugEnabled) {
    LOG.debug("String_Node_Str");
  }
  if (CollectionUtils.isNotEmpty(groups)) {
    for (    String group : groups) {
      isAccessAllowed=checkAccess(group,resourceType,resource,map);
      if (isAccessAllowed) {
        break;
      }
    }
  }
  if (isDebugEnabled) {
    LOG.debug("String_Node_Str");
  }
  return isAccessAllowed;
}
Program: 171116
Project: 171116
Buggy source:
private JSONObject callAPIWithResource(API api,WebResource resource,Object requestObject) throws AtlasServiceException {
  ClientResponse clientResponse=null;
  for (int i=0; i < getNumberOfRetries(); i++) {
    clientResponse=resource.accept(JSON_MEDIA_TYPE).type(JSON_MEDIA_TYPE).method(api.getMethod(),ClientResponse.class,requestObject);
    LOG.debug("String_Node_Str",resource.getURI(),clientResponse.getStatus());
    if (clientResponse.getStatus() == api.getExpectedStatus().getStatusCode()) {
      String responseAsString=clientResponse.getEntity(String.class);
      try {
        return new JSONObject(responseAsString);
      }
 catch (      JSONException e) {
        throw new AtlasServiceException(api,e);
      }
    }
 else     if (clientResponse.getStatus() != ClientResponse.Status.SERVICE_UNAVAILABLE.getStatusCode()) {
      break;
    }
 else {
      LOG.error("String_Node_Str",resource);
      sleepBetweenRetries();
    }
  }
  throw new AtlasServiceException(api,clientResponse);
}

Fixed version (ground truth):
private JSONObject callAPIWithResource(API api,WebResource resource,Object requestObject) throws AtlasServiceException {
  ClientResponse clientResponse=null;
  int i=0;
  do {
    clientResponse=resource.accept(JSON_MEDIA_TYPE).type(JSON_MEDIA_TYPE).method(api.getMethod(),ClientResponse.class,requestObject);
    LOG.debug("String_Node_Str",resource.getURI(),clientResponse.getStatus());
    if (clientResponse.getStatus() == api.getExpectedStatus().getStatusCode()) {
      String responseAsString=clientResponse.getEntity(String.class);
      try {
        return new JSONObject(responseAsString);
      }
 catch (      JSONException e) {
        throw new AtlasServiceException(api,e);
      }
    }
 else     if (clientResponse.getStatus() != ClientResponse.Status.SERVICE_UNAVAILABLE.getStatusCode()) {
      break;
    }
 else {
      LOG.error("String_Node_Str",resource);
      sleepBetweenRetries();
    }
    i++;
  }
 while (i < getNumberOfRetries());
  throw new AtlasServiceException(api,clientResponse);
}