Program: 6336
Project: 6336
Buggy source:
/** 
 * Returns the program status.
 * @param id the id of the program for which the status call is made
 * @return the status of the program
 * @throws BadRequestException if the program type is invalid
 * @throws NotFoundException if the application to which this program belongs was not found
 */
private ProgramStatus getProgramStatus(Id.Program id) throws BadRequestException, NotFoundException {
  if (id.getType() == null) {
    throw new BadRequestException(String.format("String_Node_Str",id.getId()));
  }
  ApplicationSpecification appSpec=store.getApplication(id.getApplication());
  if (appSpec == null) {
    throw new NotFoundException(Id.Application.from(id.getNamespaceId(),id.getApplicationId()));
  }
  ProgramRuntimeService.RuntimeInfo runtimeInfo=findRuntimeInfo(id,null);
  if (runtimeInfo == null) {
    if (id.getType() != ProgramType.WEBAPP) {
      ProgramSpecification spec=getProgramSpecification(id);
      if (spec == null) {
        throw new NotFoundException(id);
      }
      if (id.getType() == ProgramType.MAPREDUCE && !store.getRuns(id,ProgramRunStatus.RUNNING,0,Long.MAX_VALUE,1).isEmpty()) {
        return ProgramStatus.RUNNING;
      }
      return ProgramStatus.STOPPED;
    }
    try {
      Location webappLoc=Programs.programLocation(namespacedLocationFactory,appFabricDir,id);
      if (webappLoc != null && webappLoc.exists()) {
        return ProgramStatus.STOPPED;
      }
      throw new NotFoundException(id);
    }
 catch (    IOException ioe) {
      throw new NotFoundException(id,ioe);
    }
  }
  return runtimeInfo.getController().getState().getProgramStatus();
}

Fixed version (ground truth):
/** 
 * Returns the program status.
 * @param id the id of the program for which the status call is made
 * @return the status of the program
 * @throws BadRequestException if the program type is invalid
 * @throws NotFoundException if the application to which this program belongs was not found
 */
private ProgramStatus getProgramStatus(Id.Program id) throws BadRequestException, NotFoundException {
  if (id.getType() == null) {
    throw new BadRequestException(String.format("String_Node_Str",id.getId()));
  }
  ApplicationSpecification appSpec=store.getApplication(id.getApplication());
  if (appSpec == null) {
    throw new NotFoundException(Id.Application.from(id.getNamespaceId(),id.getApplicationId()));
  }
  ProgramRuntimeService.RuntimeInfo runtimeInfo=findRuntimeInfo(id,(String)null);
  if (runtimeInfo == null) {
    if (id.getType() != ProgramType.WEBAPP) {
      ProgramSpecification spec=getProgramSpecification(id);
      if (spec == null) {
        throw new NotFoundException(id);
      }
      if (id.getType() == ProgramType.MAPREDUCE && !store.getRuns(id,ProgramRunStatus.RUNNING,0,Long.MAX_VALUE,1).isEmpty()) {
        return ProgramStatus.RUNNING;
      }
      return ProgramStatus.STOPPED;
    }
    try {
      Location webappLoc=Programs.programLocation(namespacedLocationFactory,appFabricDir,id);
      if (webappLoc != null && webappLoc.exists()) {
        return ProgramStatus.STOPPED;
      }
      throw new NotFoundException(id);
    }
 catch (    IOException ioe) {
      throw new NotFoundException(id,ioe);
    }
  }
  return runtimeInfo.getController().getState().getProgramStatus();
}