Program: 106076
Project: 106076
Buggy source:
/** 
 * @param router
 * @param add
 * @param privateNic
 * @return
 * @throws ResourceUnavailableException
 */
protected boolean setupVpcPrivateNetwork(VirtualRouter router,boolean add,NicProfile privateNic) throws ResourceUnavailableException {
  if (router.getState() == State.Running) {
    PrivateIpVO ipVO=_privateIpDao.findByIpAndSourceNetworkId(privateNic.getNetworkId(),privateNic.getIp4Address());
    Network network=_networkDao.findById(privateNic.getNetworkId());
    String vlanTag=BroadcastDomainType.getValue(network.getBroadcastUri());
    String netmask=NetUtils.getCidrNetmask(network.getCidr());
    PrivateIpAddress ip=new PrivateIpAddress(ipVO,vlanTag,network.getGateway(),netmask,privateNic.getMacAddress());
    List<PrivateIpAddress> privateIps=new ArrayList<PrivateIpAddress>(1);
    privateIps.add(ip);
    Commands cmds=new Commands(Command.OnError.Stop);
    createVpcAssociatePrivateIPCommands(router,privateIps,cmds,add);
    if (sendCommandsToRouter(router,cmds)) {
      s_logger.debug("String_Node_Str" + ip + "String_Node_Str"+ network);
      return true;
    }
 else {
      s_logger.warn("String_Node_Str" + ip + "String_Node_Str"+ network);
      return false;
    }
  }
 else   if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
    s_logger.debug("String_Node_Str" + router.getInstanceName() + "String_Node_Str"+ router.getState()+ "String_Node_Str");
  }
 else {
    s_logger.warn("String_Node_Str" + router + "String_Node_Str"+ router.getState());
    throw new ResourceUnavailableException("String_Node_Str" + "String_Node_Str" + router + "String_Node_Str",DataCenter.class,router.getDataCenterId());
  }
  return true;
}

Fixed version (ground truth):
/** 
 * @param router
 * @param add
 * @param privateNic
 * @return
 * @throws ResourceUnavailableException
 */
protected boolean setupVpcPrivateNetwork(VirtualRouter router,boolean add,NicProfile privateNic) throws ResourceUnavailableException {
  if (router.getState() == State.Running) {
    PrivateIpVO ipVO=_privateIpDao.findByIpAndSourceNetworkId(privateNic.getNetworkId(),privateNic.getIp4Address());
    Network network=_networkDao.findById(privateNic.getNetworkId());
    String vlanTag=BroadcastDomainType.getValue(network.getBroadcastUri());
    String netmask=NetUtils.getCidrNetmask(network.getCidr());
    PrivateIpAddress ip=new PrivateIpAddress(ipVO,network.getBroadcastUri().toString(),network.getGateway(),netmask,privateNic.getMacAddress());
    List<PrivateIpAddress> privateIps=new ArrayList<PrivateIpAddress>(1);
    privateIps.add(ip);
    Commands cmds=new Commands(Command.OnError.Stop);
    createVpcAssociatePrivateIPCommands(router,privateIps,cmds,add);
    if (sendCommandsToRouter(router,cmds)) {
      s_logger.debug("String_Node_Str" + ip + "String_Node_Str"+ network);
      return true;
    }
 else {
      s_logger.warn("String_Node_Str" + ip + "String_Node_Str"+ network);
      return false;
    }
  }
 else   if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
    s_logger.debug("String_Node_Str" + router.getInstanceName() + "String_Node_Str"+ router.getState()+ "String_Node_Str");
  }
 else {
    s_logger.warn("String_Node_Str" + router + "String_Node_Str"+ router.getState());
    throw new ResourceUnavailableException("String_Node_Str" + "String_Node_Str" + router + "String_Node_Str",DataCenter.class,router.getDataCenterId());
  }
  return true;
}