Program: 26556
Project: 26556
Buggy source:
/** 
 * handle completed node in the CD -move something from the live server list to the completed server list
 * @param status the node that has just completed
 * @return NodeCompletionResult
 */
public synchronized NodeCompletionResult onCompletedNode(ContainerStatus status){
  ContainerId containerId=status.getContainerId();
  NodeCompletionResult result=new NodeCompletionResult();
  RoleInstance roleInstance;
  if (containersBeingReleased.containsKey(containerId)) {
    log.info("String_Node_Str");
    Container container=containersBeingReleased.remove(containerId);
    RoleStatus roleStatus=lookupRoleStatus(container);
    log.info("String_Node_Str",roleStatus.getName());
    roleStatus.decReleasing();
    roleStatus.decActual();
    roleStatus.incCompleted();
    roleHistory.onReleaseCompleted(container);
  }
 else   if (surplusNodes.remove(containerId)) {
    result.surplusNode=true;
  }
 else {
    result.containerFailed=true;
    roleInstance=activeContainers.remove(containerId);
    if (roleInstance != null) {
      incFailedCountainerCount();
      failedNodes.put(containerId,roleInstance);
    }
 else {
      roleInstance=failedNodes.get(containerId);
    }
    if (roleInstance != null) {
      int roleId=roleInstance.roleId;
      log.info("String_Node_Str",roleId);
      try {
        RoleStatus roleStatus=lookupRoleStatus(roleId);
        roleStatus.decActual();
        boolean shortLived=isShortLived(roleInstance);
        String message;
        if (roleInstance.container != null) {
          message=String.format("String_Node_Str",roleInstance.getContainerId(),roleInstance.container.getNodeId().getHost());
        }
 else {
          message=String.format("String_Node_Str",containerId.toString());
        }
        roleStatus.noteFailed(message);
        if (shortLived) {
          roleStatus.incStartFailed();
        }
        roleHistory.onFailedContainer(roleInstance.container,shortLived);
      }
 catch (      YarnRuntimeException e1) {
        log.error("String_Node_Str",roleId);
      }
    }
 else {
      log.error("String_Node_Str" + "String_Node_Str");
      completionOfUnknownContainerEvent.incrementAndGet();
    }
  }
  if (result.surplusNode) {
    return result;
  }
  ContainerId id=status.getContainerId();
  RoleInstance node=getLiveNodes().remove(id);
  if (node == null) {
    log.warn("String_Node_Str");
    completionOfNodeNotInLiveListEvent.incrementAndGet();
  }
 else {
    node.state=ClusterDescription.STATE_DESTROYED;
    node.exitCode=status.getExitStatus();
    node.diagnostics=status.getDiagnostics();
    getCompletedNodes().put(id,node);
    result.roleInstance=node;
  }
  return result;
}

Fixed version (ground truth):
/** 
 * handle completed node in the CD -move something from the live server list to the completed server list
 * @param status the node that has just completed
 * @return NodeCompletionResult
 */
public synchronized NodeCompletionResult onCompletedNode(ContainerStatus status){
  ContainerId containerId=status.getContainerId();
  NodeCompletionResult result=new NodeCompletionResult();
  RoleInstance roleInstance;
  if (containersBeingReleased.containsKey(containerId)) {
    log.info("String_Node_Str");
    Container container=containersBeingReleased.remove(containerId);
    RoleStatus roleStatus=lookupRoleStatus(container);
    log.info("String_Node_Str",roleStatus.getName());
    roleStatus.decReleasing();
    roleStatus.decActual();
    roleStatus.incCompleted();
    roleHistory.onReleaseCompleted(container);
  }
 else   if (surplusNodes.remove(containerId)) {
    result.surplusNode=true;
  }
 else {
    result.containerFailed=true;
    roleInstance=activeContainers.remove(containerId);
    if (roleInstance != null) {
      incFailedCountainerCount();
      failedNodes.put(containerId,roleInstance);
    }
 else {
      roleInstance=failedNodes.get(containerId);
    }
    if (roleInstance != null) {
      int roleId=roleInstance.roleId;
      log.info("String_Node_Str",roleId);
      try {
        RoleStatus roleStatus=lookupRoleStatus(roleId);
        roleStatus.decActual();
        boolean shortLived=isShortLived(roleInstance);
        String message;
        if (roleInstance.container != null) {
          message=String.format("String_Node_Str",roleInstance.getContainerId(),roleInstance.container.getNodeId().getHost());
        }
 else {
          message=String.format("String_Node_Str",containerId.toString());
        }
        roleStatus.noteFailed(message);
        if (shortLived) {
          roleStatus.incStartFailed();
        }
        if (roleInstance.container != null) {
          roleHistory.onFailedContainer(roleInstance.container,shortLived);
        }
      }
 catch (      YarnRuntimeException e1) {
        log.error("String_Node_Str",roleId);
      }
    }
 else {
      log.error("String_Node_Str" + "String_Node_Str");
      completionOfUnknownContainerEvent.incrementAndGet();
    }
  }
  if (result.surplusNode) {
    return result;
  }
  ContainerId id=status.getContainerId();
  RoleInstance node=getLiveNodes().remove(id);
  if (node == null) {
    log.warn("String_Node_Str");
    completionOfNodeNotInLiveListEvent.incrementAndGet();
  }
 else {
    node.state=ClusterDescription.STATE_DESTROYED;
    node.exitCode=status.getExitStatus();
    node.diagnostics=status.getDiagnostics();
    getCompletedNodes().put(id,node);
    result.roleInstance=node;
  }
  return result;
}