Program: 6337
Project: 6337
Buggy source:
/** 
 * Increases number of instance for a flowlet within a flow.
 */
@PUT @Path("String_Node_Str") public synchronized void setFlowletInstances(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String appId,@PathParam("String_Node_Str") String flowId,@PathParam("String_Node_Str") String flowletId) throws ExecutionException, InterruptedException {
  int instances;
  try {
    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;
    }
  }
 catch (  Throwable th) {
    responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
    return;
  }
  try {
    Id.Program programId=Id.Program.from(namespaceId,appId,ProgramType.FLOW,flowId);
    int oldInstances=store.getFlowletInstances(programId,flowletId);
    if (oldInstances != instances) {
      FlowSpecification flowSpec=store.setFlowletInstances(programId,flowletId,instances);
      ProgramRuntimeService.RuntimeInfo runtimeInfo=findRuntimeInfo(namespaceId,appId,flowId,ProgramType.FLOW,runtimeService);
      if (runtimeInfo != null) {
        runtimeInfo.getController().command(ProgramOptionConstants.INSTANCES,ImmutableMap.of("String_Node_Str",flowletId,"String_Node_Str",String.valueOf(instances),"String_Node_Str",GSON.toJson(flowSpec,FlowSpecification.class))).get();
      }
    }
    responder.sendStatus(HttpResponseStatus.OK);
  }
 catch (  SecurityException e) {
    responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
  }
catch (  Throwable e) {
    if (respondIfElementNotFound(e,responder)) {
      return;
    }
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * Increases number of instance for a flowlet within a flow.
 */
@PUT @Path("String_Node_Str") public synchronized void setFlowletInstances(HttpRequest request,HttpResponder responder,@PathParam("String_Node_Str") String namespaceId,@PathParam("String_Node_Str") String appId,@PathParam("String_Node_Str") String flowId,@PathParam("String_Node_Str") String flowletId) throws ExecutionException, InterruptedException {
  int instances;
  try {
    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;
    }
  }
 catch (  Throwable th) {
    responder.sendString(HttpResponseStatus.BAD_REQUEST,"String_Node_Str");
    return;
  }
  try {
    Id.Program programId=Id.Program.from(namespaceId,appId,ProgramType.FLOW,flowId);
    int oldInstances=store.getFlowletInstances(programId,flowletId);
    if (oldInstances != instances) {
      FlowSpecification flowSpec=store.setFlowletInstances(programId,flowletId,instances);
      ProgramRuntimeService.RuntimeInfo runtimeInfo=findRuntimeInfo(programId,runtimeService);
      if (runtimeInfo != null) {
        runtimeInfo.getController().command(ProgramOptionConstants.INSTANCES,ImmutableMap.of("String_Node_Str",flowletId,"String_Node_Str",String.valueOf(instances),"String_Node_Str",GSON.toJson(flowSpec,FlowSpecification.class))).get();
      }
    }
    responder.sendStatus(HttpResponseStatus.OK);
  }
 catch (  SecurityException e) {
    responder.sendStatus(HttpResponseStatus.UNAUTHORIZED);
  }
catch (  Throwable e) {
    if (respondIfElementNotFound(e,responder)) {
      return;
    }
    throw e;
  }
}