Program: 107192
Project: 107192
Buggy source:
@Override public boolean cleanupAccount(AccountVO account,long callerUserId,Account caller) throws ConcurrentOperationException, ResourceUnavailableException {
  long accountId=account.getId();
  boolean accountCleanupNeeded=false;
  try {
    List<InstanceGroupVO> groups=_vmGroupDao.listByAccountId(accountId);
    for (    InstanceGroupVO group : groups) {
      if (!_vmMgr.deleteVmGroup(group.getId())) {
        s_logger.error("String_Node_Str" + group.getId());
        accountCleanupNeeded=true;
      }
    }
    boolean success=_snapMgr.deleteSnapshotDirsForAccount(accountId);
    if (success) {
      s_logger.debug("String_Node_Str" + accountId + "String_Node_Str");
    }
    List<VMTemplateVO> userTemplates=_templateDao.listByAccountId(accountId);
    boolean allTemplatesDeleted=true;
    for (    VMTemplateVO template : userTemplates) {
      try {
        allTemplatesDeleted=_tmpltMgr.delete(callerUserId,template.getId(),null);
      }
 catch (      Exception e) {
        s_logger.warn("String_Node_Str" + template.getName() + "String_Node_Str"+ e.getMessage());
        allTemplatesDeleted=false;
      }
    }
    if (!allTemplatesDeleted) {
      accountCleanupNeeded=true;
    }
    List<UserVmVO> vms=_userVmDao.listByAccountId(accountId);
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + accountId + "String_Node_Str"+ vms.size());
    }
    for (    UserVmVO vm : vms) {
      if (!_vmMgr.expunge(vm,callerUserId,caller)) {
        s_logger.error("String_Node_Str" + vm.getId());
        accountCleanupNeeded=true;
      }
    }
    List<VolumeVO> volumes=_volumeDao.findDetachedByAccount(accountId);
    for (    VolumeVO volume : volumes) {
      if (!volume.getState().equals(Volume.State.Destroy))       _storageMgr.destroyVolume(volume);
    }
    int numRemoved=_securityGroupDao.removeByAccountId(accountId);
    s_logger.info("String_Node_Str" + numRemoved + "String_Node_Str"+ accountId);
    boolean networksDeleted=true;
    s_logger.debug("String_Node_Str" + account.getId());
    List<NetworkVO> networks=_networkDao.listByOwner(accountId);
    if (networks != null) {
      for (      NetworkVO network : networks) {
        if (!_networkMgr.deleteNetwork(network.getId())) {
          s_logger.warn("String_Node_Str" + network + "String_Node_Str"+ accountId+ "String_Node_Str");
          accountCleanupNeeded=true;
          networksDeleted=false;
        }
 else {
          s_logger.debug("String_Node_Str" + network.getId() + "String_Node_Str"+ accountId+ "String_Node_Str");
        }
      }
    }
    if (networksDeleted) {
      if (!_configMgr.deleteAccountSpecificVirtualRanges(accountId)) {
        accountCleanupNeeded=true;
      }
 else {
        s_logger.debug("String_Node_Str" + "String_Node_Str" + accountId + "String_Node_Str");
      }
    }
    return true;
  }
  finally {
    s_logger.info("String_Node_Str" + account.getId() + (accountCleanupNeeded ? "String_Node_Str" : "String_Node_Str"));
    if (accountCleanupNeeded) {
      _accountDao.markForCleanup(accountId);
    }
  }
}

Fixed version (ground truth):
@Override public boolean cleanupAccount(AccountVO account,long callerUserId,Account caller) throws ConcurrentOperationException, ResourceUnavailableException {
  long accountId=account.getId();
  boolean accountCleanupNeeded=false;
  try {
    List<InstanceGroupVO> groups=_vmGroupDao.listByAccountId(accountId);
    for (    InstanceGroupVO group : groups) {
      if (!_vmMgr.deleteVmGroup(group.getId())) {
        s_logger.error("String_Node_Str" + group.getId());
        accountCleanupNeeded=true;
      }
    }
    boolean success=_snapMgr.deleteSnapshotDirsForAccount(accountId);
    if (success) {
      s_logger.debug("String_Node_Str" + accountId + "String_Node_Str");
    }
    List<VMTemplateVO> userTemplates=_templateDao.listByAccountId(accountId);
    boolean allTemplatesDeleted=true;
    for (    VMTemplateVO template : userTemplates) {
      try {
        allTemplatesDeleted=_tmpltMgr.delete(callerUserId,template.getId(),null);
      }
 catch (      Exception e) {
        s_logger.warn("String_Node_Str" + template.getName() + "String_Node_Str"+ e.getMessage());
        allTemplatesDeleted=false;
      }
    }
    if (!allTemplatesDeleted) {
      s_logger.warn("String_Node_Str" + accountId);
      accountCleanupNeeded=true;
    }
    List<UserVmVO> vms=_userVmDao.listByAccountId(accountId);
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + accountId + "String_Node_Str"+ vms.size());
    }
    for (    UserVmVO vm : vms) {
      if (!_vmMgr.expunge(vm,callerUserId,caller)) {
        s_logger.error("String_Node_Str" + vm.getId());
        accountCleanupNeeded=true;
      }
    }
    List<VolumeVO> volumes=_volumeDao.findDetachedByAccount(accountId);
    for (    VolumeVO volume : volumes) {
      if (!volume.getState().equals(Volume.State.Destroy))       _storageMgr.destroyVolume(volume);
    }
    int numRemoved=_securityGroupDao.removeByAccountId(accountId);
    s_logger.info("String_Node_Str" + numRemoved + "String_Node_Str"+ accountId);
    boolean networksDeleted=true;
    s_logger.debug("String_Node_Str" + account.getId());
    List<NetworkVO> networks=_networkDao.listByOwner(accountId);
    if (networks != null) {
      for (      NetworkVO network : networks) {
        if (!_networkMgr.deleteNetwork(network.getId())) {
          s_logger.warn("String_Node_Str" + network + "String_Node_Str"+ accountId+ "String_Node_Str");
          accountCleanupNeeded=true;
          networksDeleted=false;
        }
 else {
          s_logger.debug("String_Node_Str" + network.getId() + "String_Node_Str"+ accountId+ "String_Node_Str");
        }
      }
    }
    if (networksDeleted) {
      if (!_configMgr.deleteAccountSpecificVirtualRanges(accountId)) {
        accountCleanupNeeded=true;
      }
 else {
        s_logger.debug("String_Node_Str" + "String_Node_Str" + accountId + "String_Node_Str");
      }
    }
    return true;
  }
  finally {
    s_logger.info("String_Node_Str" + account.getId() + (accountCleanupNeeded ? "String_Node_Str" : "String_Node_Str"));
    if (accountCleanupNeeded) {
      _accountDao.markForCleanup(accountId);
    }
  }
}