Program: 6334
Project: 6334
Buggy source:
/** 
 * Set instances of a service.
 */
@PUT @Path("String_Node_Str") public void setServiceInstances(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String appId,@PathParam("String_Node_Str") String serviceId) throws ExecutionException, InterruptedException {
  try {
    Id.Program programId=Id.Program.from(namespaceId,appId,ProgramType.SERVICE,serviceId);
    if (!store.programExists(programId)) {
      responder.sendString(HttpResponseStatus.NOT_FOUND,"String_Node_Str");
      return;
    }
    int instances;
    try {
      instances=getInstances(request);
    }
 catch (    IllegalArgumentException e) {
      responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
      return;
    }
catch (    JsonSyntaxException e) {
      responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
      return;
    }
    if (instances < 1) {
      responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
      return;
    }
    int oldInstances=store.getServiceInstances(programId);
    if (oldInstances != instances) {
      store.setServiceInstances(programId,instances);
      ProgramRuntimeService.RuntimeInfo runtimeInfo=findRuntimeInfo(namespaceId,appId,serviceId,ProgramType.SERVICE,runtimeService);
      if (runtimeInfo != null) {
        runtimeInfo.getController().command(ProgramOptionConstants.INSTANCES,ImmutableMap.of(serviceId,String.valueOf(instances))).get();
      }
    }
    responder.sendStatus(HttpResponseStatus.OK);
  }
 catch (  SecurityException e) {
    responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
  }
catch (  Throwable throwable) {
    if (respondIfElementNotFound(throwable,responder)) {
      return;
    }
    throw throwable;
  }
}

Fixed version (ground truth):
/** 
 * Set instances of a service.
 */
@PUT @Path("String_Node_Str") public void setServiceInstances(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String appId,@PathParam("String_Node_Str") String serviceId) throws ExecutionException, InterruptedException {
  try {
    Id.Program programId=Id.Program.from(namespaceId,appId,ProgramType.SERVICE,serviceId);
    if (!store.programExists(programId)) {
      responder.sendString(HttpResponseStatus.NOT_FOUND,"String_Node_Str");
      return;
    }
    int instances;
    try {
      instances=getInstances(request);
    }
 catch (    IllegalArgumentException e) {
      responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
      return;
    }
catch (    JsonSyntaxException e) {
      responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
      return;
    }
    if (instances < 1) {
      responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
      return;
    }
    int oldInstances=store.getServiceInstances(programId);
    if (oldInstances != instances) {
      store.setServiceInstances(programId,instances);
      ProgramRuntimeService.RuntimeInfo runtimeInfo=findRuntimeInfo(programId,runtimeService);
      if (runtimeInfo != null) {
        runtimeInfo.getController().command(ProgramOptionConstants.INSTANCES,ImmutableMap.of(serviceId,String.valueOf(instances))).get();
      }
    }
    responder.sendStatus(HttpResponseStatus.OK);
  }
 catch (  SecurityException e) {
    responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
  }
catch (  Throwable throwable) {
    if (respondIfElementNotFound(throwable,responder)) {
      return;
    }
    throw throwable;
  }
}