Program: 89779
Project: 89779
Buggy source:
@Override public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile,DeployDestination dest,ReservationContext context){
  DomainRouterVO router=profile.getVirtualMachine();
  NetworkVO network=_networkDao.findById(router.getNetworkId());
  String type=null;
  String dhcpRange=null;
  DataCenter dc=dest.getDataCenter();
  if (dc.getNetworkType() == NetworkType.Advanced) {
    String cidr=network.getCidr();
    if (cidr != null) {
      dhcpRange=NetUtils.getDhcpRange(cidr);
    }
  }
  if (router.getRole() == Role.DHCP_USERDATA) {
    type="String_Node_Str";
  }
 else {
    type="String_Node_Str";
  }
  StringBuilder buf=profile.getBootArgsBuilder();
  buf.append("String_Node_Str" + type);
  buf.append("String_Node_Str").append(profile.getHostName());
  NicProfile controlNic=null;
  for (  NicProfile nic : profile.getNics()) {
    int deviceId=nic.getDeviceId();
    buf.append("String_Node_Str").append(deviceId).append("String_Node_Str").append(nic.getIp4Address());
    buf.append("String_Node_Str").append(deviceId).append("String_Node_Str").append(nic.getNetmask());
    if (nic.isDefaultNic()) {
      buf.append("String_Node_Str").append(nic.getGateway());
      buf.append("String_Node_Str").append(nic.getDns1());
      if (nic.getDns2() != null) {
        buf.append("String_Node_Str").append(nic.getDns2());
      }
      if (dc.getNetworkType() == NetworkType.Basic) {
        long cidrSize=NetUtils.getCidrSize(nic.getNetmask());
        String cidr=NetUtils.getCidrSubNet(nic.getGateway(),cidrSize);
        if (cidr != null) {
          dhcpRange=NetUtils.getIpRangeStartIpFromCidr(cidr,cidrSize);
        }
      }
    }
    if (nic.getTrafficType() == TrafficType.Management) {
      buf.append("String_Node_Str").append(dest.getPod().getGateway());
    }
 else     if (nic.getTrafficType() == TrafficType.Control) {
      if (dest.getHost().getHypervisorType() == HypervisorType.VMware) {
        if (s_logger.isInfoEnabled()) {
          s_logger.info("String_Node_Str" + dest.getPod().getCidrAddress() + "String_Node_Str"+ dest.getPod().getCidrSize()+ "String_Node_Str"+ dest.getPod().getGateway()+ "String_Node_Str"+ _mgmt_host);
        }
        if (!NetUtils.sameSubnetCIDR(_mgmt_host,dest.getPod().getGateway(),dest.getPod().getCidrSize())) {
          if (s_logger.isInfoEnabled()) {
            s_logger.info("String_Node_Str");
          }
          buf.append("String_Node_Str").append(_mgmt_host);
          buf.append("String_Node_Str").append(dest.getPod().getGateway());
        }
 else {
          if (s_logger.isInfoEnabled()) {
            s_logger.info("String_Node_Str");
          }
        }
      }
      controlNic=nic;
    }
  }
  if (dhcpRange != null) {
    buf.append("String_Node_Str" + dhcpRange);
  }
  String domain=network.getNetworkDomain();
  if (domain != null) {
    buf.append("String_Node_Str" + domain);
  }
  if (!network.isDefault() && network.getGuestType() == GuestIpType.Direct) {
    buf.append("String_Node_Str");
  }
 else {
    buf.append("String_Node_Str");
  }
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + profile + "String_Node_Str"+ buf.toString());
  }
  if (controlNic == null) {
    throw new CloudRuntimeException("String_Node_Str");
  }
  profile.setParameter(VirtualMachineProfile.Param.ControlNic,controlNic);
  return true;
}

Fixed version (ground truth):
@Override public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO> profile,DeployDestination dest,ReservationContext context){
  DomainRouterVO router=profile.getVirtualMachine();
  NetworkVO network=_networkDao.findById(router.getNetworkId());
  String type=null;
  String dhcpRange=null;
  DataCenter dc=dest.getDataCenter();
  if (dc.getNetworkType() == NetworkType.Advanced) {
    String cidr=network.getCidr();
    if (cidr != null) {
      dhcpRange=NetUtils.getDhcpRange(cidr);
    }
  }
  if (router.getRole() == Role.DHCP_USERDATA) {
    type="String_Node_Str";
  }
 else {
    type="String_Node_Str";
  }
  StringBuilder buf=profile.getBootArgsBuilder();
  buf.append("String_Node_Str" + type);
  buf.append("String_Node_Str").append(profile.getHostName());
  NicProfile controlNic=null;
  for (  NicProfile nic : profile.getNics()) {
    int deviceId=nic.getDeviceId();
    buf.append("String_Node_Str").append(deviceId).append("String_Node_Str").append(nic.getIp4Address());
    buf.append("String_Node_Str").append(deviceId).append("String_Node_Str").append(nic.getNetmask());
    if (nic.isDefaultNic()) {
      buf.append("String_Node_Str").append(nic.getGateway());
      buf.append("String_Node_Str").append(nic.getDns1());
      if (nic.getDns2() != null) {
        buf.append("String_Node_Str").append(nic.getDns2());
      }
      if (dc.getNetworkType() == NetworkType.Basic) {
        long cidrSize=NetUtils.getCidrSize(nic.getNetmask());
        String cidr=NetUtils.getCidrSubNet(nic.getGateway(),cidrSize);
        if (cidr != null) {
          dhcpRange=NetUtils.getIpRangeStartIpFromCidr(cidr,cidrSize);
        }
      }
    }
    if (nic.getTrafficType() == TrafficType.Management) {
      buf.append("String_Node_Str").append(dest.getPod().getGateway());
    }
 else     if (nic.getTrafficType() == TrafficType.Control) {
      if (dest.getHost().getHypervisorType() == HypervisorType.VMware) {
        if (s_logger.isInfoEnabled()) {
          s_logger.info("String_Node_Str" + dest.getPod().getCidrAddress() + "String_Node_Str"+ dest.getPod().getCidrSize()+ "String_Node_Str"+ dest.getPod().getGateway()+ "String_Node_Str"+ _mgmt_host);
        }
        if (!NetUtils.sameSubnetCIDR(_mgmt_host,dest.getPod().getGateway(),dest.getPod().getCidrSize())) {
          if (s_logger.isInfoEnabled()) {
            s_logger.info("String_Node_Str");
          }
          buf.append("String_Node_Str").append(_mgmt_host);
          buf.append("String_Node_Str").append(dest.getPod().getGateway());
        }
 else {
          if (s_logger.isInfoEnabled()) {
            s_logger.info("String_Node_Str");
          }
        }
      }
      controlNic=nic;
    }
  }
  if (dhcpRange != null) {
    buf.append("String_Node_Str" + dhcpRange);
  }
  String domain=network.getNetworkDomain();
  if (domain != null) {
    buf.append("String_Node_Str" + domain);
  }
  if (!network.isDefault() && network.getGuestType() == GuestIpType.Direct) {
    buf.append("String_Node_Str");
  }
 else {
    buf.append("String_Node_Str");
  }
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + profile + "String_Node_Str"+ buf.toString());
  }
  if (controlNic == null) {
    throw new CloudRuntimeException("String_Node_Str");
  }
  return true;
}