Program: 106061
Project: 106061
Buggy source:
public Outcome<VirtualMachine> removeNicFromVmThroughJobQueue(final VirtualMachine vm,final Nic nic){
  final CallContext context=CallContext.current();
  final User user=context.getCallingUser();
  final Account account=context.getCallingAccount();
  Object[] result=Transaction.execute(new TransactionCallback<Object[]>(){
    @Override public Object[] doInTransaction(    TransactionStatus status){
      List<VmWorkJobVO> pendingWorkJobs=_workJobDao.listPendingWorkJobs(VirtualMachine.Type.Instance,vm.getId(),VmWorkRemoveNicFromVm.class.getName());
      VmWorkJobVO workJob=null;
      if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) {
        assert(pendingWorkJobs.size() == 1);
        workJob=pendingWorkJobs.get(0);
      }
 else {
        workJob=new VmWorkJobVO(context.getContextId());
        workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
        workJob.setCmd(VmWorkRemoveNicFromVm.class.getName());
        workJob.setAccountId(account.getId());
        workJob.setUserId(user.getId());
        workJob.setVmType(vm.getType());
        workJob.setVmInstanceId(vm.getId());
        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
        VmWorkRemoveNicFromVm workInfo=new VmWorkRemoveNicFromVm(user.getId(),account.getId(),vm.getId(),VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER,nic);
        workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
        _jobMgr.submitAsyncJob(workJob,VmWorkConstants.VM_WORK_QUEUE,vm.getId());
      }
      return new Object[]{workJob,new Long(workJob.getId())};
    }
  }
);
  final long jobId=(Long)result[1];
  AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
  return new VmJobVirtualMachineOutcome((VmWorkJobVO)result[0],vm.getId());
}

Fixed version (ground truth):
public Outcome<VirtualMachine> removeNicFromVmThroughJobQueue(final VirtualMachine vm,final Nic nic){
  final CallContext context=CallContext.current();
  final User user=context.getCallingUser();
  final Account account=context.getCallingAccount();
  Object[] result=Transaction.execute(new TransactionCallback<Object[]>(){
    @Override public Object[] doInTransaction(    TransactionStatus status){
      List<VmWorkJobVO> pendingWorkJobs=_workJobDao.listPendingWorkJobs(VirtualMachine.Type.Instance,vm.getId(),VmWorkRemoveNicFromVm.class.getName());
      VmWorkJobVO workJob=null;
      if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) {
        assert(pendingWorkJobs.size() == 1);
        workJob=pendingWorkJobs.get(0);
      }
 else {
        workJob=new VmWorkJobVO(context.getContextId());
        workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
        workJob.setCmd(VmWorkRemoveNicFromVm.class.getName());
        workJob.setAccountId(account.getId());
        workJob.setUserId(user.getId());
        workJob.setVmType(vm.getType());
        workJob.setVmInstanceId(vm.getId());
        workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId());
        VmWorkRemoveNicFromVm workInfo=new VmWorkRemoveNicFromVm(user.getId(),account.getId(),vm.getId(),VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER,nic.getId());
        workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo));
        _jobMgr.submitAsyncJob(workJob,VmWorkConstants.VM_WORK_QUEUE,vm.getId());
      }
      return new Object[]{workJob,new Long(workJob.getId())};
    }
  }
);
  final long jobId=(Long)result[1];
  AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId);
  return new VmJobVirtualMachineOutcome((VmWorkJobVO)result[0],vm.getId());
}