Program: 106659
Project: 106659
Buggy source:
private String queueCommand(BaseCmd cmdObj,Map<String,String> params){
  UserContext ctx=UserContext.current();
  Long callerUserId=ctx.getCallerUserId();
  Account caller=ctx.getCaller();
  if (cmdObj instanceof BaseAsyncCmd) {
    Long objectId=null;
    String objectEntityTable=null;
    if (cmdObj instanceof BaseAsyncCreateCmd) {
      BaseAsyncCreateCmd createCmd=(BaseAsyncCreateCmd)cmdObj;
      _dispatcher.dispatchCreateCmd(createCmd,params);
      objectId=createCmd.getEntityId();
      objectEntityTable=createCmd.getEntityTable();
      params.put("String_Node_Str",objectId.toString());
    }
 else {
      ApiDispatcher.setupParameters(cmdObj,params);
    }
    BaseAsyncCmd asyncCmd=(BaseAsyncCmd)cmdObj;
    if (callerUserId != null) {
      params.put("String_Node_Str",callerUserId.toString());
    }
    if (caller != null) {
      params.put("String_Node_Str",String.valueOf(caller.getId()));
    }
    long startEventId=ctx.getStartEventId();
    asyncCmd.setStartEventId(startEventId);
    Long eventId=EventUtils.saveScheduledEvent((callerUserId == null) ? User.UID_SYSTEM : callerUserId,asyncCmd.getEntityOwnerId(),asyncCmd.getEventType(),asyncCmd.getEventDescription(),startEventId);
    if (startEventId == 0) {
      startEventId=eventId;
    }
    params.put("String_Node_Str",String.valueOf(startEventId));
    ctx.setAccountId(asyncCmd.getEntityOwnerId());
    AsyncJobVO job=new AsyncJobVO();
    job.setInstanceId((objectId == null) ? asyncCmd.getInstanceId() : objectId);
    job.setInstanceType(asyncCmd.getInstanceType());
    job.setUserId(callerUserId);
    job.setAccountId(caller.getId());
    job.setCmd(cmdObj.getClass().getName());
    job.setCmdInfo(ApiGsonHelper.getBuilder().create().toJson(params));
    long jobId=_asyncMgr.submitAsyncJob(job);
    if (jobId == 0L) {
      String errorMsg="String_Node_Str" + job.getCmd();
      s_logger.warn(errorMsg);
      throw new ServerApiException(BaseCmd.INTERNAL_ERROR,errorMsg);
    }
    if (objectId != null) {
      return ((BaseAsyncCreateCmd)asyncCmd).getResponse(jobId,objectId,objectEntityTable);
    }
    SerializationContext.current().setUuidTranslation(true);
    return ApiResponseSerializer.toSerializedString(asyncCmd.getResponse(jobId),asyncCmd.getResponseType());
  }
 else {
    _dispatcher.dispatch(cmdObj,params);
    if (cmdObj instanceof BaseListCmd) {
      buildAsyncListResponse((BaseListCmd)cmdObj,caller);
    }
    SerializationContext.current().setUuidTranslation(true);
    return ApiResponseSerializer.toSerializedString((ResponseObject)cmdObj.getResponseObject(),cmdObj.getResponseType());
  }
}

Fixed version (ground truth):
private String queueCommand(BaseCmd cmdObj,Map<String,String> params){
  UserContext ctx=UserContext.current();
  Long callerUserId=ctx.getCallerUserId();
  Account caller=ctx.getCaller();
  if (cmdObj instanceof BaseAsyncCmd) {
    Long objectId=null;
    String objectEntityTable=null;
    if (cmdObj instanceof BaseAsyncCreateCmd) {
      BaseAsyncCreateCmd createCmd=(BaseAsyncCreateCmd)cmdObj;
      _dispatcher.dispatchCreateCmd(createCmd,params);
      objectId=createCmd.getEntityId();
      objectEntityTable=createCmd.getEntityTable();
      params.put("String_Node_Str",objectId.toString());
    }
 else {
      ApiDispatcher.setupParameters(cmdObj,params);
    }
    BaseAsyncCmd asyncCmd=(BaseAsyncCmd)cmdObj;
    if (callerUserId != null) {
      params.put("String_Node_Str",callerUserId.toString());
    }
    if (caller != null) {
      params.put("String_Node_Str",String.valueOf(caller.getId()));
    }
    long startEventId=ctx.getStartEventId();
    asyncCmd.setStartEventId(startEventId);
    Long eventId=EventUtils.saveScheduledEvent((callerUserId == null) ? User.UID_SYSTEM : callerUserId,asyncCmd.getEntityOwnerId(),asyncCmd.getEventType(),asyncCmd.getEventDescription(),startEventId);
    if (startEventId == 0) {
      startEventId=eventId;
    }
    params.put("String_Node_Str",String.valueOf(startEventId));
    ctx.setAccountId(asyncCmd.getEntityOwnerId());
    AsyncJobVO job=new AsyncJobVO();
    job.setInstanceId((objectId == null) ? asyncCmd.getInstanceId() : objectId);
    job.setInstanceType(asyncCmd.getInstanceType());
    job.setUserId(callerUserId);
    job.setAccountId(caller.getId());
    job.setCmd(cmdObj.getClass().getName());
    job.setCmdInfo(ApiGsonHelper.getBuilder().create().toJson(params));
    long jobId=_asyncMgr.submitAsyncJob(job);
    if (jobId == 0L) {
      String errorMsg="String_Node_Str" + job.getCmd();
      s_logger.warn(errorMsg);
      throw new ServerApiException(BaseCmd.INTERNAL_ERROR,errorMsg);
    }
    if (objectId != null) {
      SerializationContext.current().setUuidTranslation(true);
      return ((BaseAsyncCreateCmd)asyncCmd).getResponse(jobId,objectId,objectEntityTable);
    }
    SerializationContext.current().setUuidTranslation(true);
    return ApiResponseSerializer.toSerializedString(asyncCmd.getResponse(jobId),asyncCmd.getResponseType());
  }
 else {
    _dispatcher.dispatch(cmdObj,params);
    if (cmdObj instanceof BaseListCmd) {
      buildAsyncListResponse((BaseListCmd)cmdObj,caller);
    }
    SerializationContext.current().setUuidTranslation(true);
    return ApiResponseSerializer.toSerializedString((ResponseObject)cmdObj.getResponseObject(),cmdObj.getResponseType());
  }
}