Program: 6396
Project: 6396
Buggy source:
/** 
 * Returns the status for all programs that are passed into the data. The data is an array of JSON objects where each object must contain the following three elements: appId, programType, and programId (flow name, service name, etc.). <p> Example input: <pre><code> [{"appId": "App1", "programType": "Service", "programId": "Service1"}, {"appId": "App1", "programType": "Mapreduce", "programId": "MapReduce2"}, {"appId": "App2", "programType": "Flow", "programId": "Flow1"}] </code></pre> </p><p> The response will be an array of JsonObjects each of which will contain the three input parameters as well as 2 fields, "status" which maps to the status of the program and "statusCode" which maps to the status code for the data in that JsonObjects. </p><p> If an error occurs in the input (for the example above, App2 does not exist), then all JsonObjects for which the parameters have a valid status will have the status field but all JsonObjects for which the parameters do not have a valid status will have an error message and statusCode. </p><p> For example, if there is no App2 in the data above, then the response would be 200 OK with following possible data: </p> <pre><code> [{"appId": "App1", "programType": "Service", "programId": "Service1", "statusCode": 200, "status": "RUNNING"}, {"appId": "App1", "programType": "Mapreduce", "programId": "Mapreduce2", "statusCode": 200, "status": "STOPPED"}, {"appId":"App2", "programType":"Flow", "programId":"Flow1", "statusCode":404, "error": "App: App2 not found"}] </code></pre>
 */
@POST @Path("String_Node_Str") public void getStatuses(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId) throws IOException, BadRequestException {
  List<BatchProgram> programs=validateAndGetBatchInput(request,BATCH_PROGRAMS_TYPE);
  List<BatchProgramStatus> statuses=new ArrayList<>(programs.size());
  for (  BatchProgram program : programs) {
    Id.Program progId=Id.Program.from(namespaceId,program.getAppId(),program.getProgramType(),program.getProgramId());
    try {
      StatusMap statusMap=getStatus(progId);
      statuses.add(new BatchProgramStatus(program,HttpResponseStatus.OK.getCode(),null,statusMap.getStatus()));
    }
 catch (    BadRequestException e) {
      statuses.add(new BatchProgramStatus(program,HttpResponseStatus.BAD_REQUEST.getCode(),e.getMessage(),null));
    }
catch (    NotFoundException e) {
      statuses.add(new BatchProgramStatus(program,HttpResponseStatus.NOT_FOUND.getCode(),e.getMessage(),null));
    }
  }
  responder.sendJson(HttpResponseStatus.OK,statuses);
}

Fixed version (ground truth):
/** 
 * Returns the status for all programs that are passed into the data. The data is an array of JSON objects where each object must contain the following three elements: appId, programType, and programId (flow name, service name, etc.). <p> Example input: <pre><code> [{"appId": "App1", "programType": "Service", "programId": "Service1"}, {"appId": "App1", "programType": "Mapreduce", "programId": "MapReduce2"}, {"appId": "App2", "programType": "Flow", "programId": "Flow1"}] </code></pre> </p><p> The response will be an array of JsonObjects each of which will contain the three input parameters as well as 2 fields, "status" which maps to the status of the program and "statusCode" which maps to the status code for the data in that JsonObjects. </p><p> If an error occurs in the input (for the example above, App2 does not exist), then all JsonObjects for which the parameters have a valid status will have the status field but all JsonObjects for which the parameters do not have a valid status will have an error message and statusCode. </p><p> For example, if there is no App2 in the data above, then the response would be 200 OK with following possible data: </p> <pre><code> [{"appId": "App1", "programType": "Service", "programId": "Service1", "statusCode": 200, "status": "RUNNING"}, {"appId": "App1", "programType": "Mapreduce", "programId": "Mapreduce2", "statusCode": 200, "status": "STOPPED"}, {"appId":"App2", "programType":"Flow", "programId":"Flow1", "statusCode":404, "error": "App: App2 not found"}] </code></pre>
 */
@POST @Path("String_Node_Str") public void getStatuses(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId) throws IOException, BadRequestException {
  List<BatchProgram> programs=validateAndGetBatchInput(request,BATCH_PROGRAMS_TYPE);
  List<BatchProgramStatus> statuses=new ArrayList<>(programs.size());
  for (  BatchProgram program : programs) {
    Id.Program progId=Id.Program.from(namespaceId,program.getAppId(),program.getProgramType(),program.getProgramId());
    try {
      ProgramStatus programStatus=getProgramStatus(progId);
      statuses.add(new BatchProgramStatus(program,HttpResponseStatus.OK.getCode(),null,programStatus.name()));
    }
 catch (    BadRequestException e) {
      statuses.add(new BatchProgramStatus(program,HttpResponseStatus.BAD_REQUEST.getCode(),e.getMessage(),null));
    }
catch (    NotFoundException e) {
      statuses.add(new BatchProgramStatus(program,HttpResponseStatus.NOT_FOUND.getCode(),e.getMessage(),null));
    }
  }
  responder.sendJson(HttpResponseStatus.OK,statuses);
}