nus-yam/ex-repair huggingface dataset:
Program: 105719
Project: 105719
Buggy source:
@Override public void execute(){
  ListResponse<PortableIpRangeResponse> response=new ListResponse<PortableIpRangeResponse>();
  List<PortableIpRangeResponse> responses=new ArrayList<PortableIpRangeResponse>();
  List<? extends PortableIpRange> portableIpRanges=_configService.listPortableIpRanges(this);
  if (portableIpRanges != null && !portableIpRanges.isEmpty()) {
    for (    PortableIpRange range : portableIpRanges) {
      PortableIpRangeResponse rangeResponse=_responseGenerator.createPortableIPRangeResponse(range);
      List<? extends PortableIp> portableIps=_configService.listPortableIps(range.getId());
      if (portableIps != null && !portableIps.isEmpty()) {
        List<PortableIpResponse> portableIpResponses=new ArrayList<PortableIpResponse>();
        for (        PortableIp portableIP : portableIps) {
          PortableIpResponse portableIpresponse=_responseGenerator.createPortableIPResponse(portableIP);
          portableIpResponses.add(portableIpresponse);
        }
        rangeResponse.setPortableIpResponses(portableIpResponses);
      }
      responses.add(rangeResponse);
    }
  }
  response.setResponses(responses,portableIpRanges.size());
  response.setResponseName(getCommandName());
  this.setResponseObject(response);
}

Fixed version (ground truth):
@Override public void execute(){
  ListResponse<PortableIpRangeResponse> response=new ListResponse<PortableIpRangeResponse>();
  List<PortableIpRangeResponse> responses=new ArrayList<PortableIpRangeResponse>();
  List<? extends PortableIpRange> portableIpRanges=_configService.listPortableIpRanges(this);
  if (portableIpRanges != null && !portableIpRanges.isEmpty()) {
    for (    PortableIpRange range : portableIpRanges) {
      PortableIpRangeResponse rangeResponse=_responseGenerator.createPortableIPRangeResponse(range);
      List<? extends PortableIp> portableIps=_configService.listPortableIps(range.getId());
      if (portableIps != null && !portableIps.isEmpty()) {
        List<PortableIpResponse> portableIpResponses=new ArrayList<PortableIpResponse>();
        for (        PortableIp portableIP : portableIps) {
          PortableIpResponse portableIpresponse=_responseGenerator.createPortableIPResponse(portableIP);
          portableIpResponses.add(portableIpresponse);
        }
        rangeResponse.setPortableIpResponses(portableIpResponses);
      }
      responses.add(rangeResponse);
    }
    response.setResponses(responses,portableIpRanges.size());
  }
  response.setResponseName(getCommandName());
  this.setResponseObject(response);
}
Program: 105720
Project: 105720
Buggy source:
private Long getVpcId(){
  if (ipAddressId != null) {
    IpAddress ipAddr=_networkService.getIp(ipAddressId);
    if (ipAddr == null || !ipAddr.readyToUse()) {
      throw new InvalidParameterValueException("String_Node_Str" + ipAddr.getId());
    }
 else {
      return ipAddr.getVpcId();
    }
  }
  return null;
}

Fixed version (ground truth):
private Long getVpcId(){
  if (ipAddressId != null) {
    IpAddress ipAddr=_networkService.getIp(ipAddressId);
    if (ipAddr == null || !ipAddr.readyToUse()) {
      throw new InvalidParameterValueException("String_Node_Str" + ipAddressId);
    }
 else {
      return ipAddr.getVpcId();
    }
  }
  return null;
}
Program: 105721
Project: 105721
Buggy source:
public Long getSourceIpAddressId(){
  if (publicIpId != null) {
    IpAddress ipAddr=_networkService.getIp(publicIpId);
    if (ipAddr == null || !ipAddr.readyToUse()) {
      throw new InvalidParameterValueException("String_Node_Str" + ipAddr.getId());
    }
  }
 else   if (getEntityId() != null) {
    LoadBalancer rule=_entityMgr.findById(LoadBalancer.class,getEntityId());
    return rule.getSourceIpAddressId();
  }
  return publicIpId;
}

Fixed version (ground truth):
public Long getSourceIpAddressId(){
  if (publicIpId != null) {
    IpAddress ipAddr=_networkService.getIp(publicIpId);
    if (ipAddr == null || !ipAddr.readyToUse()) {
      throw new InvalidParameterValueException("String_Node_Str" + publicIpId);
    }
  }
 else   if (getEntityId() != null) {
    LoadBalancer rule=_entityMgr.findById(LoadBalancer.class,getEntityId());
    return rule.getSourceIpAddressId();
  }
  return publicIpId;
}
Program: 105722
Project: 105722
Buggy source:
private Long getVpcId(){
  if (publicIpId != null) {
    IpAddress ipAddr=_networkService.getIp(publicIpId);
    if (ipAddr == null || !ipAddr.readyToUse()) {
      throw new InvalidParameterValueException("String_Node_Str" + ipAddr.getId());
    }
 else {
      return ipAddr.getVpcId();
    }
  }
  return null;
}

Fixed version (ground truth):
private Long getVpcId(){
  if (publicIpId != null) {
    IpAddress ipAddr=_networkService.getIp(publicIpId);
    if (ipAddr == null || !ipAddr.readyToUse()) {
      throw new InvalidParameterValueException("String_Node_Str" + publicIpId);
    }
 else {
      return ipAddr.getVpcId();
    }
  }
  return null;
}
Program: 105723
Project: 105723
Buggy source:
@Override public void execute(){
  Pair<List<? extends LoadBalancer>,Integer> loadBalancers=_lbService.searchForLoadBalancers(this);
  ListResponse<LoadBalancerResponse> response=new ListResponse<LoadBalancerResponse>();
  List<LoadBalancerResponse> lbResponses=new ArrayList<LoadBalancerResponse>();
  if (loadBalancers != null) {
    for (    LoadBalancer loadBalancer : loadBalancers.first()) {
      LoadBalancerResponse lbResponse=_responseGenerator.createLoadBalancerResponse(loadBalancer);
      lbResponse.setObjectName("String_Node_Str");
      lbResponses.add(lbResponse);
    }
  }
  response.setResponses(lbResponses,loadBalancers.second());
  response.setResponseName(getCommandName());
  this.setResponseObject(response);
}

Fixed version (ground truth):
@Override public void execute(){
  Pair<List<? extends LoadBalancer>,Integer> loadBalancers=_lbService.searchForLoadBalancers(this);
  ListResponse<LoadBalancerResponse> response=new ListResponse<LoadBalancerResponse>();
  List<LoadBalancerResponse> lbResponses=new ArrayList<LoadBalancerResponse>();
  if (loadBalancers != null) {
    for (    LoadBalancer loadBalancer : loadBalancers.first()) {
      LoadBalancerResponse lbResponse=_responseGenerator.createLoadBalancerResponse(loadBalancer);
      lbResponse.setObjectName("String_Node_Str");
      lbResponses.add(lbResponse);
    }
    response.setResponses(lbResponses,loadBalancers.second());
  }
  response.setResponseName(getCommandName());
  this.setResponseObject(response);
}
Program: 105724
Project: 105724
Buggy source:
@Override public void execute() throws ResourceAllocationException, ResourceUnavailableException {
  CallContext callerContext=CallContext.current();
  GlobalLoadBalancerRule rule=_entityMgr.findById(GlobalLoadBalancerRule.class,getEntityId());
  GlobalLoadBalancerResponse response=null;
  if (rule != null) {
    response=_responseGenerator.createGlobalLoadBalancerResponse(rule);
    setResponseObject(response);
  }
  response.setResponseName(getCommandName());
}

Fixed version (ground truth):
@Override public void execute() throws ResourceAllocationException, ResourceUnavailableException {
  GlobalLoadBalancerRule rule=_entityMgr.findById(GlobalLoadBalancerRule.class,getEntityId());
  if (rule != null) {
    GlobalLoadBalancerResponse response=_responseGenerator.createGlobalLoadBalancerResponse(rule);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
  }
}
Program: 105725
Project: 105725
Buggy source:
protected boolean filter(ExcludeList avoid,StoragePool pool,DiskProfile dskCh,DeploymentPlan plan){
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + pool.getName() + "String_Node_Str"+ pool.getId());
  }
  if (avoid.shouldAvoid(pool)) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
    }
    return false;
  }
  Long clusterId=pool.getClusterId();
  if (clusterId != null) {
    ClusterVO cluster=_clusterDao.findById(clusterId);
    if (!(cluster.getHypervisorType() == dskCh.getHypervisorType())) {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str");
      }
      return false;
    }
  }
 else   if (pool.getHypervisor() != null && !(pool.getHypervisor() == dskCh.getHypervisorType())) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
    }
    return false;
  }
  Volume volume=_volumeDao.findById(dskCh.getVolumeId());
  List<Volume> requestVolumes=new ArrayList<Volume>();
  requestVolumes.add(volume);
  return storageMgr.storagePoolHasEnoughIops(requestVolumes,pool) && storageMgr.storagePoolHasEnoughSpace(requestVolumes,pool);
}

Fixed version (ground truth):
protected boolean filter(ExcludeList avoid,StoragePool pool,DiskProfile dskCh,DeploymentPlan plan){
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + pool.getName() + "String_Node_Str"+ pool.getId());
  }
  if (avoid.shouldAvoid(pool)) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
    }
    return false;
  }
  Long clusterId=pool.getClusterId();
  if (clusterId != null) {
    ClusterVO cluster=_clusterDao.findById(clusterId);
    if (!(cluster.getHypervisorType() == dskCh.getHypervisorType())) {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str");
      }
      return false;
    }
  }
 else   if (pool.getHypervisor() != null && !pool.getHypervisor().equals(HypervisorType.Any) && !(pool.getHypervisor() == dskCh.getHypervisorType())) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str");
    }
    return false;
  }
  Volume volume=_volumeDao.findById(dskCh.getVolumeId());
  List<Volume> requestVolumes=new ArrayList<Volume>();
  requestVolumes.add(volume);
  return storageMgr.storagePoolHasEnoughIops(requestVolumes,pool) && storageMgr.storagePoolHasEnoughSpace(requestVolumes,pool);
}
Program: 105726
Project: 105726
Buggy source:
@Override @DB public List<VlanVO> searchForZoneWideVlans(long dcId,String vlanType,String vlanId){
  StringBuilder sql=new StringBuilder(FindZoneWideVlans);
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  PreparedStatement pstmt=null;
  try {
    pstmt=txn.prepareAutoCloseStatement(sql.toString());
    pstmt.setLong(1,dcId);
    pstmt.setString(2,vlanType);
    pstmt.setString(3,vlanId);
    ResultSet rs=pstmt.executeQuery();
    List<VlanVO> zoneWideVlans=new ArrayList<VlanVO>();
    while (rs.next()) {
      zoneWideVlans.add(toEntityBean(rs,false));
    }
    return zoneWideVlans;
  }
 catch (  SQLException e) {
    throw new CloudRuntimeException("String_Node_Str" + pstmt.toString(),e);
  }
}

Fixed version (ground truth):
@Override @DB public List<VlanVO> searchForZoneWideVlans(long dcId,String vlanType,String vlanId){
  StringBuilder sql=new StringBuilder(FindZoneWideVlans);
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  List<VlanVO> zoneWideVlans=new ArrayList<VlanVO>();
  try (PreparedStatement pstmt=txn.prepareStatement(sql.toString())){
    if (pstmt != null) {
      pstmt.setLong(1,dcId);
      pstmt.setString(2,vlanType);
      pstmt.setString(3,vlanId);
      try (ResultSet rs=pstmt.executeQuery()){
        while (rs.next()) {
          zoneWideVlans.add(toEntityBean(rs,false));
        }
      }
 catch (      SQLException e) {
        throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
      }
    }
    return zoneWideVlans;
  }
 catch (  SQLException e) {
    throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 105727
Project: 105727
Buggy source:
@Override @DB public List<Long> searchForPoolIdsForPendingWorkJobs(long msId){
  StringBuilder sql=new StringBuilder(FindPoolIds);
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  PreparedStatement pstmt=null;
  try {
    pstmt=txn.prepareAutoCloseStatement(sql.toString());
    pstmt.setLong(1,msId);
    ResultSet rs=pstmt.executeQuery();
    List<Long> poolIds=new ArrayList<Long>();
    while (rs.next()) {
      poolIds.add(rs.getLong("String_Node_Str"));
    }
    return poolIds;
  }
 catch (  SQLException e) {
    throw new CloudRuntimeException("String_Node_Str" + pstmt.toString(),e);
  }
}

Fixed version (ground truth):
@Override @DB public List<Long> searchForPoolIdsForPendingWorkJobs(long msId){
  StringBuilder sql=new StringBuilder(FindPoolIds);
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  List<Long> poolIds=new ArrayList<Long>();
  try (PreparedStatement pstmt=txn.prepareStatement(sql.toString())){
    if (pstmt != null) {
      pstmt.setLong(1,msId);
      try (ResultSet rs=pstmt.executeQuery()){
        while (rs.next()) {
          poolIds.add(rs.getLong("String_Node_Str"));
        }
      }
 catch (      SQLException e) {
        throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
      }
    }
    return poolIds;
  }
 catch (  SQLException e) {
    throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 105728
Project: 105728
Buggy source:
private static void initDB(String dbPropsFile,String rootPassword,String[] databases,boolean dryRun){
  Properties dbProperties=new Properties();
  try {
    dbProperties.load(new FileInputStream(new File(dbPropsFile)));
  }
 catch (  IOException e) {
    System.out.println("String_Node_Str" + e);
    System.exit(1);
  }
  for (  String database : databases) {
    String host=dbProperties.getProperty(String.format("String_Node_Str",database));
    String port=dbProperties.getProperty(String.format("String_Node_Str",database));
    String username=dbProperties.getProperty(String.format("String_Node_Str",database));
    String password=dbProperties.getProperty(String.format("String_Node_Str",database));
    String dbName=dbProperties.getProperty(String.format("String_Node_Str",database));
    System.out.println(String.format("String_Node_Str",dbName,host,port,username,password));
    List<String> queries=new ArrayList<String>();
    queries.add(String.format("String_Node_Str",dbName));
    queries.add(String.format("String_Node_Str",dbName));
    queries.add(String.format("String_Node_Str",dbName,username,password));
    queries.add(String.format("String_Node_Str",dbName,username,password));
    for (    String query : queries) {
      runQuery(host,port,rootPassword,query,dryRun);
    }
  }
}

Fixed version (ground truth):
private static void initDB(String dbPropsFile,String rootPassword,String[] databases,boolean dryRun){
  Properties dbProperties=new Properties();
  try (FileInputStream f_stream=new FileInputStream(new File(dbPropsFile))){
    dbProperties.load(f_stream);
  }
 catch (  IOException e) {
    System.out.println("String_Node_Str" + e);
    System.exit(1);
  }
  for (  String database : databases) {
    String host=dbProperties.getProperty(String.format("String_Node_Str",database));
    String port=dbProperties.getProperty(String.format("String_Node_Str",database));
    String username=dbProperties.getProperty(String.format("String_Node_Str",database));
    String password=dbProperties.getProperty(String.format("String_Node_Str",database));
    String dbName=dbProperties.getProperty(String.format("String_Node_Str",database));
    System.out.println(String.format("String_Node_Str",dbName,host,port,username,password));
    List<String> queries=new ArrayList<String>();
    queries.add(String.format("String_Node_Str",dbName));
    queries.add(String.format("String_Node_Str",dbName));
    queries.add(String.format("String_Node_Str",dbName,username,password));
    queries.add(String.format("String_Node_Str",dbName,username,password));
    for (    String query : queries) {
      runQuery(host,port,rootPassword,query,dryRun);
    }
  }
}
Program: 105729
Project: 105729
Buggy source:
@Override public void update(UsageIPAddressVO usage){
  TransactionLegacy txn=TransactionLegacy.open(TransactionLegacy.USAGE_DB);
  PreparedStatement pstmt=null;
  try {
    txn.start();
    if (usage.getReleased() != null) {
      pstmt=txn.prepareAutoCloseStatement(UPDATE_RELEASED);
      pstmt.setString(1,DateUtil.getDateDisplayString(TimeZone.getTimeZone("String_Node_Str"),usage.getReleased()));
      pstmt.setLong(2,usage.getAccountId());
      pstmt.setString(3,usage.getAddress());
    }
    pstmt.executeUpdate();
    txn.commit();
  }
 catch (  Exception e) {
    txn.rollback();
    s_logger.warn("String_Node_Str",e);
  }
 finally {
    txn.close();
  }
}

Fixed version (ground truth):
@Override public void update(UsageIPAddressVO usage){
  TransactionLegacy txn=TransactionLegacy.open(TransactionLegacy.USAGE_DB);
  try {
    txn.start();
    if (usage.getReleased() != null) {
      try (PreparedStatement pstmt=txn.prepareStatement(UPDATE_RELEASED)){
        if (pstmt != null) {
          pstmt.setString(1,DateUtil.getDateDisplayString(TimeZone.getTimeZone("String_Node_Str"),usage.getReleased()));
          pstmt.setLong(2,usage.getAccountId());
          pstmt.setString(3,usage.getAddress());
          pstmt.executeUpdate();
        }
      }
 catch (      SQLException e) {
        throw new CloudException("String_Node_Str" + e.getMessage(),e);
      }
    }
    txn.commit();
  }
 catch (  Exception e) {
    txn.rollback();
    s_logger.error("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    txn.close();
  }
}
Program: 105730
Project: 105730
Buggy source:
@Override public void update(UsageLoadBalancerPolicyVO usage){
  TransactionLegacy txn=TransactionLegacy.open(TransactionLegacy.USAGE_DB);
  PreparedStatement pstmt=null;
  try {
    txn.start();
    if (usage.getDeleted() != null) {
      pstmt=txn.prepareAutoCloseStatement(UPDATE_DELETED);
      pstmt.setString(1,DateUtil.getDateDisplayString(TimeZone.getTimeZone("String_Node_Str"),usage.getDeleted()));
      pstmt.setLong(2,usage.getAccountId());
      pstmt.setLong(3,usage.getId());
    }
    pstmt.executeUpdate();
    txn.commit();
  }
 catch (  Exception e) {
    txn.rollback();
    s_logger.warn("String_Node_Str",e);
  }
 finally {
    txn.close();
  }
}

Fixed version (ground truth):
@Override public void update(UsageLoadBalancerPolicyVO usage){
  TransactionLegacy txn=TransactionLegacy.open(TransactionLegacy.USAGE_DB);
  try {
    txn.start();
    if (usage.getDeleted() != null) {
      try (PreparedStatement pstmt=txn.prepareStatement(UPDATE_DELETED)){
        if (pstmt != null) {
          pstmt.setString(1,DateUtil.getDateDisplayString(TimeZone.getTimeZone("String_Node_Str"),usage.getDeleted()));
          pstmt.setLong(2,usage.getAccountId());
          pstmt.setLong(3,usage.getId());
          pstmt.executeUpdate();
        }
      }
 catch (      SQLException e) {
        throw new CloudException("String_Node_Str" + e.getMessage(),e);
      }
    }
    txn.commit();
  }
 catch (  Exception e) {
    txn.rollback();
    s_logger.warn("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    txn.close();
  }
}
Program: 105731
Project: 105731
Buggy source:
@Override public void update(UsageNetworkOfferingVO usage){
  TransactionLegacy txn=TransactionLegacy.open(TransactionLegacy.USAGE_DB);
  PreparedStatement pstmt=null;
  try {
    txn.start();
    if (usage.getDeleted() != null) {
      pstmt=txn.prepareAutoCloseStatement(UPDATE_DELETED);
      pstmt.setString(1,DateUtil.getDateDisplayString(TimeZone.getTimeZone("String_Node_Str"),usage.getDeleted()));
      pstmt.setLong(2,usage.getAccountId());
      pstmt.setLong(3,usage.getVmInstanceId());
      pstmt.setLong(4,usage.getNetworkOfferingId());
    }
    pstmt.executeUpdate();
    txn.commit();
  }
 catch (  Exception e) {
    txn.rollback();
    s_logger.warn("String_Node_Str",e);
  }
 finally {
    txn.close();
  }
}

Fixed version (ground truth):
@Override public void update(UsageNetworkOfferingVO usage){
  TransactionLegacy txn=TransactionLegacy.open(TransactionLegacy.USAGE_DB);
  try {
    txn.start();
    if (usage.getDeleted() != null) {
      try (PreparedStatement pstmt=txn.prepareStatement(UPDATE_DELETED)){
        if (pstmt != null) {
          pstmt.setString(1,DateUtil.getDateDisplayString(TimeZone.getTimeZone("String_Node_Str"),usage.getDeleted()));
          pstmt.setLong(2,usage.getAccountId());
          pstmt.setLong(3,usage.getVmInstanceId());
          pstmt.setLong(4,usage.getNetworkOfferingId());
          pstmt.executeUpdate();
        }
      }
 catch (      SQLException e) {
        throw new CloudException("String_Node_Str" + e.getMessage(),e);
      }
    }
    txn.commit();
  }
 catch (  Exception e) {
    txn.rollback();
    s_logger.warn("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    txn.close();
  }
}
Program: 105732
Project: 105732
Buggy source:
@Override public void update(UsagePortForwardingRuleVO usage){
  TransactionLegacy txn=TransactionLegacy.open(TransactionLegacy.USAGE_DB);
  PreparedStatement pstmt=null;
  try {
    txn.start();
    if (usage.getDeleted() != null) {
      pstmt=txn.prepareAutoCloseStatement(UPDATE_DELETED);
      pstmt.setString(1,DateUtil.getDateDisplayString(TimeZone.getTimeZone("String_Node_Str"),usage.getDeleted()));
      pstmt.setLong(2,usage.getAccountId());
      pstmt.setLong(3,usage.getId());
    }
    pstmt.executeUpdate();
    txn.commit();
  }
 catch (  Exception e) {
    txn.rollback();
    s_logger.warn("String_Node_Str",e);
  }
 finally {
    txn.close();
  }
}

Fixed version (ground truth):
@Override public void update(UsagePortForwardingRuleVO usage){
  TransactionLegacy txn=TransactionLegacy.open(TransactionLegacy.USAGE_DB);
  try {
    txn.start();
    if (usage.getDeleted() != null) {
      try (PreparedStatement pstmt=txn.prepareStatement(UPDATE_DELETED)){
        if (pstmt != null) {
          pstmt.setString(1,DateUtil.getDateDisplayString(TimeZone.getTimeZone("String_Node_Str"),usage.getDeleted()));
          pstmt.setLong(2,usage.getAccountId());
          pstmt.setLong(3,usage.getId());
          pstmt.executeUpdate();
        }
      }
 catch (      SQLException e) {
        throw new CloudException("String_Node_Str" + e.getMessage(),e);
      }
    }
    txn.commit();
  }
 catch (  Exception e) {
    txn.rollback();
    s_logger.warn("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    txn.close();
  }
}
Program: 105733
Project: 105733
Buggy source:
@Override @ActionEvent(eventType=EventTypes.EVENT_SNAPSHOT_POLICY_UPDATE,eventDescription="String_Node_Str",async=true) public SnapshotPolicy updateSnapshotPolicy(UpdateSnapshotPolicyCmd cmd){
  Long id=cmd.getId();
  String customUUID=cmd.getCustomId();
  Boolean display=cmd.getDisplay();
  SnapshotPolicyVO policyVO=_snapshotPolicyDao.findById(id);
  if (display != null)   policyVO.setDisplay(display);
  if (customUUID != null)   policyVO.setUuid(customUUID);
  _snapshotPolicyDao.update(id,policyVO);
  return policyVO;
}

Fixed version (ground truth):
@Override @ActionEvent(eventType=EventTypes.EVENT_SNAPSHOT_POLICY_UPDATE,eventDescription="String_Node_Str",async=true) public SnapshotPolicy updateSnapshotPolicy(UpdateSnapshotPolicyCmd cmd){
  Long id=cmd.getId();
  String customUUID=cmd.getCustomId();
  Boolean display=cmd.getDisplay();
  SnapshotPolicyVO policyVO=_snapshotPolicyDao.findById(id);
  if (display != null) {
    boolean previousDisplay=policyVO.isDisplay();
    policyVO.setDisplay(display);
    _snapSchedMgr.scheduleOrCancelNextSnapshotJobOnDisplayChange(policyVO,previousDisplay);
  }
  if (customUUID != null)   policyVO.setUuid(customUUID);
  _snapshotPolicyDao.update(id,policyVO);
  return policyVO;
}
Program: 105734
Project: 105734
Buggy source:
@Override @DB public Date scheduleNextSnapshotJob(final SnapshotPolicyVO policy){
  if (policy == null) {
    return null;
  }
  if (!policy.isDisplay()) {
    removeSchedule(policy.getVolumeId(),policy.getId());
  }
  final long policyId=policy.getId();
  if (policyId == Snapshot.MANUAL_POLICY_ID) {
    return null;
  }
  final Date nextSnapshotTimestamp=getNextScheduledTime(policyId,_currentTimestamp);
  SnapshotScheduleVO spstSchedVO=_snapshotScheduleDao.findOneByVolumePolicy(policy.getVolumeId(),policy.getId());
  if (spstSchedVO == null) {
    spstSchedVO=new SnapshotScheduleVO(policy.getVolumeId(),policyId,nextSnapshotTimestamp);
    _snapshotScheduleDao.persist(spstSchedVO);
  }
 else {
    try {
      spstSchedVO=_snapshotScheduleDao.acquireInLockTable(spstSchedVO.getId());
      spstSchedVO.setPolicyId(policyId);
      spstSchedVO.setScheduledTimestamp(nextSnapshotTimestamp);
      spstSchedVO.setAsyncJobId(null);
      spstSchedVO.setSnapshotId(null);
      _snapshotScheduleDao.update(spstSchedVO.getId(),spstSchedVO);
    }
  finally {
      if (spstSchedVO != null) {
        _snapshotScheduleDao.releaseFromLockTable(spstSchedVO.getId());
      }
    }
  }
  return nextSnapshotTimestamp;
}

Fixed version (ground truth):
@Override @DB public Date scheduleNextSnapshotJob(final SnapshotPolicyVO policy){
  if (policy == null) {
    return null;
  }
  if (!policy.isDisplay()) {
    removeSchedule(policy.getVolumeId(),policy.getId());
    return null;
  }
  final long policyId=policy.getId();
  if (policyId == Snapshot.MANUAL_POLICY_ID) {
    return null;
  }
  final Date nextSnapshotTimestamp=getNextScheduledTime(policyId,_currentTimestamp);
  SnapshotScheduleVO spstSchedVO=_snapshotScheduleDao.findOneByVolumePolicy(policy.getVolumeId(),policy.getId());
  if (spstSchedVO == null) {
    spstSchedVO=new SnapshotScheduleVO(policy.getVolumeId(),policyId,nextSnapshotTimestamp);
    _snapshotScheduleDao.persist(spstSchedVO);
  }
 else {
    try {
      spstSchedVO=_snapshotScheduleDao.acquireInLockTable(spstSchedVO.getId());
      spstSchedVO.setPolicyId(policyId);
      spstSchedVO.setScheduledTimestamp(nextSnapshotTimestamp);
      spstSchedVO.setAsyncJobId(null);
      spstSchedVO.setSnapshotId(null);
      _snapshotScheduleDao.update(spstSchedVO.getId(),spstSchedVO);
    }
  finally {
      if (spstSchedVO != null) {
        _snapshotScheduleDao.releaseFromLockTable(spstSchedVO.getId());
      }
    }
  }
  return nextSnapshotTimestamp;
}
Program: 105735
Project: 105735
Buggy source:
@Override public long getUsedIops(StoragePoolVO pool){
  long usedIops=0;
  List<VolumeVO> volumes=_volumeDao.findByPoolId(pool.getId(),null);
  if (volumes != null && volumes.size() > 0) {
    for (    VolumeVO volume : volumes) {
      usedIops+=volume.getMinIops();
    }
  }
  return usedIops;
}

Fixed version (ground truth):
@Override public long getUsedIops(StoragePoolVO pool){
  long usedIops=0;
  List<VolumeVO> volumes=_volumeDao.findByPoolId(pool.getId(),null);
  if (volumes != null && volumes.size() > 0) {
    for (    VolumeVO volume : volumes) {
      usedIops+=volume.getMinIops() != null ? volume.getMinIops() : 0;
    }
  }
  return usedIops;
}
Program: 105736
Project: 105736
Buggy source:
public Map<String,String> getDetails(){
  Map<String,String> customparameterMap=new HashMap<String,String>();
  if (details != null && details.size() != 0) {
    Collection parameterCollection=details.values();
    Iterator iter=parameterCollection.iterator();
    while (iter.hasNext()) {
      HashMap<String,String> value=(HashMap<String,String>)iter.next();
      for (      String key : value.keySet()) {
        customparameterMap.put(key,value.get(key));
      }
    }
  }
  return customparameterMap;
}

Fixed version (ground truth):
public Map<String,String> getDetails(){
  Map<String,String> customparameterMap=new HashMap<String,String>();
  if (details != null && details.size() != 0) {
    Collection parameterCollection=details.values();
    Iterator iter=parameterCollection.iterator();
    while (iter.hasNext()) {
      HashMap<String,String> value=(HashMap<String,String>)iter.next();
      for (      Map.Entry<String,String> entry : value.entrySet()) {
        customparameterMap.put(entry.getKey(),entry.getValue());
      }
    }
  }
  return customparameterMap;
}
Program: 105737
Project: 105737
Buggy source:
public Map<String,String> getDetails(){
  Map<String,String> customparameterMap=new HashMap<String,String>();
  if (details != null && details.size() != 0) {
    Collection parameterCollection=details.values();
    Iterator iter=parameterCollection.iterator();
    while (iter.hasNext()) {
      HashMap<String,String> value=(HashMap<String,String>)iter.next();
      for (      String key : value.keySet()) {
        customparameterMap.put(key,value.get(key));
      }
    }
  }
  return customparameterMap;
}

Fixed version (ground truth):
public Map<String,String> getDetails(){
  Map<String,String> customparameterMap=new HashMap<String,String>();
  if (details != null && details.size() != 0) {
    Collection parameterCollection=details.values();
    Iterator iter=parameterCollection.iterator();
    while (iter.hasNext()) {
      HashMap<String,String> value=(HashMap<String,String>)iter.next();
      for (      Map.Entry<String,String> entry : value.entrySet()) {
        customparameterMap.put(entry.getKey(),entry.getValue());
      }
    }
  }
  return customparameterMap;
}
Program: 105738
Project: 105738
Buggy source:
public void putContextParameters(Map<Object,Object> details){
  if (details == null)   return;
  for (  Object key : details.keySet()) {
    putContextParameter(key,details.get(key));
  }
}

Fixed version (ground truth):
public void putContextParameters(Map<Object,Object> details){
  if (details == null)   return;
  for (  Map.Entry<Object,Object> entry : details.entrySet()) {
    putContextParameter(entry.getKey(),entry.getValue());
  }
}
Program: 105739
Project: 105739
Buggy source:
protected AgentAttache(final AgentManagerImpl agentMgr,final long id,final String name,final boolean maintenance){
  _id=id;
  _name=name;
  _waitForList=new ConcurrentHashMap<Long,Listener>();
  _currentSequence=null;
  _maintenance=maintenance;
  _requests=new LinkedList<Request>();
  _agentMgr=agentMgr;
  _nextSequence=new Long(s_rand.nextInt(Short.MAX_VALUE)) << 48;
}

Fixed version (ground truth):
protected AgentAttache(final AgentManagerImpl agentMgr,final long id,final String name,final boolean maintenance){
  _id=id;
  _name=name;
  _waitForList=new ConcurrentHashMap<Long,Listener>();
  _currentSequence=null;
  _maintenance=maintenance;
  _requests=new LinkedList<Request>();
  _agentMgr=agentMgr;
  _nextSequence=new Long(s_rand.nextInt(Short.MAX_VALUE)).longValue() << 48;
}
Program: 105740
Project: 105740
Buggy source:
private VM createWorkingVM(Connection conn,String vmName,String guestOSType,List<VolumeObjectTO> listVolumeTo) throws BadServerResponse, Types.VmBadPowerState, Types.SrFull, Types.OperationNotAllowed, XenAPIException, XmlRpcException {
  String guestOsTypeName=getGuestOsType(guestOSType,false);
  if (guestOsTypeName == null) {
    String msg="String_Node_Str" + this.getClass().getName() + "String_Node_Str"+ guestOSType+ "String_Node_Str";
    s_logger.warn(msg);
    throw new CloudRuntimeException(msg);
  }
  VM template=getVM(conn,guestOsTypeName);
  VM vm=template.createClone(conn,vmName);
  vm.setIsATemplate(conn,false);
  Map<VDI,VolumeObjectTO> vdiMap=new HashMap<VDI,VolumeObjectTO>();
  for (  VolumeObjectTO volume : listVolumeTo) {
    String vdiUuid=volume.getPath();
    try {
      VDI vdi=VDI.getByUuid(conn,vdiUuid);
      vdiMap.put(vdi,volume);
    }
 catch (    Types.UuidInvalid e) {
      s_logger.warn("String_Node_Str" + vdiUuid + "String_Node_Str");
    }
  }
  for (  VDI vdi : vdiMap.keySet()) {
    VolumeObjectTO volumeTO=vdiMap.get(vdi);
    VBD.Record vbdr=new VBD.Record();
    vbdr.VM=vm;
    vbdr.VDI=vdi;
    if (volumeTO.getVolumeType() == Volume.Type.ROOT) {
      vbdr.bootable=true;
      vbdr.unpluggable=false;
    }
 else {
      vbdr.bootable=false;
      vbdr.unpluggable=true;
    }
    vbdr.userdevice=Long.toString(volumeTO.getDeviceId());
    vbdr.mode=Types.VbdMode.RW;
    vbdr.type=Types.VbdType.DISK;
    VBD.create(conn,vbdr);
  }
  return vm;
}

Fixed version (ground truth):
private VM createWorkingVM(Connection conn,String vmName,String guestOSType,List<VolumeObjectTO> listVolumeTo) throws BadServerResponse, Types.VmBadPowerState, Types.SrFull, Types.OperationNotAllowed, XenAPIException, XmlRpcException {
  String guestOsTypeName=getGuestOsType(guestOSType,false);
  if (guestOsTypeName == null) {
    String msg="String_Node_Str" + this.getClass().getName() + "String_Node_Str"+ guestOSType+ "String_Node_Str";
    s_logger.warn(msg);
    throw new CloudRuntimeException(msg);
  }
  VM template=getVM(conn,guestOsTypeName);
  VM vm=template.createClone(conn,vmName);
  vm.setIsATemplate(conn,false);
  Map<VDI,VolumeObjectTO> vdiMap=new HashMap<VDI,VolumeObjectTO>();
  for (  VolumeObjectTO volume : listVolumeTo) {
    String vdiUuid=volume.getPath();
    try {
      VDI vdi=VDI.getByUuid(conn,vdiUuid);
      vdiMap.put(vdi,volume);
    }
 catch (    Types.UuidInvalid e) {
      s_logger.warn("String_Node_Str" + vdiUuid + "String_Node_Str");
    }
  }
  for (  Map.Entry<VDI,VolumeObjectTO> entry : vdiMap.entrySet()) {
    VDI vdi=entry.getKey();
    VolumeObjectTO volumeTO=entry.getValue();
    VBD.Record vbdr=new VBD.Record();
    vbdr.VM=vm;
    vbdr.VDI=vdi;
    if (volumeTO.getVolumeType() == Volume.Type.ROOT) {
      vbdr.bootable=true;
      vbdr.unpluggable=false;
    }
 else {
      vbdr.bootable=false;
      vbdr.unpluggable=true;
    }
    vbdr.userdevice=Long.toString(volumeTO.getDeviceId());
    vbdr.mode=Types.VbdMode.RW;
    vbdr.type=Types.VbdType.DISK;
    VBD.create(conn,vbdr);
  }
  return vm;
}
Program: 105742
Project: 105742
Buggy source:
@Override public String toString(){
  StringBuilder sbuf=new StringBuilder("String_Node_Str");
  for (  HashMap<String,Pair<String,State>> clusterVM : _clusterVms.values()) {
    for (    String vmname : clusterVM.keySet()) {
      sbuf.append(vmname).append("String_Node_Str").append(clusterVM.get(vmname).second()).append("String_Node_Str");
    }
  }
  return sbuf.toString();
}

Fixed version (ground truth):
@Override public String toString(){
  StringBuilder sbuf=new StringBuilder("String_Node_Str");
  for (  HashMap<String,Pair<String,State>> clusterVM : _clusterVms.values()) {
    for (    Map.Entry<String,Pair<String,State>> entry : clusterVM.entrySet()) {
      String vmname=entry.getKey();
      Pair<String,State> vmstate=entry.getValue();
      sbuf.append(vmname).append("String_Node_Str").append(vmstate.second()).append("String_Node_Str");
    }
  }
  return sbuf.toString();
}
Program: 105743
Project: 105743
Buggy source:
@Override public boolean verifyServicesCombination(Set<Service> services){
  Set<Service> netscalerServices=new HashSet<Service>();
  netscalerServices.add(Service.Lb);
  netscalerServices.add(Service.StaticNat);
  if (services != null && !services.isEmpty() && !netscalerServices.containsAll(services)) {
    s_logger.warn("String_Node_Str" + services + "String_Node_Str");
    String servicesList="String_Node_Str";
    for (    Service service : services) {
      servicesList+=service.getName() + "String_Node_Str";
    }
    s_logger.warn("String_Node_Str" + servicesList + "String_Node_Str");
    s_logger.warn("String_Node_Str" + services + "String_Node_Str");
    return false;
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean verifyServicesCombination(Set<Service> services){
  Set<Service> netscalerServices=new HashSet<Service>();
  netscalerServices.add(Service.Lb);
  netscalerServices.add(Service.StaticNat);
  if (services != null && !services.isEmpty() && !netscalerServices.containsAll(services)) {
    s_logger.warn("String_Node_Str" + services + "String_Node_Str");
    StringBuffer buff=new StringBuffer();
    for (    Service service : services) {
      buff.append(service.getName());
      buff.append("String_Node_Str");
    }
    s_logger.warn("String_Node_Str" + buff.toString() + "String_Node_Str");
    s_logger.warn("String_Node_Str" + services + "String_Node_Str");
    return false;
  }
  return true;
}
Program: 105744
Project: 105744
Buggy source:
private String genObjectName(Object... args){
  String objectName="String_Node_Str";
  for (int i=0; i < args.length; i++) {
    objectName+=args[i];
    if (i != args.length - 1) {
      objectName+=_objectNamePathSep;
    }
  }
  return objectName;
}

Fixed version (ground truth):
private String genObjectName(Object... args){
  StringBuffer buff=new StringBuffer();
  for (int i=0; i < args.length; i++) {
    buff.append(args[i]);
    if (i != args.length - 1) {
      buff.append(_objectNamePathSep);
    }
  }
  return buff.toString();
}
Program: 105745
Project: 105745
Buggy source:
private static String genGslbObjectName(Object... args){
  String objectName="String_Node_Str";
  for (int i=0; i < args.length; i++) {
    objectName+=args[i];
    if (i != args.length - 1) {
      objectName+="String_Node_Str";
    }
  }
  return objectName;
}

Fixed version (ground truth):
private static String genGslbObjectName(Object... args){
  StringBuffer buff=new StringBuffer();
  for (int i=0; i < args.length; i++) {
    buff.append(args[i]);
    if (i != args.length - 1) {
      buff.append("String_Node_Str");
    }
  }
  return buff.toString();
}
Program: 105746
Project: 105746
Buggy source:
public Integer getPort(){
  return port <= 0 ? 389 : port;
}

Fixed version (ground truth):
public Integer getPort(){
  return (Integer)(port.intValue() <= 0 ? 389 : port.intValue());
}
Program: 105750
Project: 105750
Buggy source:
private void doAccessChecks(BaseCmd cmd,Map<Object,AccessType> entitiesToAccess){
  Account caller=CallContext.current().getCallingAccount();
  Account owner=_accountMgr.getActiveAccountById(cmd.getEntityOwnerId());
  if (cmd instanceof BaseAsyncCreateCmd) {
    _accountMgr.checkAccess(caller,null,true,owner);
  }
  if (!entitiesToAccess.isEmpty()) {
    _accountMgr.checkAccess(caller,null,true,owner);
    for (    Object entity : entitiesToAccess.keySet()) {
      if (entity instanceof ControlledEntity) {
        _accountMgr.checkAccess(caller,entitiesToAccess.get(entity),true,(ControlledEntity)entity);
      }
 else       if (entity instanceof InfrastructureEntity) {
      }
    }
  }
}

Fixed version (ground truth):
private void doAccessChecks(BaseCmd cmd,Map<Object,AccessType> entitiesToAccess){
  Account caller=CallContext.current().getCallingAccount();
  Account owner=_accountMgr.getActiveAccountById(cmd.getEntityOwnerId());
  if (cmd instanceof BaseAsyncCreateCmd) {
    _accountMgr.checkAccess(caller,null,true,owner);
  }
  if (!entitiesToAccess.isEmpty()) {
    _accountMgr.checkAccess(caller,null,true,owner);
    for (    Map.Entry<Object,AccessType> entry : entitiesToAccess.entrySet()) {
      Object entity=entry.getKey();
      if (entity instanceof ControlledEntity) {
        _accountMgr.checkAccess(caller,entry.getValue(),true,(ControlledEntity)entity);
      }
 else       if (entity instanceof InfrastructureEntity) {
      }
    }
  }
}
Program: 105752
Project: 105752
Buggy source:
protected List<DomainRouterVO> startRouters(final Map<Param,Object> params,final List<DomainRouterVO> routers) throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
  List<DomainRouterVO> runningRouters=null;
  if (routers != null) {
    runningRouters=new ArrayList<DomainRouterVO>();
  }
  for (  DomainRouterVO router : routers) {
    boolean skip=false;
    final State state=router.getState();
    if (router.getHostId() != null && state != State.Running) {
      final HostVO host=_hostDao.findById(router.getHostId());
      if (host == null || host.getState() != Status.Up) {
        skip=true;
      }
    }
    if (!skip) {
      if (state != State.Running) {
        router=startVirtualRouter(router,_accountMgr.getSystemUser(),_accountMgr.getSystemAccount(),params);
      }
      if (router != null) {
        runningRouters.add(router);
      }
    }
  }
  return runningRouters;
}

Fixed version (ground truth):
protected List<DomainRouterVO> startRouters(final Map<Param,Object> params,final List<DomainRouterVO> routers) throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
  List<DomainRouterVO> runningRouters=new ArrayList<DomainRouterVO>();
  for (  DomainRouterVO router : routers) {
    boolean skip=false;
    final State state=router.getState();
    if (router.getHostId() != null && state != State.Running) {
      final HostVO host=_hostDao.findById(router.getHostId());
      if (host == null || host.getState() != Status.Up) {
        skip=true;
      }
    }
    if (!skip) {
      if (state != State.Running) {
        router=startVirtualRouter(router,_accountMgr.getSystemUser(),_accountMgr.getSystemAccount(),params);
      }
      if (router != null) {
        runningRouters.add(router);
      }
    }
  }
  return runningRouters;
}
Program: 105753
Project: 105753
Buggy source:
private void createApplyStaticNatRulesCommands(final List<? extends StaticNatRule> rules,final VirtualRouter router,final Commands cmds,final long guestNetworkId){
  List<StaticNatRuleTO> rulesTO=null;
  if (rules != null) {
    rulesTO=new ArrayList<StaticNatRuleTO>();
    for (    final StaticNatRule rule : rules) {
      final IpAddress sourceIp=_networkModel.getIp(rule.getSourceIpAddressId());
      final StaticNatRuleTO ruleTO=new StaticNatRuleTO(rule,null,sourceIp.getAddress().addr(),rule.getDestIpAddress());
      rulesTO.add(ruleTO);
    }
  }
  final SetStaticNatRulesCommand cmd=new SetStaticNatRulesCommand(rulesTO,router.getVpcId());
  cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP,getRouterControlIp(router.getId()));
  cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP,getRouterIpInNetwork(guestNetworkId,router.getId()));
  cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME,router.getInstanceName());
  final DataCenterVO dcVo=_dcDao.findById(router.getDataCenterId());
  cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE,dcVo.getNetworkType().toString());
  cmds.addCommand(cmd);
}

Fixed version (ground truth):
private void createApplyStaticNatRulesCommands(final List<? extends StaticNatRule> rules,final VirtualRouter router,final Commands cmds,final long guestNetworkId){
  List<StaticNatRuleTO> rulesTO=new ArrayList<StaticNatRuleTO>();
  if (rules != null) {
    for (    final StaticNatRule rule : rules) {
      final IpAddress sourceIp=_networkModel.getIp(rule.getSourceIpAddressId());
      final StaticNatRuleTO ruleTO=new StaticNatRuleTO(rule,null,sourceIp.getAddress().addr(),rule.getDestIpAddress());
      rulesTO.add(ruleTO);
    }
  }
  final SetStaticNatRulesCommand cmd=new SetStaticNatRulesCommand(rulesTO,router.getVpcId());
  cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP,getRouterControlIp(router.getId()));
  cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP,getRouterIpInNetwork(guestNetworkId,router.getId()));
  cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME,router.getInstanceName());
  final DataCenterVO dcVo=_dcDao.findById(router.getDataCenterId());
  cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE,dcVo.getNetworkType().toString());
  cmds.addCommand(cmd);
}
Program: 105754
Project: 105754
Buggy source:
private void createApplyPortForwardingRulesCommands(final List<? extends PortForwardingRule> rules,final VirtualRouter router,final Commands cmds,final long guestNetworkId){
  List<PortForwardingRuleTO> rulesTO=null;
  if (rules != null) {
    rulesTO=new ArrayList<PortForwardingRuleTO>();
    for (    final PortForwardingRule rule : rules) {
      final IpAddress sourceIp=_networkModel.getIp(rule.getSourceIpAddressId());
      final PortForwardingRuleTO ruleTO=new PortForwardingRuleTO(rule,null,sourceIp.getAddress().addr());
      rulesTO.add(ruleTO);
    }
  }
  SetPortForwardingRulesCommand cmd=null;
  if (router.getVpcId() != null) {
    cmd=new SetPortForwardingRulesVpcCommand(rulesTO);
  }
 else {
    cmd=new SetPortForwardingRulesCommand(rulesTO);
  }
  cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP,getRouterControlIp(router.getId()));
  cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP,getRouterIpInNetwork(guestNetworkId,router.getId()));
  cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME,router.getInstanceName());
  final DataCenterVO dcVo=_dcDao.findById(router.getDataCenterId());
  cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE,dcVo.getNetworkType().toString());
  cmds.addCommand(cmd);
}

Fixed version (ground truth):
private void createApplyPortForwardingRulesCommands(final List<? extends PortForwardingRule> rules,final VirtualRouter router,final Commands cmds,final long guestNetworkId){
  List<PortForwardingRuleTO> rulesTO=new ArrayList<PortForwardingRuleTO>();
  if (rules != null) {
    for (    final PortForwardingRule rule : rules) {
      final IpAddress sourceIp=_networkModel.getIp(rule.getSourceIpAddressId());
      final PortForwardingRuleTO ruleTO=new PortForwardingRuleTO(rule,null,sourceIp.getAddress().addr());
      rulesTO.add(ruleTO);
    }
  }
  SetPortForwardingRulesCommand cmd=null;
  if (router.getVpcId() != null) {
    cmd=new SetPortForwardingRulesVpcCommand(rulesTO);
  }
 else {
    cmd=new SetPortForwardingRulesCommand(rulesTO);
  }
  cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP,getRouterControlIp(router.getId()));
  cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP,getRouterIpInNetwork(guestNetworkId,router.getId()));
  cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME,router.getInstanceName());
  final DataCenterVO dcVo=_dcDao.findById(router.getDataCenterId());
  cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE,dcVo.getNetworkType().toString());
  cmds.addCommand(cmd);
}
Program: 105755
Project: 105755
Buggy source:
@Override @ActionEvent(eventType=EventTypes.EVENT_ROUTER_STOP,eventDescription="String_Node_Str",async=true) public VirtualRouter stopRouter(final long routerId,final boolean forced) throws ResourceUnavailableException, ConcurrentOperationException {
  final CallContext context=CallContext.current();
  final Account account=context.getCallingAccount();
  DomainRouterVO router=_routerDao.findById(routerId);
  if (router == null) {
    throw new InvalidParameterValueException("String_Node_Str" + routerId + "String_Node_Str");
  }
  _accountMgr.checkAccess(account,null,true,router);
  final UserVO user=_userDao.findById(CallContext.current().getCallingUserId());
  final VirtualRouter virtualRouter=stop(router,forced,user,account);
  if (virtualRouter == null) {
    throw new CloudRuntimeException("String_Node_Str" + routerId);
  }
  if (router.isStopPending()) {
    s_logger.info("String_Node_Str" + router.getHostName() + "String_Node_Str");
    router.setStopPending(false);
    router=_routerDao.persist(router);
    virtualRouter.setStopPending(false);
  }
  return virtualRouter;
}

Fixed version (ground truth):
@Override @ActionEvent(eventType=EventTypes.EVENT_ROUTER_STOP,eventDescription="String_Node_Str",async=true) public VirtualRouter stopRouter(final long routerId,final boolean forced) throws ResourceUnavailableException, ConcurrentOperationException {
  final CallContext context=CallContext.current();
  final Account account=context.getCallingAccount();
  DomainRouterVO router=_routerDao.findById(routerId);
  if (router == null) {
    throw new InvalidParameterValueException("String_Node_Str" + routerId + "String_Node_Str");
  }
  _accountMgr.checkAccess(account,null,true,router);
  final UserVO user=_userDao.findById(CallContext.current().getCallingUserId());
  final VirtualRouter virtualRouter=stop(router,forced,user,account);
  if (virtualRouter == null) {
    throw new CloudRuntimeException("String_Node_Str" + routerId);
  }
  if (router.isStopPending()) {
    s_logger.info("String_Node_Str" + router.getHostName() + "String_Node_Str");
    router.setStopPending(false);
    _routerDao.persist(router);
    virtualRouter.setStopPending(false);
  }
  return virtualRouter;
}