Program: 105749
Project: 105749
Buggy source:
private String queueCommand(final BaseCmd cmdObj,final Map<String,String> params) throws Exception {
  final CallContext ctx=CallContext.current();
  final Long callerUserId=ctx.getCallingUserId();
  final Account caller=ctx.getCallingAccount();
  if (cmdObj instanceof BaseAsyncCmd) {
    Long objectId=null;
    String objectUuid=null;
    if (cmdObj instanceof BaseAsyncCreateCmd) {
      final BaseAsyncCreateCmd createCmd=(BaseAsyncCreateCmd)cmdObj;
      _dispatcher.dispatchCreateCmd(createCmd,params);
      objectId=createCmd.getEntityId();
      objectUuid=createCmd.getEntityUuid();
      params.put("String_Node_Str",objectId.toString());
      Class entityClass=EventTypes.getEntityClassForEvent(createCmd.getEventType());
      if (entityClass != null)       ctx.putContextParameter(entityClass.getName(),objectUuid);
    }
 else {
      objectUuid=params.get(ApiConstants.ID);
      dispatchChainFactory.getStandardDispatchChain().dispatch(new DispatchTask(cmdObj,params));
    }
    final 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()));
    }
    if (objectUuid != null) {
      params.put("String_Node_Str",objectUuid);
    }
    long startEventId=ctx.getStartEventId();
    asyncCmd.setStartEventId(startEventId);
    final Long eventId=ActionEventUtils.onScheduledActionEvent((callerUserId == null) ? User.UID_SYSTEM : callerUserId,asyncCmd.getEntityOwnerId(),asyncCmd.getEventType(),asyncCmd.getEventDescription(),asyncCmd.isDisplay(),startEventId);
    if (startEventId == 0) {
      startEventId=eventId;
    }
    params.put("String_Node_Str",String.valueOf(startEventId));
    params.put("String_Node_Str",asyncCmd.getEventType().toString());
    params.put("String_Node_Str",ApiGsonHelper.getBuilder().create().toJson(ctx.getContextParameters()));
    Long instanceId=(objectId == null) ? asyncCmd.getInstanceId() : objectId;
    String injectedJobId=asyncCmd.getInjectedJobId();
    _uuidMgr.checkUuidSimple(injectedJobId,AsyncJob.class);
    AsyncJobVO job=new AsyncJobVO("String_Node_Str",callerUserId,caller.getId(),cmdObj.getClass().getName(),ApiGsonHelper.getBuilder().create().toJson(params),instanceId,asyncCmd.getInstanceType() != null ? asyncCmd.getInstanceType().toString() : null,injectedJobId);
    job.setDispatcher(_asyncDispatcher.getName());
    final long jobId=_asyncMgr.submitAsyncJob(job);
    if (jobId == 0L) {
      final String errorMsg="String_Node_Str" + job.getCmd();
      s_logger.warn(errorMsg);
      throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,errorMsg);
    }
    if (objectId != null) {
      final String objUuid=(objectUuid == null) ? objectId.toString() : objectUuid;
      return getBaseAsyncCreateResponse(jobId,(BaseAsyncCreateCmd)asyncCmd,objUuid);
    }
 else {
      SerializationContext.current().setUuidTranslation(true);
      return getBaseAsyncResponse(jobId,asyncCmd);
    }
  }
 else {
    _dispatcher.dispatch(cmdObj,params,false);
    if (cmdObj instanceof BaseListCmd && !(cmdObj instanceof ListVMsCmd) && !(cmdObj instanceof ListVMsCmdByAdmin)&& !(cmdObj instanceof ListRoutersCmd)&& !(cmdObj instanceof ListSecurityGroupsCmd)&& !(cmdObj instanceof ListTagsCmd)&& !(cmdObj instanceof ListEventsCmd)&& !(cmdObj instanceof ListVMGroupsCmd)&& !(cmdObj instanceof ListProjectsCmd)&& !(cmdObj instanceof ListProjectAccountsCmd)&& !(cmdObj instanceof ListProjectInvitationsCmd)&& !(cmdObj instanceof ListHostsCmd)&& !(cmdObj instanceof ListVolumesCmd)&& !(cmdObj instanceof ListVolumesCmdByAdmin)&& !(cmdObj instanceof ListUsersCmd)&& !(cmdObj instanceof ListAccountsCmd)&& !(cmdObj instanceof ListAccountsCmdByAdmin)&& !(cmdObj instanceof ListStoragePoolsCmd)&& !(cmdObj instanceof ListDiskOfferingsCmd)&& !(cmdObj instanceof ListServiceOfferingsCmd)&& !(cmdObj instanceof ListZonesCmd)&& !(cmdObj instanceof ListZonesCmdByAdmin)) {
      buildAsyncListResponse((BaseListCmd)cmdObj,caller);
    }
    SerializationContext.current().setUuidTranslation(true);
    return ApiResponseSerializer.toSerializedString((ResponseObject)cmdObj.getResponseObject(),cmdObj.getResponseType());
  }
}

Fixed version (ground truth):
private String queueCommand(final BaseCmd cmdObj,final Map<String,String> params) throws Exception {
  final CallContext ctx=CallContext.current();
  final Long callerUserId=ctx.getCallingUserId();
  final Account caller=ctx.getCallingAccount();
  if (cmdObj instanceof BaseAsyncCmd) {
    Long objectId=null;
    String objectUuid=null;
    if (cmdObj instanceof BaseAsyncCreateCmd) {
      final BaseAsyncCreateCmd createCmd=(BaseAsyncCreateCmd)cmdObj;
      _dispatcher.dispatchCreateCmd(createCmd,params);
      objectId=createCmd.getEntityId();
      objectUuid=createCmd.getEntityUuid();
      params.put("String_Node_Str",objectId.toString());
      Class entityClass=EventTypes.getEntityClassForEvent(createCmd.getEventType());
      if (entityClass != null)       ctx.putContextParameter(entityClass.getName(),objectUuid);
    }
 else {
      objectUuid=params.get(ApiConstants.ID);
      dispatchChainFactory.getStandardDispatchChain().dispatch(new DispatchTask(cmdObj,params));
    }
    final 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()));
    }
    if (objectUuid != null) {
      params.put("String_Node_Str",objectUuid);
    }
    long startEventId=ctx.getStartEventId();
    asyncCmd.setStartEventId(startEventId);
    final Long eventId=ActionEventUtils.onScheduledActionEvent((callerUserId == null) ? (Long)User.UID_SYSTEM : callerUserId,asyncCmd.getEntityOwnerId(),asyncCmd.getEventType(),asyncCmd.getEventDescription(),asyncCmd.isDisplay(),startEventId);
    if (startEventId == 0) {
      startEventId=eventId;
    }
    params.put("String_Node_Str",String.valueOf(startEventId));
    params.put("String_Node_Str",asyncCmd.getEventType().toString());
    params.put("String_Node_Str",ApiGsonHelper.getBuilder().create().toJson(ctx.getContextParameters()));
    Long instanceId=(objectId == null) ? asyncCmd.getInstanceId() : objectId;
    String injectedJobId=asyncCmd.getInjectedJobId();
    _uuidMgr.checkUuidSimple(injectedJobId,AsyncJob.class);
    AsyncJobVO job=new AsyncJobVO("String_Node_Str",callerUserId,caller.getId(),cmdObj.getClass().getName(),ApiGsonHelper.getBuilder().create().toJson(params),instanceId,asyncCmd.getInstanceType() != null ? asyncCmd.getInstanceType().toString() : null,injectedJobId);
    job.setDispatcher(_asyncDispatcher.getName());
    final long jobId=_asyncMgr.submitAsyncJob(job);
    if (jobId == 0L) {
      final String errorMsg="String_Node_Str" + job.getCmd();
      s_logger.warn(errorMsg);
      throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,errorMsg);
    }
    if (objectId != null) {
      final String objUuid=(objectUuid == null) ? objectId.toString() : objectUuid;
      return getBaseAsyncCreateResponse(jobId,(BaseAsyncCreateCmd)asyncCmd,objUuid);
    }
 else {
      SerializationContext.current().setUuidTranslation(true);
      return getBaseAsyncResponse(jobId,asyncCmd);
    }
  }
 else {
    _dispatcher.dispatch(cmdObj,params,false);
    if (cmdObj instanceof BaseListCmd && !(cmdObj instanceof ListVMsCmd) && !(cmdObj instanceof ListVMsCmdByAdmin)&& !(cmdObj instanceof ListRoutersCmd)&& !(cmdObj instanceof ListSecurityGroupsCmd)&& !(cmdObj instanceof ListTagsCmd)&& !(cmdObj instanceof ListEventsCmd)&& !(cmdObj instanceof ListVMGroupsCmd)&& !(cmdObj instanceof ListProjectsCmd)&& !(cmdObj instanceof ListProjectAccountsCmd)&& !(cmdObj instanceof ListProjectInvitationsCmd)&& !(cmdObj instanceof ListHostsCmd)&& !(cmdObj instanceof ListVolumesCmd)&& !(cmdObj instanceof ListVolumesCmdByAdmin)&& !(cmdObj instanceof ListUsersCmd)&& !(cmdObj instanceof ListAccountsCmd)&& !(cmdObj instanceof ListAccountsCmdByAdmin)&& !(cmdObj instanceof ListStoragePoolsCmd)&& !(cmdObj instanceof ListDiskOfferingsCmd)&& !(cmdObj instanceof ListServiceOfferingsCmd)&& !(cmdObj instanceof ListZonesCmd)&& !(cmdObj instanceof ListZonesCmdByAdmin)) {
      buildAsyncListResponse((BaseListCmd)cmdObj,caller);
    }
    SerializationContext.current().setUuidTranslation(true);
    return ApiResponseSerializer.toSerializedString((ResponseObject)cmdObj.getResponseObject(),cmdObj.getResponseType());
  }
}