nus-yam/ex-repair huggingface dataset:
Program: 105756
Project: 105756
Buggy source:
private void createApplyStaticNatCommands(final List<? extends StaticNat> rules,final VirtualRouter router,final Commands cmds,final long guestNetworkId){
  List<StaticNatRuleTO> rulesTO=null;
  if (rules != null) {
    rulesTO=new ArrayList<StaticNatRuleTO>();
    for (    final StaticNat rule : rules) {
      final IpAddress sourceIp=_networkModel.getIp(rule.getSourceIpAddressId());
      final StaticNatRuleTO ruleTO=new StaticNatRuleTO(0,sourceIp.getAddress().addr(),null,null,rule.getDestIpAddress(),null,null,null,rule.isForRevoke(),false);
      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 createApplyStaticNatCommands(final List<? extends StaticNat> rules,final VirtualRouter router,final Commands cmds,final long guestNetworkId){
  List<StaticNatRuleTO> rulesTO=new ArrayList<StaticNatRuleTO>();
  if (rules != null) {
    for (    final StaticNat rule : rules) {
      final IpAddress sourceIp=_networkModel.getIp(rule.getSourceIpAddressId());
      final StaticNatRuleTO ruleTO=new StaticNatRuleTO(0,sourceIp.getAddress().addr(),null,null,rule.getDestIpAddress(),null,null,null,rule.isForRevoke(),false);
      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: 105759
Project: 105759
Buggy source:
/** 
 * Once a guest network has been designed, virtual machines can be created.  allocated() is called for the NetworkGuru to design a nic that will make the virtual machine work within the guest network.
 * @param network guest network that the virtual machine will be deployed in.
 * @param nic nic information that the end user wants to set.  TheNetworkGuru should check this information with the guest network settings to make sure everything will work.
 * @param vm virtual machine that is about to be deployed.
 * @return NicProfile nic with all of the information
 * @throws InsufficientVirtualNetworkCapcityException if there'sinsufficient capacity within the guest network.
 * @throws InsufficientAddressCapacityException if there are not addressesto be assigned.
 */
NicProfile allocate(Network network,NicProfile nic,VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException ;

Fixed version (ground truth):
/** 
 * Once a guest network has been designed, virtual machines can be created.  allocated() is called for the NetworkGuru to design a nic that will make the virtual machine work within the guest network.
 * @param network guest network that the virtual machine will be deployed in.
 * @param nic nic information that the end user wants to set.  TheNetworkGuru should check this information with the guest network settings to make sure everything will work.
 * @param vm virtual machine that is about to be deployed.
 * @return NicProfile nic with all of the information
 * @throws InsufficientVirtualNetworkCapacityException if there'sinsufficient capacity within the guest network.
 * @throws InsufficientAddressCapacityException if there are not addressesto be assigned.
 */
NicProfile allocate(Network network,NicProfile nic,VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException ;
Program: 105760
Project: 105760
Buggy source:
/** 
 * Once a guest network is implemented, then the virtual machine must be allocated its resources in order for it to participate within the guest network.  reserve() is called for the NetworkGuru to make sure that works.
 * @param nic nic that the vm is using to access the guest network.
 * @param network guest network the vm is in.
 * @param vm vm
 * @param dest destination the vm is deployed to
 * @param context Reservation context from which to get the owner, caller, and reservation id
 * @throws InsufficientVirtualNetworkCapcityException if there's not enoughresources.
 * @throws InsufficientAddressCapacityException if there's not enough ipaddresses.
 * @throws ConcurrentOperationException if there are multiple operationshappening on this guest network or vm.
 */
void reserve(NicProfile nic,Network network,VirtualMachineProfile vm,DeployDestination dest,ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException ;

Fixed version (ground truth):
/** 
 * Once a guest network is implemented, then the virtual machine must be allocated its resources in order for it to participate within the guest network.  reserve() is called for the NetworkGuru to make sure that works.
 * @param nic nic that the vm is using to access the guest network.
 * @param network guest network the vm is in.
 * @param vm vm
 * @param dest destination the vm is deployed to
 * @param context Reservation context from which to get the owner, caller, and reservation id
 * @throws InsufficientVirtualNetworkCapacityException if there's not enoughresources.
 * @throws InsufficientAddressCapacityException if there's not enough ipaddresses.
 * @throws ConcurrentOperationException if there are multiple operationshappening on this guest network or vm.
 */
void reserve(NicProfile nic,Network network,VirtualMachineProfile vm,DeployDestination dest,ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException ;
Program: 105761
Project: 105761
Buggy source:
/** 
 * For guest networks that are in Allocated state after the design stage, resources are allocated when the guest network is actually being used by a virtual machine.  implement() is called to acquire those resources.
 * @param network network to be implemented.
 * @param offering network offering that the network was created with.
 * @param destination where the network is being deployed in.
 * @return a fully implemented Network.
 * @throws InsufficientVirtualNetworkCapcityException  if there's notenough resources to make the guest network usable in the physical environment.  At this time, the admin generally must be involved to allocate more resources before any more guest network can be implemented.
 */
Network implement(Network network,NetworkOffering offering,DeployDestination destination,ReservationContext context) throws InsufficientVirtualNetworkCapcityException ;

Fixed version (ground truth):
/** 
 * For guest networks that are in Allocated state after the design stage, resources are allocated when the guest network is actually being used by a virtual machine.  implement() is called to acquire those resources.
 * @param network network to be implemented.
 * @param offering network offering that the network was created with.
 * @param destination where the network is being deployed in.
 * @return a fully implemented Network.
 * @throws InsufficientVirtualNetworkCapacityException  if there's notenough resources to make the guest network usable in the physical environment.  At this time, the admin generally must be involved to allocate more resources before any more guest network can be implemented.
 */
Network implement(Network network,NetworkOffering offering,DeployDestination destination,ReservationContext context) throws InsufficientVirtualNetworkCapacityException ;
Program: 105762
Project: 105762
Buggy source:
@Override public void create(){
  try {
    ApplicationLoadBalancerRule result=_appLbService.createApplicationLoadBalancer(getName(),getDescription(),getScheme(),getSourceIpNetworkId(),getSourceIp(),getSourcePort(),getInstancePort(),getAlgorithm(),getNetworkId(),getEntityOwnerId(),getDisplay());
    this.setEntityId(result.getId());
    this.setEntityUuid(result.getUuid());
  }
 catch (  NetworkRuleConflictException e) {
    s_logger.warn("String_Node_Str",e);
    throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR,e.getMessage());
  }
catch (  InsufficientAddressCapacityException e) {
    s_logger.warn("String_Node_Str",e);
    throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR,e.getMessage());
  }
catch (  InsufficientVirtualNetworkCapcityException e) {
    s_logger.warn("String_Node_Str",e);
    throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR,e.getMessage());
  }
}

Fixed version (ground truth):
@Override public void create(){
  try {
    ApplicationLoadBalancerRule result=_appLbService.createApplicationLoadBalancer(getName(),getDescription(),getScheme(),getSourceIpNetworkId(),getSourceIp(),getSourcePort(),getInstancePort(),getAlgorithm(),getNetworkId(),getEntityOwnerId(),getDisplay());
    this.setEntityId(result.getId());
    this.setEntityUuid(result.getUuid());
  }
 catch (  NetworkRuleConflictException e) {
    s_logger.warn("String_Node_Str",e);
    throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR,e.getMessage());
  }
catch (  InsufficientAddressCapacityException e) {
    s_logger.warn("String_Node_Str",e);
    throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR,e.getMessage());
  }
catch (  InsufficientVirtualNetworkCapacityException e) {
    s_logger.warn("String_Node_Str",e);
    throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR,e.getMessage());
  }
}
Program: 105763
Project: 105763
Buggy source:
ApplicationLoadBalancerRule createApplicationLoadBalancer(String name,String description,Scheme scheme,long sourceIpNetworkId,String sourceIp,int sourcePort,int instancePort,String algorithm,long networkId,long lbOwnerId,Boolean forDisplay) throws InsufficientAddressCapacityException, NetworkRuleConflictException, InsufficientVirtualNetworkCapcityException ;

Fixed version (ground truth):
ApplicationLoadBalancerRule createApplicationLoadBalancer(String name,String description,Scheme scheme,long sourceIpNetworkId,String sourceIp,int sourcePort,int instancePort,String algorithm,long networkId,long lbOwnerId,Boolean forDisplay) throws InsufficientAddressCapacityException, NetworkRuleConflictException, InsufficientVirtualNetworkCapacityException ;
Program: 105764
Project: 105764
Buggy source:
/** 
 * @param requested
 * @param network
 * @param isDefaultNic
 * @param deviceId
 * @param vm
 * @return
 * @throws InsufficientVirtualNetworkCapcityException
 * @throws InsufficientAddressCapacityException
 * @throws ConcurrentOperationException
 */
Pair<NicProfile,Integer> allocateNic(NicProfile requested,Network network,Boolean isDefaultNic,int deviceId,VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException ;

Fixed version (ground truth):
/** 
 * @param requested
 * @param network
 * @param isDefaultNic
 * @param deviceId
 * @param vm
 * @return
 * @throws InsufficientVirtualNetworkCapacityException
 * @throws InsufficientAddressCapacityException
 * @throws ConcurrentOperationException
 */
Pair<NicProfile,Integer> allocateNic(NicProfile requested,Network network,Boolean isDefaultNic,int deviceId,VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException ;
Program: 105765
Project: 105765
Buggy source:
/** 
 * @param vmProfile
 * @param dest
 * @param context
 * @param nicId
 * @param network
 * @return
 * @throws InsufficientVirtualNetworkCapcityException
 * @throws InsufficientAddressCapacityException
 * @throws ConcurrentOperationException
 * @throws InsufficientCapacityException
 * @throws ResourceUnavailableException
 */
NicProfile prepareNic(VirtualMachineProfile vmProfile,DeployDestination dest,ReservationContext context,long nicId,Network network) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException ;

Fixed version (ground truth):
/** 
 * @param vmProfile
 * @param dest
 * @param context
 * @param nicId
 * @param network
 * @return
 * @throws InsufficientVirtualNetworkCapacityException
 * @throws InsufficientAddressCapacityException
 * @throws ConcurrentOperationException
 * @throws InsufficientCapacityException
 * @throws ResourceUnavailableException
 */
NicProfile prepareNic(VirtualMachineProfile vmProfile,DeployDestination dest,ReservationContext context,long nicId,Network network) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException ;
Program: 105766
Project: 105766
Buggy source:
NicProfile createNicForVm(Network network,NicProfile requested,ReservationContext context,VirtualMachineProfile vmProfile,boolean prepare) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException ;

Fixed version (ground truth):
NicProfile createNicForVm(Network network,NicProfile requested,ReservationContext context,VirtualMachineProfile vmProfile,boolean prepare) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException ;
Program: 105767
Project: 105767
Buggy source:
void allocateDirectIp(NicProfile nic,DataCenter dc,VirtualMachineProfile vm,Network network,String requestedIpv4,String requestedIpv6) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException ;

Fixed version (ground truth):
void allocateDirectIp(NicProfile nic,DataCenter dc,VirtualMachineProfile vm,Network network,String requestedIpv4,String requestedIpv6) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException ;
Program: 105769
Project: 105769
Buggy source:
@DB @Override public Pair<NicProfile,Integer> allocateNic(NicProfile requested,Network network,Boolean isDefaultNic,int deviceId,VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
  NetworkVO ntwkVO=_networksDao.findById(network.getId());
  s_logger.debug("String_Node_Str" + vm.getVirtualMachine() + "String_Node_Str"+ network+ "String_Node_Str"+ requested);
  NetworkGuru guru=AdapterBase.getAdapterByName(networkGurus,ntwkVO.getGuruName());
  if (requested != null && requested.getMode() == null) {
    requested.setMode(network.getMode());
  }
  NicProfile profile=guru.allocate(network,requested,vm);
  if (profile == null) {
    return null;
  }
  if (isDefaultNic != null) {
    profile.setDefaultNic(isDefaultNic);
  }
  if (requested != null && requested.getMode() == null) {
    profile.setMode(requested.getMode());
  }
 else {
    profile.setMode(network.getMode());
  }
  NicVO vo=new NicVO(guru.getName(),vm.getId(),network.getId(),vm.getType());
  deviceId=applyProfileToNic(vo,profile,deviceId);
  vo=_nicDao.persist(vo);
  Integer networkRate=_networkModel.getNetworkRate(network.getId(),vm.getId());
  NicProfile vmNic=new NicProfile(vo,network,vo.getBroadcastUri(),vo.getIsolationUri(),networkRate,_networkModel.isSecurityGroupSupportedInNetwork(network),_networkModel.getNetworkTag(vm.getHypervisorType(),network));
  return new Pair<NicProfile,Integer>(vmNic,Integer.valueOf(deviceId));
}

Fixed version (ground truth):
@DB @Override public Pair<NicProfile,Integer> allocateNic(NicProfile requested,Network network,Boolean isDefaultNic,int deviceId,VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException {
  NetworkVO ntwkVO=_networksDao.findById(network.getId());
  s_logger.debug("String_Node_Str" + vm.getVirtualMachine() + "String_Node_Str"+ network+ "String_Node_Str"+ requested);
  NetworkGuru guru=AdapterBase.getAdapterByName(networkGurus,ntwkVO.getGuruName());
  if (requested != null && requested.getMode() == null) {
    requested.setMode(network.getMode());
  }
  NicProfile profile=guru.allocate(network,requested,vm);
  if (profile == null) {
    return null;
  }
  if (isDefaultNic != null) {
    profile.setDefaultNic(isDefaultNic);
  }
  if (requested != null && requested.getMode() == null) {
    profile.setMode(requested.getMode());
  }
 else {
    profile.setMode(network.getMode());
  }
  NicVO vo=new NicVO(guru.getName(),vm.getId(),network.getId(),vm.getType());
  deviceId=applyProfileToNic(vo,profile,deviceId);
  vo=_nicDao.persist(vo);
  Integer networkRate=_networkModel.getNetworkRate(network.getId(),vm.getId());
  NicProfile vmNic=new NicProfile(vo,network,vo.getBroadcastUri(),vo.getIsolationUri(),networkRate,_networkModel.isSecurityGroupSupportedInNetwork(network),_networkModel.getNetworkTag(vm.getHypervisorType(),network));
  return new Pair<NicProfile,Integer>(vmNic,Integer.valueOf(deviceId));
}
Program: 105770
Project: 105770
Buggy source:
@Override public NicProfile createNicForVm(Network network,NicProfile requested,ReservationContext context,VirtualMachineProfile vmProfile,boolean prepare) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
  VirtualMachine vm=vmProfile.getVirtualMachine();
  DataCenter dc=_entityMgr.findById(DataCenter.class,network.getDataCenterId());
  Host host=_hostDao.findById(vm.getHostId());
  DeployDestination dest=new DeployDestination(dc,null,null,host);
  NicProfile nic=getNicProfileForVm(network,requested,vm);
  if (nic == null || (vmProfile.getType() == VirtualMachine.Type.User)) {
    int deviceId=_nicDao.countNics(vm.getId());
    nic=allocateNic(requested,network,false,deviceId,vmProfile).first();
    if (nic == null) {
      throw new CloudRuntimeException("String_Node_Str" + vm + "String_Node_Str"+ network);
    }
    s_logger.debug("String_Node_Str" + vm + "String_Node_Str"+ network);
  }
  if (prepare) {
    Pair<NetworkGuru,NetworkVO> implemented=implementNetwork(nic.getNetworkId(),dest,context);
    nic=prepareNic(vmProfile,dest,context,nic.getId(),implemented.second());
    s_logger.debug("String_Node_Str" + vm + "String_Node_Str"+ network);
  }
  return nic;
}

Fixed version (ground truth):
@Override public NicProfile createNicForVm(Network network,NicProfile requested,ReservationContext context,VirtualMachineProfile vmProfile,boolean prepare) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
  VirtualMachine vm=vmProfile.getVirtualMachine();
  DataCenter dc=_entityMgr.findById(DataCenter.class,network.getDataCenterId());
  Host host=_hostDao.findById(vm.getHostId());
  DeployDestination dest=new DeployDestination(dc,null,null,host);
  NicProfile nic=getNicProfileForVm(network,requested,vm);
  if (nic == null || (vmProfile.getType() == VirtualMachine.Type.User)) {
    int deviceId=_nicDao.countNics(vm.getId());
    nic=allocateNic(requested,network,false,deviceId,vmProfile).first();
    if (nic == null) {
      throw new CloudRuntimeException("String_Node_Str" + vm + "String_Node_Str"+ network);
    }
    s_logger.debug("String_Node_Str" + vm + "String_Node_Str"+ network);
  }
  if (prepare) {
    Pair<NetworkGuru,NetworkVO> implemented=implementNetwork(nic.getNetworkId(),dest,context);
    nic=prepareNic(vmProfile,dest,context,nic.getId(),implemented.second());
    s_logger.debug("String_Node_Str" + vm + "String_Node_Str"+ network);
  }
  return nic;
}
Program: 105771
Project: 105771
Buggy source:
private void getBaremetalIp(NicProfile nic,Pod pod,VirtualMachineProfile vm,Network network,String requiredIp) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
  DataCenter dc=_dcDao.findById(pod.getDataCenterId());
  if (nic.getIp4Address() == null) {
    s_logger.debug(String.format("String_Node_Str",nic.getIp4Address()));
    PublicIp ip=_ipAddrMgr.assignPublicIpAddress(dc.getId(),pod.getId(),vm.getOwner(),VlanType.DirectAttached,network.getId(),requiredIp,false);
    nic.setIp4Address(ip.getAddress().toString());
    nic.setFormat(AddressFormat.Ip4);
    nic.setGateway(ip.getGateway());
    nic.setNetmask(ip.getNetmask());
    if (ip.getVlanTag() != null && ip.getVlanTag().equalsIgnoreCase(Vlan.UNTAGGED)) {
      nic.setIsolationUri(IsolationType.Ec2.toUri(Vlan.UNTAGGED));
      nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED));
      nic.setBroadcastType(BroadcastDomainType.Native);
    }
    nic.setReservationId(String.valueOf(ip.getVlanTag()));
    nic.setMacAddress(ip.getMacAddress());
  }
  nic.setDns1(dc.getDns1());
  nic.setDns2(dc.getDns2());
}

Fixed version (ground truth):
private void getBaremetalIp(NicProfile nic,Pod pod,VirtualMachineProfile vm,Network network,String requiredIp) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException {
  DataCenter dc=_dcDao.findById(pod.getDataCenterId());
  if (nic.getIp4Address() == null) {
    s_logger.debug(String.format("String_Node_Str",nic.getIp4Address()));
    PublicIp ip=_ipAddrMgr.assignPublicIpAddress(dc.getId(),pod.getId(),vm.getOwner(),VlanType.DirectAttached,network.getId(),requiredIp,false);
    nic.setIp4Address(ip.getAddress().toString());
    nic.setFormat(AddressFormat.Ip4);
    nic.setGateway(ip.getGateway());
    nic.setNetmask(ip.getNetmask());
    if (ip.getVlanTag() != null && ip.getVlanTag().equalsIgnoreCase(Vlan.UNTAGGED)) {
      nic.setIsolationUri(IsolationType.Ec2.toUri(Vlan.UNTAGGED));
      nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED));
      nic.setBroadcastType(BroadcastDomainType.Native);
    }
    nic.setReservationId(String.valueOf(ip.getVlanTag()));
    nic.setMacAddress(ip.getMacAddress());
  }
  nic.setDns1(dc.getDns1());
  nic.setDns2(dc.getDns2());
}
Program: 105773
Project: 105773
Buggy source:
@Override public void reserve(NicProfile nic,Network network,VirtualMachineProfile vm,DeployDestination dest,ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
  super.reserve(nic,network,vm,dest,context);
}

Fixed version (ground truth):
@Override public void reserve(NicProfile nic,Network network,VirtualMachineProfile vm,DeployDestination dest,ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException {
  super.reserve(nic,network,vm,dest,context);
}
Program: 105774
Project: 105774
Buggy source:
@Override public Network implement(Network network,NetworkOffering offering,DeployDestination dest,ReservationContext context) throws InsufficientVirtualNetworkCapcityException {
}

Fixed version (ground truth):
@Override public Network implement(Network network,NetworkOffering offering,DeployDestination dest,ReservationContext context) throws InsufficientVirtualNetworkCapacityException {
}
Program: 105775
Project: 105775
Buggy source:
protected VDI prepareManagedStorage(Connection conn,Map<String,String> details,String path,String vdiNameLabel) throws Exception {
  SR sr=prepareManagedSr(conn,details);
  VDI vdi=getVDIbyUuid(conn,path,false);
  Long volumeSize=Long.parseLong(details.get(DiskTO.VOLUME_SIZE));
  if (vdi == null) {
    vdi=createVdi(sr,vdiNameLabel,volumeSize);
  }
 else {
    s_logger.info("String_Node_Str");
    long vdiVirtualsize=vdi.getVirtualSize(conn);
    if (vdiVirtualsize != volumeSize) {
      s_logger.info("String_Node_Str" + vdiVirtualsize + "String_Node_Str"+ volumeSize);
      try {
        vdi.resize(conn,volumeSize);
      }
 catch (      Exception e) {
        s_logger.warn("String_Node_Str",e);
      }
    }
  }
  return vdi;
}

Fixed version (ground truth):
protected VDI prepareManagedStorage(Connection conn,Map<String,String> details,String path,String vdiNameLabel) throws Exception {
  SR sr=prepareManagedSr(conn,details);
  VDI vdi=getVDIbyUuid(conn,path,false);
  Long volumeSize=Long.parseLong(details.get(DiskTO.VOLUME_SIZE));
  if (vdi == null) {
    vdi=createVdi(sr,vdiNameLabel,volumeSize);
  }
 else {
    s_logger.info("String_Node_Str");
    long vdiVirtualSize=vdi.getVirtualSize(conn);
    if (vdiVirtualSize != volumeSize) {
      s_logger.info("String_Node_Str" + vdiVirtualSize + "String_Node_Str"+ volumeSize);
      try {
        vdi.resize(conn,volumeSize);
      }
 catch (      Exception e) {
        s_logger.warn("String_Node_Str",e);
      }
    }
  }
  return vdi;
}
Program: 105776
Project: 105776
Buggy source:
@Override public void execute(){
  LoadBalancer lb=null;
  if (lbRuleId == null && id == null) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  if (id != null) {
    lb=_lbService.findLbByStickinessId(id);
    if (lb == null) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if ((lbRuleId != null) && (lbRuleId != lb.getId())) {
      throw new InvalidParameterValueException("String_Node_Str" + lbRuleId);
    }
  }
  if (lbRuleId != null && lb != null) {
    lb=_lbService.findById(getLbRuleId());
  }
  List<LBStickinessResponse> spResponses=new ArrayList<LBStickinessResponse>();
  ListResponse<LBStickinessResponse> response=new ListResponse<LBStickinessResponse>();
  if (lb != null) {
    Account caller=CallContext.current().getCallingAccount();
    _accountService.checkAccess(caller,null,true,lb);
    List<? extends StickinessPolicy> stickinessPolicies=_lbService.searchForLBStickinessPolicies(this);
    LBStickinessResponse spResponse=_responseGenerator.createLBStickinessPolicyResponse(stickinessPolicies,lb);
    spResponses.add(spResponse);
    response.setResponses(spResponses);
  }
  response.setResponseName(getCommandName());
  this.setResponseObject(response);
}

Fixed version (ground truth):
@Override public void execute(){
  LoadBalancer lb=null;
  if (lbRuleId == null && id == null) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  if (id != null) {
    lb=_lbService.findLbByStickinessId(id);
    if (lb == null) {
      throw new InvalidParameterValueException("String_Node_Str");
    }
    if ((lbRuleId != null) && (lbRuleId != lb.getId())) {
      throw new InvalidParameterValueException("String_Node_Str" + lbRuleId);
    }
  }
  if (lbRuleId != null && lb == null) {
    lb=_lbService.findById(getLbRuleId());
  }
  List<LBStickinessResponse> spResponses=new ArrayList<LBStickinessResponse>();
  ListResponse<LBStickinessResponse> response=new ListResponse<LBStickinessResponse>();
  if (lb != null) {
    Account caller=CallContext.current().getCallingAccount();
    _accountService.checkAccess(caller,null,true,lb);
    List<? extends StickinessPolicy> stickinessPolicies=_lbService.searchForLBStickinessPolicies(this);
    LBStickinessResponse spResponse=_responseGenerator.createLBStickinessPolicyResponse(stickinessPolicies,lb);
    spResponses.add(spResponse);
    response.setResponses(spResponses);
  }
  response.setResponseName(getCommandName());
  this.setResponseObject(response);
}
Program: 105778
Project: 105778
Buggy source:
@Override public List<Long> listPodIdsHavingVmsforAccount(long zoneId,long accountId){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  PreparedStatement pstmt=null;
  List<Long> result=new ArrayList<Long>();
  try {
    String sql=LIST_PODS_HAVING_VMS_FOR_ACCOUNT;
    pstmt=txn.prepareAutoCloseStatement(sql);
    pstmt.setLong(1,zoneId);
    pstmt.setLong(2,accountId);
    ResultSet rs=pstmt.executeQuery();
    while (rs.next()) {
      result.add(rs.getLong(1));
    }
    return result;
  }
 catch (  SQLException e) {
    throw new CloudRuntimeException("String_Node_Str" + LIST_PODS_HAVING_VMS_FOR_ACCOUNT,e);
  }
catch (  Throwable e) {
    throw new CloudRuntimeException("String_Node_Str" + LIST_PODS_HAVING_VMS_FOR_ACCOUNT,e);
  }
}

Fixed version (ground truth):
@Override public List<Long> listPodIdsHavingVmsforAccount(long zoneId,long accountId){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  List<Long> result=new ArrayList<Long>();
  String sql=LIST_PODS_HAVING_VMS_FOR_ACCOUNT;
  try (PreparedStatement pstmt=txn.prepareStatement(sql)){
    pstmt.setLong(1,zoneId);
    pstmt.setLong(2,accountId);
    try (ResultSet rs=pstmt.executeQuery()){
      while (rs.next()) {
        result.add(rs.getLong(1));
      }
    }
 catch (    Exception e) {
      s_logger.error("String_Node_Str" + e.getMessage());
      throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
    }
    txn.commit();
    return result;
  }
 catch (  Exception e) {
    s_logger.error("String_Node_Str" + e.getMessage());
    throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
  }
 finally {
    try {
      if (txn != null) {
        txn.close();
      }
    }
 catch (    Exception e) {
      s_logger.error("String_Node_Str" + e.getMessage());
    }
  }
}
Program: 105782
Project: 105782
Buggy source:
@Override @DB @ActionEvent(eventType=EventTypes.EVENT_ZONE_DELETE,eventDescription="String_Node_Str",async=false) public boolean deleteZone(DeleteZoneCmd cmd){
  Long userId=CallContext.current().getCallingUserId();
  final Long zoneId=cmd.getId();
  if (userId == null) {
    userId=Long.valueOf(User.UID_SYSTEM);
  }
  if (!validZone(zoneId)) {
    throw new InvalidParameterValueException("String_Node_Str" + zoneId + "String_Node_Str");
  }
  checkIfZoneIsDeletable(zoneId);
  return Transaction.execute(new TransactionCallback<Boolean>(){
    @Override public Boolean doInTransaction(    TransactionStatus status){
      List<VlanVO> vlans=_vlanDao.listByZone(zoneId);
      for (      VlanVO vlan : vlans) {
        _vlanDao.remove(vlan.getId());
      }
      boolean success=_zoneDao.remove(zoneId);
      if (success) {
        _capacityDao.removeBy(null,zoneId,null,null,null);
        DedicatedResourceVO dr=_dedicatedDao.findByZoneId(zoneId);
        if (dr != null) {
          _dedicatedDao.remove(dr.getId());
          List<DedicatedResourceVO> resourcesInGroup=_dedicatedDao.listByAffinityGroupId(dr.getAffinityGroupId());
          if (resourcesInGroup.isEmpty()) {
            _affinityGroupService.deleteAffinityGroup(dr.getAffinityGroupId(),null,null,null);
          }
        }
      }
      return success;
    }
  }
);
}

Fixed version (ground truth):
@Override @DB @ActionEvent(eventType=EventTypes.EVENT_ZONE_DELETE,eventDescription="String_Node_Str",async=false) public boolean deleteZone(DeleteZoneCmd cmd){
  final Long zoneId=cmd.getId();
  if (!validZone(zoneId)) {
    throw new InvalidParameterValueException("String_Node_Str" + zoneId + "String_Node_Str");
  }
  checkIfZoneIsDeletable(zoneId);
  return Transaction.execute(new TransactionCallback<Boolean>(){
    @Override public Boolean doInTransaction(    TransactionStatus status){
      List<VlanVO> vlans=_vlanDao.listByZone(zoneId);
      for (      VlanVO vlan : vlans) {
        _vlanDao.remove(vlan.getId());
      }
      boolean success=_zoneDao.remove(zoneId);
      if (success) {
        _capacityDao.removeBy(null,zoneId,null,null,null);
        DedicatedResourceVO dr=_dedicatedDao.findByZoneId(zoneId);
        if (dr != null) {
          _dedicatedDao.remove(dr.getId());
          List<DedicatedResourceVO> resourcesInGroup=_dedicatedDao.listByAffinityGroupId(dr.getAffinityGroupId());
          if (resourcesInGroup.isEmpty()) {
            _affinityGroupService.deleteAffinityGroup(dr.getAffinityGroupId(),null,null,null);
          }
        }
      }
      return success;
    }
  }
);
}
Program: 105783
Project: 105783
Buggy source:
@Override @DB public boolean trash(Network network,NetworkOffering offering){
  final List<NicVO> nics=_nicDao.listPlaceholderNicsByNetworkId(network.getId());
  Transaction.execute(new TransactionCallbackNoReturn(){
    @Override public void doInTransactionWithoutResult(    TransactionStatus status){
      for (      Nic nic : nics) {
        if (nic.getIp4Address() != null) {
          s_logger.debug("String_Node_Str" + nic.getIp4Address() + "String_Node_Str"+ nic);
          IPAddressVO ip=_ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(),nic.getIp4Address());
          _ipAddrMgr.markIpAsUnavailable(ip.getId());
          _ipAddressDao.unassignIpAddress(ip.getId());
          s_logger.debug("String_Node_Str" + nic);
          _nicDao.remove(nic.getId());
        }
      }
    }
  }
);
  return true;
}

Fixed version (ground truth):
@Override @DB public boolean trash(Network network,NetworkOffering offering){
  try {
    long id=network.getId();
    final List<NicVO> nics=_nicDao.listPlaceholderNicsByNetworkId(id);
    if (nics != null) {
      Transaction.execute(new TransactionCallbackNoReturn(){
        @Override public void doInTransactionWithoutResult(        TransactionStatus status){
          for (          Nic nic : nics) {
            if (nic.getIp4Address() != null) {
              s_logger.debug("String_Node_Str" + nic.getIp4Address() + "String_Node_Str"+ nic);
              IPAddressVO ip=_ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(),nic.getIp4Address());
              if (ip != null) {
                _ipAddrMgr.markIpAsUnavailable(ip.getId());
                _ipAddressDao.unassignIpAddress(ip.getId());
                s_logger.debug("String_Node_Str" + nic);
                _nicDao.remove(nic.getId());
              }
            }
          }
        }
      }
);
    }
    return true;
  }
 catch (  Exception e) {
    s_logger.error("String_Node_Str" + e.getMessage());
    throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 105784
Project: 105784
Buggy source:
@Override public void doInTransactionWithoutResult(TransactionStatus status){
  for (  Nic nic : nics) {
    if (nic.getIp4Address() != null) {
      s_logger.debug("String_Node_Str" + nic.getIp4Address() + "String_Node_Str"+ nic);
      IPAddressVO ip=_ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(),nic.getIp4Address());
      _ipAddrMgr.markIpAsUnavailable(ip.getId());
      _ipAddressDao.unassignIpAddress(ip.getId());
      s_logger.debug("String_Node_Str" + nic);
      _nicDao.remove(nic.getId());
    }
  }
}

Fixed version (ground truth):
@Override public void doInTransactionWithoutResult(TransactionStatus status){
  for (  Nic nic : nics) {
    if (nic.getIp4Address() != null) {
      s_logger.debug("String_Node_Str" + nic.getIp4Address() + "String_Node_Str"+ nic);
      IPAddressVO ip=_ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(),nic.getIp4Address());
      if (ip != null) {
        _ipAddrMgr.markIpAsUnavailable(ip.getId());
        _ipAddressDao.unassignIpAddress(ip.getId());
        s_logger.debug("String_Node_Str" + nic);
        _nicDao.remove(nic.getId());
      }
    }
  }
}
Program: 105794
Project: 105794
Buggy source:
@Override public void storageMigration(String vmUuid,StoragePool destPool){
  AsyncJobExecutionContext jobContext=AsyncJobExecutionContext.getCurrentExecutionContext();
  if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
    VmWorkJobVO placeHolder=null;
    if (VmJobEnabled.value()) {
      VirtualMachine vm=_vmDao.findByUuid(vmUuid);
      placeHolder=createPlaceHolderWork(vm.getId());
    }
    try {
      orchestrateStorageMigration(vmUuid,destPool);
    }
  finally {
      if (VmJobEnabled.value())       _workJobDao.expunge(placeHolder.getId());
    }
  }
 else {
    Outcome<VirtualMachine> outcome=migrateVmStorageThroughJobQueue(vmUuid,destPool);
    try {
      VirtualMachine vm=outcome.get();
    }
 catch (    InterruptedException e) {
      throw new RuntimeException("String_Node_Str",e);
    }
catch (    java.util.concurrent.ExecutionException e) {
      throw new RuntimeException("String_Node_Str",e);
    }
    Object jobResult=_jobMgr.unmarshallResultObject(outcome.getJob());
    if (jobResult != null) {
      if (jobResult instanceof RuntimeException)       throw (RuntimeException)jobResult;
 else       if (jobResult instanceof Throwable)       throw new RuntimeException("String_Node_Str",(Throwable)jobResult);
    }
  }
}

Fixed version (ground truth):
@Override public void storageMigration(String vmUuid,StoragePool destPool){
  AsyncJobExecutionContext jobContext=AsyncJobExecutionContext.getCurrentExecutionContext();
  if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) {
    VmWorkJobVO placeHolder=null;
    if (VmJobEnabled.value()) {
      VirtualMachine vm=_vmDao.findByUuid(vmUuid);
      placeHolder=createPlaceHolderWork(vm.getId());
    }
    try {
      orchestrateStorageMigration(vmUuid,destPool);
    }
  finally {
      if (placeHolder != null) {
        _workJobDao.expunge(placeHolder.getId());
      }
    }
  }
 else {
    Outcome<VirtualMachine> outcome=migrateVmStorageThroughJobQueue(vmUuid,destPool);
    try {
      VirtualMachine vm=outcome.get();
    }
 catch (    InterruptedException e) {
      throw new RuntimeException("String_Node_Str",e);
    }
catch (    java.util.concurrent.ExecutionException e) {
      throw new RuntimeException("String_Node_Str",e);
    }
    Object jobResult=_jobMgr.unmarshallResultObject(outcome.getJob());
    if (jobResult != null) {
      if (jobResult instanceof RuntimeException)       throw (RuntimeException)jobResult;
 else       if (jobResult instanceof Throwable)       throw new RuntimeException("String_Node_Str",(Throwable)jobResult);
    }
  }
}
Program: 105795
Project: 105795
Buggy source:
private String buildAccessCacheKey(Account caller,ControlledEntity entity,AccessType accessType,String action){
  StringBuffer key=new StringBuffer();
  key.append(caller.getAccountId());
  key.append("String_Node_Str");
  String entityType=null;
  if (entity != null && entity.getEntityType() != null) {
    entityType=entity.getEntityType().getSimpleName();
  }
  key.append(entityType != null ? entityType : "String_Node_Str");
  key.append("String_Node_Str");
  key.append(accessType != null ? accessType.toString() : "String_Node_Str");
  key.append("String_Node_Str");
  key.append(action != null ? action : "String_Node_Str");
  return key.toString();
}

Fixed version (ground truth):
private String buildAccessCacheKey(Account caller,ControlledEntity entity,AccessType accessType,String action){
  StringBuffer key=new StringBuffer();
  key.append(caller.getAccountId());
  key.append("String_Node_Str");
  String entityType=null;
  if (entity != null && entity.getEntityType() != null) {
    entityType=entity.getEntityType().getSimpleName();
    if (entity instanceof InternalIdentity) {
      entityType+=((InternalIdentity)entity).getId();
    }
  }
  key.append(entityType != null ? entityType : "String_Node_Str");
  key.append("String_Node_Str");
  key.append(accessType != null ? accessType.toString() : "String_Node_Str");
  key.append("String_Node_Str");
  key.append(action != null ? action : "String_Node_Str");
  return key.toString();
}
Program: 105796
Project: 105796
Buggy source:
void destroyRemoteAccessVpnForIp(long vpnServerAddressId,Account caller) throws ResourceUnavailableException ;

Fixed version (ground truth):
boolean destroyRemoteAccessVpnForIp(long ipId,Account caller) throws ResourceUnavailableException ;
Program: 105797
Project: 105797
Buggy source:
@Override public void execute() throws ResourceUnavailableException {
  _ravService.destroyRemoteAccessVpnForIp(publicIpId,CallContext.current().getCallingAccount());
}

Fixed version (ground truth):
@Override public void execute() throws ResourceUnavailableException {
  if (!_ravService.destroyRemoteAccessVpnForIp(publicIpId,CallContext.current().getCallingAccount())) {
    throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,"String_Node_Str");
  }
}
Program: 105800
Project: 105800
Buggy source:
@Override public PrivateGateway applyVpcPrivateGateway(long gatewayId,boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException {
  VpcGatewayVO vo=_vpcGatewayDao.findById(gatewayId);
  boolean success=true;
  try {
    PrivateGateway gateway=getVpcPrivateGateway(gatewayId);
    for (    VpcProvider provider : getVpcElements()) {
      if (!provider.createPrivateGateway(gateway)) {
        success=false;
      }
    }
    if (success) {
      s_logger.debug("String_Node_Str" + gateway + "String_Node_Str");
      if (vo.getState() != VpcGateway.State.Ready) {
        vo.setState(VpcGateway.State.Ready);
        _vpcGatewayDao.update(vo.getId(),vo);
        s_logger.debug("String_Node_Str" + gateway + "String_Node_Str"+ VpcGateway.State.Ready);
      }
      return getVpcPrivateGateway(gatewayId);
    }
 else {
      s_logger.warn("String_Node_Str" + gateway + "String_Node_Str");
      return null;
    }
  }
  finally {
    if (!success) {
      if (destroyOnFailure) {
        s_logger.debug("String_Node_Str" + vo + "String_Node_Str");
        if (deletePrivateGatewayFromTheDB(getVpcPrivateGateway(gatewayId))) {
          s_logger.warn("String_Node_Str" + vo + "String_Node_Str");
        }
 else {
          s_logger.warn("String_Node_Str" + vo + "String_Node_Str");
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public PrivateGateway applyVpcPrivateGateway(long gatewayId,boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException {
  VpcGatewayVO vo=_vpcGatewayDao.findById(gatewayId);
  boolean success=true;
  try {
    List<Provider> providersToImplement=getVpcProviders(vo.getVpcId());
    PrivateGateway gateway=getVpcPrivateGateway(gatewayId);
    for (    VpcProvider provider : getVpcElements()) {
      if (providersToImplement.contains(provider.getProvider())) {
        if (!provider.createPrivateGateway(gateway)) {
          success=false;
        }
      }
    }
    if (success) {
      s_logger.debug("String_Node_Str" + gateway + "String_Node_Str");
      if (vo.getState() != VpcGateway.State.Ready) {
        vo.setState(VpcGateway.State.Ready);
        _vpcGatewayDao.update(vo.getId(),vo);
        s_logger.debug("String_Node_Str" + gateway + "String_Node_Str"+ VpcGateway.State.Ready);
      }
      return getVpcPrivateGateway(gatewayId);
    }
 else {
      s_logger.warn("String_Node_Str" + gateway + "String_Node_Str");
      return null;
    }
  }
  finally {
    if (!success) {
      if (destroyOnFailure) {
        s_logger.debug("String_Node_Str" + vo + "String_Node_Str");
        if (deletePrivateGatewayFromTheDB(getVpcPrivateGateway(gatewayId))) {
          s_logger.warn("String_Node_Str" + vo + "String_Node_Str");
        }
 else {
          s_logger.warn("String_Node_Str" + vo + "String_Node_Str");
        }
      }
    }
  }
}
Program: 105801
Project: 105801
Buggy source:
@Override public List<NetworkACLItemVO> listByACL(long aclId){
  SearchCriteria<NetworkACLItemVO> sc=AllFieldsSearch.create();
  sc.setParameters("String_Node_Str",aclId);
  List<NetworkACLItemVO> list=listBy(sc);
  for (  NetworkACLItemVO item : list) {
    loadCidrs(item);
  }
  return listBy(sc);
}

Fixed version (ground truth):
@Override public List<NetworkACLItemVO> listByACL(long aclId){
  SearchCriteria<NetworkACLItemVO> sc=AllFieldsSearch.create();
  sc.setParameters("String_Node_Str",aclId);
  List<NetworkACLItemVO> list=listBy(sc);
  for (  NetworkACLItemVO item : list) {
    loadCidrs(item);
  }
  return list;
}
Program: 105802
Project: 105802
Buggy source:
@Override public NetworkACLItemVO findByAclAndNumber(long aclId,int number){
  SearchCriteria<NetworkACLItemVO> sc=AllFieldsSearch.create();
  sc.setParameters("String_Node_Str",aclId);
  sc.setParameters("String_Node_Str",number);
  NetworkACLItemVO vo=findOneBy(sc);
  loadCidrs(vo);
  return vo;
}

Fixed version (ground truth):
@Override public NetworkACLItemVO findByAclAndNumber(long aclId,int number){
  SearchCriteria<NetworkACLItemVO> sc=AllFieldsSearch.create();
  sc.setParameters("String_Node_Str",aclId);
  sc.setParameters("String_Node_Str",number);
  NetworkACLItemVO vo=findOneBy(sc);
  if (vo != null) {
    loadCidrs(vo);
  }
  return vo;
}
Program: 105805
Project: 105805
Buggy source:
private String extractSnapshotBaseFileName(String input){
  if (input == null) {
    return null;
  }
  String result=input;
  if (result.endsWith("String_Node_Str")) {
    result=result.substring(0,result.length() - ("String_Node_Str").length());
  }
  if (result.split("String_Node_Str").length == 1) {
    return result;
  }
  if (result.split("String_Node_Str").length > 2) {
    return result.split("String_Node_Str")[0] + "String_Node_Str" + result.split("String_Node_Str")[1];
  }
  if (result.split("String_Node_Str").length == 2) {
    return result.split("String_Node_Str")[0];
  }
 else {
    return result;
  }
}

Fixed version (ground truth):
private String extractSnapshotBaseFileName(String input){
  if (input == null) {
    return null;
  }
  String result=input;
  final String fileType="String_Node_Str";
  if (result.endsWith(fileType)) {
    result=result.substring(0,result.length() - (fileType).length());
  }
  String[] str=result.split("String_Node_Str");
  int length=str.length;
  if (length == 1 || length == 2) {
    return result;
  }
  if (length > 2) {
    return str[0] + "String_Node_Str" + str[1];
  }
  return result;
}
Program: 105808
Project: 105808
Buggy source:
@Override public Answer deleteVmSnapshot(DeleteVMSnapshotCommand cmd){
  String vm=cmd.getVmName();
  String snapshotName=cmd.getTarget().getSnapshotName();
  if (_mockVmDao.findByVmName(cmd.getVmName()) != null) {
    return new DeleteVMSnapshotAnswer(cmd,false,"String_Node_Str" + cmd.getVmName());
  }
  s_logger.debug("String_Node_Str" + snapshotName + "String_Node_Str"+ vm);
  return new DeleteVMSnapshotAnswer(cmd,true,"String_Node_Str");
}

Fixed version (ground truth):
@Override public Answer deleteVmSnapshot(DeleteVMSnapshotCommand cmd){
  String vm=cmd.getVmName();
  String snapshotName=cmd.getTarget().getSnapshotName();
  if (_mockVmDao.findByVmName(cmd.getVmName()) == null) {
    return new DeleteVMSnapshotAnswer(cmd,false,"String_Node_Str" + cmd.getVmName());
  }
  s_logger.debug("String_Node_Str" + snapshotName + "String_Node_Str"+ vm);
  return new DeleteVMSnapshotAnswer(cmd,cmd.getVolumeTOs());
}
Program: 105809
Project: 105809
Buggy source:
@Override public Answer revertVmSnapshot(RevertToVMSnapshotCommand cmd){
  String vm=cmd.getVmName();
  String snapshot=cmd.getTarget().getSnapshotName();
  if (_mockVmDao.findByVmName(cmd.getVmName()) != null) {
    return new RevertToVMSnapshotAnswer(cmd,false,"String_Node_Str" + cmd.getVmName());
  }
  s_logger.debug("String_Node_Str" + snapshot + "String_Node_Str"+ vm);
  return new RevertToVMSnapshotAnswer(cmd,true,"String_Node_Str");
}

Fixed version (ground truth):
@Override public Answer revertVmSnapshot(RevertToVMSnapshotCommand cmd){
  String vm=cmd.getVmName();
  String snapshot=cmd.getTarget().getSnapshotName();
  MockVMVO vmVo=_mockVmDao.findByVmName(cmd.getVmName());
  if (vmVo == null) {
    return new RevertToVMSnapshotAnswer(cmd,false,"String_Node_Str" + cmd.getVmName());
  }
  s_logger.debug("String_Node_Str" + snapshot + "String_Node_Str"+ vm);
  return new RevertToVMSnapshotAnswer(cmd,cmd.getVolumeTOs(),vmVo.getState());
}