Program: 89760
Project: 89760
Buggy source:
@Override public boolean applyFirewallRules(Network network,List<? extends FirewallRule> rules) throws ResourceUnavailableException {
  DomainRouterVO router=_routerDao.findByNetwork(network.getId());
  if (router == null) {
    s_logger.warn("String_Node_Str" + network.getId());
    throw new ResourceUnavailableException("String_Node_Str",DataCenter.class,network.getDataCenterId());
  }
  if (router.getState() == State.Running) {
    if (rules != null && !rules.isEmpty()) {
      if (rules.get(0).getPurpose() == Purpose.LoadBalancing) {
        List<LoadBalancerVO> lbs=_loadBalancerDao.listByNetworkId(network.getId());
        List<LoadBalancingRule> lbRules=new ArrayList<LoadBalancingRule>();
        for (        LoadBalancerVO lb : lbs) {
          List<LbDestination> dstList=_lbMgr.getExistingDestinations(lb.getId());
          LoadBalancingRule loadBalancing=new LoadBalancingRule(lb,dstList);
          lbRules.add(loadBalancing);
        }
        return applyLBRules(router,lbRules);
      }
 else       if (rules.get(0).getPurpose() == Purpose.PortForwarding) {
        return applyPortForwardingRules(router,(List<PortForwardingRule>)rules);
      }
 else       if (rules.get(0).getPurpose() == Purpose.StaticNat) {
        return applyStaticNatRules(router,(List<StaticNatRule>)rules);
      }
 else {
        s_logger.warn("String_Node_Str" + rules.get(0).getPurpose());
        return false;
      }
    }
 else {
      return true;
    }
  }
 else   if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
    s_logger.debug("String_Node_Str" + router.getState() + "String_Node_Str");
    return true;
  }
 else {
    s_logger.warn("String_Node_Str" + router.getState());
    throw new CloudRuntimeException("String_Node_Str" + router.getState());
  }
}

Fixed version (ground truth):
@Override public boolean applyFirewallRules(Network network,List<? extends FirewallRule> rules) throws ResourceUnavailableException {
  DomainRouterVO router=_routerDao.findByNetwork(network.getId());
  if (router == null) {
    s_logger.warn("String_Node_Str" + network.getId());
    throw new ResourceUnavailableException("String_Node_Str",DataCenter.class,network.getDataCenterId());
  }
  if (router.getState() == State.Running) {
    if (rules != null && !rules.isEmpty()) {
      if (rules.get(0).getPurpose() == Purpose.LoadBalancing) {
        List<LoadBalancerVO> lbs=_loadBalancerDao.listByNetworkId(network.getId());
        List<LoadBalancingRule> lbRules=new ArrayList<LoadBalancingRule>();
        for (        LoadBalancerVO lb : lbs) {
          List<LbDestination> dstList=_lbMgr.getExistingDestinations(lb.getId());
          LoadBalancingRule loadBalancing=new LoadBalancingRule(lb,dstList);
          lbRules.add(loadBalancing);
        }
        return applyLBRules(router,lbRules);
      }
 else       if (rules.get(0).getPurpose() == Purpose.PortForwarding) {
        return applyPortForwardingRules(router,(List<PortForwardingRule>)rules);
      }
 else       if (rules.get(0).getPurpose() == Purpose.StaticNat) {
        return applyStaticNatRules(router,(List<StaticNatRule>)rules);
      }
 else {
        s_logger.warn("String_Node_Str" + rules.get(0).getPurpose());
        return false;
      }
    }
 else {
      return true;
    }
  }
 else   if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
    s_logger.debug("String_Node_Str" + router.getState() + "String_Node_Str");
    return true;
  }
 else {
    s_logger.warn("String_Node_Str" + router.getState());
    throw new ResourceUnavailableException("String_Node_Str",VirtualRouter.class,router.getId());
  }
}