Program: 105089
Project: 105089
Buggy source:
@DB public boolean releasePublicIpRange(final long vlanDbId,final long userId,final Account caller){
  VlanVO vlan=_vlanDao.findById(vlanDbId);
  boolean isAccountSpecific=false;
  final List<AccountVlanMapVO> acctVln=_accountVlanMapDao.listAccountVlanMapsByVlan(vlanDbId);
  if (acctVln != null && !acctVln.isEmpty()) {
    isAccountSpecific=true;
  }
  boolean isDomainSpecific=false;
  final List<DomainVlanMapVO> domainVln=_domainVlanMapDao.listDomainVlanMapsByVlan(vlanDbId);
  if (domainVln != null && !domainVln.isEmpty()) {
    isDomainSpecific=true;
  }
  if (!isAccountSpecific && !isDomainSpecific) {
    throw new InvalidParameterValueException("String_Node_Str" + vlanDbId + "String_Node_Str");
  }
  final long allocIpCount=_publicIpAddressDao.countIPs(vlan.getDataCenterId(),vlanDbId,true);
  final List<IPAddressVO> ips=_publicIpAddressDao.listByVlanId(vlanDbId);
  boolean success=true;
  final List<IPAddressVO> ipsInUse=new ArrayList<IPAddressVO>();
  if (allocIpCount > 0) {
    try {
      vlan=_vlanDao.acquireInLockTable(vlanDbId,30);
      if (vlan == null) {
        throw new CloudRuntimeException("String_Node_Str" + vlanDbId);
      }
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + vlanDbId + "String_Node_Str");
      }
      for (      final IPAddressVO ip : ips) {
        if (!ip.isOneToOneNat() && !ip.isSourceNat() && !(_firewallDao.countRulesByIpId(ip.getId()) > 0)) {
          if (s_logger.isDebugEnabled()) {
            s_logger.debug("String_Node_Str" + ip + "String_Node_Str"+ vlanDbId+ "String_Node_Str"+ "String_Node_Str");
          }
          success=success && _ipAddrMgr.disassociatePublicIpAddress(ip.getId(),userId,caller);
        }
 else {
          ipsInUse.add(ip);
        }
      }
      if (!success) {
        s_logger.warn("String_Node_Str" + "String_Node_Str" + vlanDbId + "String_Node_Str");
      }
    }
  finally {
      _vlanDao.releaseFromLockTable(vlanDbId);
    }
  }
  if (isAccountSpecific && _accountVlanMapDao.remove(acctVln.get(0).getId())) {
    for (    final IPAddressVO ip : ips) {
      if (!ipsInUse.contains(ip)) {
        UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_RELEASE,acctVln.get(0).getAccountId(),ip.getDataCenterId(),ip.getId(),ip.getAddress().toString(),ip.isSourceNat(),vlan.getVlanType().toString(),ip.getSystem(),ip.getClass().getName(),ip.getUuid());
      }
    }
    _resourceLimitMgr.decrementResourceCount(acctVln.get(0).getAccountId(),ResourceType.public_ip,new Long(ips.size()));
    return true;
  }
 else   if (isDomainSpecific && _domainVlanMapDao.remove(domainVln.get(0).getId())) {
    s_logger.debug("String_Node_Str");
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@DB public boolean releasePublicIpRange(final long vlanDbId,final long userId,final Account caller){
  VlanVO vlan=_vlanDao.findById(vlanDbId);
  if (vlan == null) {
    s_logger.warn("String_Node_Str" + caller + "String_Node_Str"+ userId+ "String_Node_Str"+ vlanDbId+ "String_Node_Str");
  }
  boolean isAccountSpecific=false;
  final List<AccountVlanMapVO> acctVln=_accountVlanMapDao.listAccountVlanMapsByVlan(vlanDbId);
  if (acctVln != null && !acctVln.isEmpty()) {
    isAccountSpecific=true;
  }
  boolean isDomainSpecific=false;
  final List<DomainVlanMapVO> domainVln=_domainVlanMapDao.listDomainVlanMapsByVlan(vlanDbId);
  if (domainVln != null && !domainVln.isEmpty()) {
    isDomainSpecific=true;
  }
  if (!isAccountSpecific && !isDomainSpecific) {
    throw new InvalidParameterValueException("String_Node_Str" + vlanDbId + "String_Node_Str");
  }
  final long allocIpCount=_publicIpAddressDao.countIPs(vlan.getDataCenterId(),vlanDbId,true);
  final List<IPAddressVO> ips=_publicIpAddressDao.listByVlanId(vlanDbId);
  boolean success=true;
  final List<IPAddressVO> ipsInUse=new ArrayList<IPAddressVO>();
  if (allocIpCount > 0) {
    try {
      vlan=_vlanDao.acquireInLockTable(vlanDbId,30);
      if (vlan == null) {
        throw new CloudRuntimeException("String_Node_Str" + vlanDbId);
      }
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + vlanDbId + "String_Node_Str");
      }
      for (      final IPAddressVO ip : ips) {
        if (!ip.isOneToOneNat() && !ip.isSourceNat() && !(_firewallDao.countRulesByIpId(ip.getId()) > 0)) {
          if (s_logger.isDebugEnabled()) {
            s_logger.debug("String_Node_Str" + ip + "String_Node_Str"+ vlanDbId+ "String_Node_Str"+ "String_Node_Str");
          }
          success=success && _ipAddrMgr.disassociatePublicIpAddress(ip.getId(),userId,caller);
        }
 else {
          ipsInUse.add(ip);
        }
      }
      if (!success) {
        s_logger.warn("String_Node_Str" + "String_Node_Str" + vlanDbId + "String_Node_Str");
      }
    }
  finally {
      _vlanDao.releaseFromLockTable(vlanDbId);
    }
  }
  if (isAccountSpecific && _accountVlanMapDao.remove(acctVln.get(0).getId())) {
    for (    final IPAddressVO ip : ips) {
      if (!ipsInUse.contains(ip)) {
        UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_RELEASE,acctVln.get(0).getAccountId(),ip.getDataCenterId(),ip.getId(),ip.getAddress().toString(),ip.isSourceNat(),vlan.getVlanType().toString(),ip.getSystem(),ip.getClass().getName(),ip.getUuid());
      }
    }
    _resourceLimitMgr.decrementResourceCount(acctVln.get(0).getAccountId(),ResourceType.public_ip,new Long(ips.size()));
    return true;
  }
 else   if (isDomainSpecific && _domainVlanMapDao.remove(domainVln.get(0).getId())) {
    s_logger.debug("String_Node_Str");
    return true;
  }
 else {
    return false;
  }
}