nus-yam/ex-repair huggingface dataset:
Program: 107340
Project: 107340
Buggy source:
@Override public void execute(){
  List<? extends IngressRule> ingressRules=_networkGroupMgr.authorizeNetworkGroupIngress(this);
  ListResponse<IngressRuleResponse> response=new ListResponse<IngressRuleResponse>();
  if ((ingressRules != null) && !ingressRules.isEmpty()) {
    List<IngressRuleResponse> responses=new ArrayList<IngressRuleResponse>();
    for (    IngressRule ingressRule : ingressRules) {
      IngressRuleResponse ingressData=new IngressRuleResponse();
      ingressData.setRuleId(ingressRule.getId());
      ingressData.setProtocol(ingressRule.getProtocol());
      if ("String_Node_Str".equalsIgnoreCase(ingressRule.getProtocol())) {
        ingressData.setIcmpType(ingressRule.getStartPort());
        ingressData.setIcmpCode(ingressRule.getEndPort());
      }
 else {
        ingressData.setStartPort(ingressRule.getStartPort());
        ingressData.setEndPort(ingressRule.getEndPort());
      }
      if (ingressRule.getAllowedNetworkGroup() != null) {
        ingressData.setNetworkGroupName(ingressRule.getAllowedNetworkGroup());
        ingressData.setAccountName(ingressRule.getAllowedNetGrpAcct());
      }
 else {
        ingressData.setCidr(ingressRule.getAllowedSourceIpCidr());
      }
      ingressData.setObjectName("String_Node_Str");
      responses.add(ingressData);
    }
    response.setResponses(responses);
    response.setResponseName("String_Node_Str");
    this.setResponseObject(response);
  }
 else {
    throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void execute(){
  List<? extends IngressRule> ingressRules=_networkGroupMgr.authorizeNetworkGroupIngress(this);
  if (ingressRules != null && !ingressRules.isEmpty()) {
    NetworkGroupResponse response=_responseGenerator.createNetworkGroupResponseFromIngressRule(ingressRules);
    this.setResponseObject(response);
  }
 else {
    throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str");
  }
}
Program: 107343
Project: 107343
Buggy source:
public void setPool(StoragePoolVO pool){
  this.pool=pool;
}

Fixed version (ground truth):
public void setPool(StoragePoolVO pool){
  this.pool=new StoragePoolVO(pool);
}
Program: 107344
Project: 107344
Buggy source:
public JsonElement serialize(List<PortConfig> src,Type typeOfSrc,JsonSerializationContext context){
  if (src.size() == 0) {
    s_logger.info("String_Node_Str");
    return new JsonNull();
  }
  Gson json=s_gBuilder.create();
  s_logger.debug("String_Node_Str");
  return json.toJsonTree(src,listType);
}

Fixed version (ground truth):
public JsonElement serialize(List<PortConfig> src,Type typeOfSrc,JsonSerializationContext context){
  if (src.size() == 0) {
    s_logger.info("String_Node_Str");
    return new JsonNull();
  }
  Gson json=s_gBuilder.create();
  s_logger.debug("String_Node_Str");
  JsonArray array=new JsonArray();
  for (  PortConfig pc : src) {
    array.add(json.toJsonTree(pc));
  }
  return array;
}
Program: 107345
Project: 107345
Buggy source:
public List<PortConfig> deserialize(JsonElement json,Type typeOfT,JsonDeserializationContext context) throws JsonParseException {
  if (json.isJsonNull()) {
    return new ArrayList<PortConfig>();
  }
  Gson jsonp=s_gBuilder.create();
  List<PortConfig> pcs=jsonp.fromJson(json,listType);
  return pcs;
}

Fixed version (ground truth):
public List<PortConfig> deserialize(JsonElement json,Type typeOfT,JsonDeserializationContext context) throws JsonParseException {
  if (json.isJsonNull()) {
    return new ArrayList<PortConfig>();
  }
  Gson jsonp=s_gBuilder.create();
  List<PortConfig> pcs=new ArrayList<PortConfig>();
  JsonArray array=json.getAsJsonArray();
  Iterator<JsonElement> it=array.iterator();
  while (it.hasNext()) {
    JsonElement element=it.next();
    pcs.add(jsonp.fromJson(element,PortConfig.class));
  }
  return pcs;
}
Program: 107346
Project: 107346
Buggy source:
protected Answer execute(final SetFirewallRuleCommand cmd){
  final String result=setFirewallRules(cmd.isEnable(),cmd.getRouterName(),cmd.getRouterIpAddress(),cmd.getProtocol().toLowerCase(),cmd.getPublicIpAddress(),cmd.getPublicPort(),cmd.getPrivateIpAddress(),cmd.getPrivatePort(),cmd.getOldPrivateIP(),cmd.getOldPrivatePort(),cmd.getVlanNetmask());
  return new Answer(cmd,result == null,result);
}

Fixed version (ground truth):
protected Answer execute(final SetFirewallRuleCommand cmd){
  String args;
  if (cmd.isNat()) {
    if (cmd.isCreate())     args="String_Node_Str";
 else     args="String_Node_Str";
    args+="String_Node_Str" + cmd.getPublicIpAddress();
    args+="String_Node_Str" + cmd.getRouterIpAddress();
    args+="String_Node_Str" + cmd.getPrivateIpAddress();
    args+="String_Node_Str" + cmd.getProtocol();
  }
 else {
    if (cmd.isEnable()) {
      args="String_Node_Str";
    }
 else {
      args="String_Node_Str";
    }
    args+="String_Node_Str" + cmd.getProtocol().toLowerCase();
    args+="String_Node_Str" + cmd.getPublicIpAddress();
    args+="String_Node_Str" + cmd.getPublicPort();
    args+="String_Node_Str" + cmd.getRouterName();
    args+="String_Node_Str" + cmd.getRouterIpAddress();
    args+="String_Node_Str" + cmd.getPrivateIpAddress();
    args+="String_Node_Str" + cmd.getPrivatePort();
    args+="String_Node_Str" + cmd.getVlanNetmask();
    String oldPrivateIP=cmd.getOldPrivateIP();
    String oldPrivatePort=cmd.getOldPrivatePort();
    if (oldPrivateIP != null) {
      args+="String_Node_Str" + oldPrivateIP;
    }
    if (oldPrivatePort != null) {
      args+="String_Node_Str" + oldPrivatePort;
    }
  }
  final Script command=new Script(_firewallPath,_timeout,s_logger);
  String[] argsArray=args.split("String_Node_Str");
  for (  String param : argsArray) {
    command.add(param);
  }
  String result=command.execute();
  return new Answer(cmd,result == null,result);
}
Program: 107348
Project: 107348
Buggy source:
public JsonElement serialize(List<PortConfig> src,Type typeOfSrc,JsonSerializationContext context){
  Gson json=s_gBuilder.create();
  String result=json.toJson(src,listType);
  return new JsonPrimitive(result);
}

Fixed version (ground truth):
public JsonElement serialize(List<PortConfig> src,Type typeOfSrc,JsonSerializationContext context){
  Gson json=s_gBuilder.create();
  s_logger.debug("String_Node_Str");
  return json.toJsonTree(src,listType);
}
Program: 107349
Project: 107349
Buggy source:
public List<PortConfig> deserialize(JsonElement json,Type typeOfT,JsonDeserializationContext context) throws JsonParseException {
  String jsonString=json.toString();
  Gson jsonp=new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
  List<PortConfig> pcs=jsonp.fromJson(jsonString,listType);
  return pcs;
}

Fixed version (ground truth):
public List<PortConfig> deserialize(JsonElement json,Type typeOfT,JsonDeserializationContext context) throws JsonParseException {
  Gson jsonp=s_gBuilder.create();
  List<PortConfig> pcs=jsonp.fromJson(json,listType);
  return pcs;
}
Program: 107352
Project: 107352
Buggy source:
@Override public boolean attachISOToVM(long vmId,long isoId,boolean attach){
  UserVmVO vm=_vmDao.findById(vmId);
  if (vm == null) {
    return false;
  }
 else   if (vm.getState() != State.Running) {
    return true;
  }
  Pair<String,String> isoPathPair=_storageMgr.getAbsoluteIsoPath(isoId,vm.getDataCenterId());
  String isoPath;
  String isoName=_templateDao.findById(isoId).getName();
  if (isoPathPair == null) {
    if (isoName.startsWith("String_Node_Str"))     isoPath=isoName;
 else     return false;
  }
 else {
    isoPath=isoPathPair.first();
  }
  String vmName=vm.getInstanceName();
  HostVO host=_hostDao.findById(vm.getHostId());
  if (host == null)   return false;
  AttachIsoCommand cmd=new AttachIsoCommand(vmName,isoPath,attach);
  if (isoPathPair != null)   cmd.setStoreUrl(isoPathPair.second());
  Answer a=_agentMgr.easySend(vm.getHostId(),cmd);
  return (a != null);
}

Fixed version (ground truth):
@Override public boolean attachISOToVM(long vmId,long isoId,boolean attach){
  UserVmVO vm=_vmDao.findById(vmId);
  if (vm == null) {
    return false;
  }
 else   if (vm.getState() != State.Running) {
    return true;
  }
  Pair<String,String> isoPathPair=_storageMgr.getAbsoluteIsoPath(isoId,vm.getDataCenterId());
  String isoPath;
  String isoName=_templateDao.findById(isoId).getName();
  if (isoPathPair == null) {
    if (isoName.startsWith("String_Node_Str"))     isoPath=isoName;
 else {
      s_logger.warn("String_Node_Str");
      return false;
    }
  }
 else {
    isoPath=isoPathPair.first();
  }
  String vmName=vm.getInstanceName();
  HostVO host=_hostDao.findById(vm.getHostId());
  if (host == null)   return false;
  AttachIsoCommand cmd=new AttachIsoCommand(vmName,isoPath,attach);
  if (isoPathPair != null)   cmd.setStoreUrl(isoPathPair.second());
  Answer a=_agentMgr.easySend(vm.getHostId(),cmd);
  return (a != null);
}
Program: 107353
Project: 107353
Buggy source:
private StoragePool getStoragePool(Connect conn,StoragePoolVO pool){
  StoragePool sp=null;
  try {
    sp=conn.storagePoolLookupByUUIDString(pool.getUuid());
  }
 catch (  LibvirtException e) {
  }
  if (sp == null) {
    if (pool.getPoolType() == StoragePoolType.NetworkFilesystem) {
      sp=createNfsStoragePool(conn,pool);
    }
    if (sp == null) {
      s_logger.debug("String_Node_Str");
      return null;
    }
  }
  try {
    StoragePoolInfo spi=sp.getInfo();
    if (spi.state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
      sp.create(0);
    }
  }
 catch (  LibvirtException e) {
  }
  return sp;
}

Fixed version (ground truth):
private Object getStoragePool(String uuid){
synchronized (_storagePools) {
    if (!_storagePools.containsKey(uuid)) {
      addStoragePool(uuid);
    }
    return _storagePools.get(uuid);
  }
}
Program: 107354
Project: 107354
Buggy source:
private StoragePool createNfsStoragePool(Connect conn,StoragePoolVO pool){
  String targetPath=_mountPoint + File.separator + pool.getUuid();
  LibvirtStoragePoolDef spd=new LibvirtStoragePoolDef(poolType.NFS,pool.getUuid(),pool.getUuid(),pool.getHostAddress(),pool.getPath(),targetPath);
  _storage.mkdir(targetPath);
  StoragePool sp=null;
  try {
    s_logger.debug(spd.toString());
    sp=conn.storagePoolDefineXML(spd.toString(),0);
    sp.create(0);
    return sp;
  }
 catch (  LibvirtException e) {
    s_logger.debug(e.toString());
    if (sp != null) {
      try {
        sp.undefine();
        sp.free();
      }
 catch (      LibvirtException l) {
        s_logger.debug("String_Node_Str" + l.toString());
      }
    }
    return null;
  }
}

Fixed version (ground truth):
private StoragePool createNfsStoragePool(Connect conn,StoragePoolVO pool){
  String targetPath=_mountPoint + File.separator + pool.getUuid();
  LibvirtStoragePoolDef spd=new LibvirtStoragePoolDef(poolType.NFS,pool.getUuid(),pool.getUuid(),pool.getHostAddress(),pool.getPath(),targetPath);
  _storage.mkdir(targetPath);
  StoragePool sp=null;
  try {
    s_logger.debug(spd.toString());
    addStoragePool(pool.getUuid());
synchronized (getStoragePool(pool.getUuid())) {
      sp=conn.storagePoolDefineXML(spd.toString(),0);
      sp.create(0);
    }
    return sp;
  }
 catch (  LibvirtException e) {
    s_logger.debug(e.toString());
    if (sp != null) {
      try {
        sp.undefine();
        sp.free();
      }
 catch (      LibvirtException l) {
        s_logger.debug("String_Node_Str" + l.toString());
      }
    }
    return null;
  }
}
Program: 107355
Project: 107355
Buggy source:
private StoragePool getNfsSPbyURI(Connect conn,URI uri) throws LibvirtException {
  String sourcePath=uri.getPath();
  sourcePath=sourcePath.replace("String_Node_Str","String_Node_Str");
  String sourceHost=uri.getHost();
  String uuid=UUID.nameUUIDFromBytes(new String(sourceHost + sourcePath).getBytes()).toString();
  String targetPath=_mountPoint + File.separator + uuid;
  StoragePool sp=null;
  try {
    sp=conn.storagePoolLookupByUUIDString(uuid);
  }
 catch (  LibvirtException e) {
  }
  if (sp == null) {
    try {
      _storage.mkdir(targetPath);
      LibvirtStoragePoolDef spd=new LibvirtStoragePoolDef(poolType.NFS,uuid,uuid,sourceHost,sourcePath,targetPath);
      s_logger.debug(spd.toString());
      sp=conn.storagePoolDefineXML(spd.toString(),0);
      if (sp == null) {
        s_logger.debug("String_Node_Str");
        return null;
      }
      sp.create(0);
      return sp;
    }
 catch (    LibvirtException e) {
      try {
        if (sp != null) {
          sp.undefine();
          sp.free();
        }
      }
 catch (      LibvirtException l) {
      }
      throw e;
    }
  }
 else {
    StoragePoolInfo spi=sp.getInfo();
    if (spi.state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
      sp.create(0);
    }
    return sp;
  }
}

Fixed version (ground truth):
private StoragePool getNfsSPbyURI(Connect conn,URI uri) throws LibvirtException {
  String sourcePath=uri.getPath();
  sourcePath=sourcePath.replace("String_Node_Str","String_Node_Str");
  String sourceHost=uri.getHost();
  String uuid=UUID.nameUUIDFromBytes(new String(sourceHost + sourcePath).getBytes()).toString();
  String targetPath=_mountPoint + File.separator + uuid;
  StoragePool sp=null;
  try {
    sp=conn.storagePoolLookupByUUIDString(uuid);
  }
 catch (  LibvirtException e) {
  }
  if (sp == null) {
    try {
      _storage.mkdir(targetPath);
      LibvirtStoragePoolDef spd=new LibvirtStoragePoolDef(poolType.NFS,uuid,uuid,sourceHost,sourcePath,targetPath);
      s_logger.debug(spd.toString());
      addStoragePool(uuid);
synchronized (getStoragePool(uuid)) {
        sp=conn.storagePoolDefineXML(spd.toString(),0);
        if (sp == null) {
          s_logger.debug("String_Node_Str");
          return null;
        }
        sp.create(0);
      }
      return sp;
    }
 catch (    LibvirtException e) {
      try {
        if (sp != null) {
          sp.undefine();
          sp.free();
        }
      }
 catch (      LibvirtException l) {
      }
      throw e;
    }
  }
 else {
    StoragePoolInfo spi=sp.getInfo();
    if (spi.state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
      sp.create(0);
    }
    return sp;
  }
}
Program: 107356
Project: 107356
Buggy source:
private StorageVol getVolume(String volKey) throws LibvirtException {
  StorageVol vol=null;
  try {
    vol=_conn.storageVolLookupByKey(volKey);
  }
 catch (  LibvirtException e) {
  }
  if (vol == null) {
    StoragePool pool=null;
    String token[]=volKey.split("String_Node_Str");
    if (token.length <= 2) {
      s_logger.debug("String_Node_Str" + volKey);
      return null;
    }
    String poolUUID=token[token.length - 2];
    pool=_conn.storagePoolLookupByUUIDString(poolUUID);
    pool.refresh(0);
    vol=_conn.storageVolLookupByKey(volKey);
  }
  return vol;
}

Fixed version (ground truth):
private StorageVol getVolume(String volKey) throws LibvirtException {
  StorageVol vol=null;
  try {
    vol=_conn.storageVolLookupByKey(volKey);
  }
 catch (  LibvirtException e) {
  }
  if (vol == null) {
    StoragePool pool=null;
    String token[]=volKey.split("String_Node_Str");
    if (token.length <= 2) {
      s_logger.debug("String_Node_Str" + volKey);
      return null;
    }
    String poolUUID=token[token.length - 2];
    pool=_conn.storagePoolLookupByUUIDString(poolUUID);
synchronized (getStoragePool(poolUUID)) {
      pool.refresh(0);
    }
    vol=_conn.storageVolLookupByKey(volKey);
  }
  return vol;
}
Program: 107361
Project: 107361
Buggy source:
protected void parse(String filename){
  Pair<XmlHandler,HashMap<String,List<ComponentInfo<Adapter>>>> result=parse2(filename);
  if (result == null) {
    s_logger.info("String_Node_Str" + filename);
    return;
  }
  XmlHandler handler=result.first();
  HashMap<String,List<ComponentInfo<Adapter>>> adapters=result.second();
  try {
    startDaos();
    instantiateAdapters(adapters);
    instantiateManagers();
    _component=createInstance(handler.componentClass,true,true);
    configureManagers();
    configureAdapters();
    startManagers();
    startAdapters();
  }
 catch (  CloudRuntimeException e) {
    s_logger.error("String_Node_Str" + _serverName + "String_Node_Str"+ filename,e);
    System.exit(1);
  }
catch (  Exception e) {
    s_logger.error("String_Node_Str" + _serverName + "String_Node_Str"+ filename,e);
    System.exit(1);
  }
}

Fixed version (ground truth):
protected void parse(String filename){
  Pair<XmlHandler,HashMap<String,List<ComponentInfo<Adapter>>>> result=parse2(filename);
  if (result == null) {
    s_logger.info("String_Node_Str" + filename);
    return;
  }
  XmlHandler handler=result.first();
  HashMap<String,List<ComponentInfo<Adapter>>> adapters=result.second();
  try {
    startDaos();
    instantiateAdapters(adapters);
    instantiateManagers();
    if (handler.componentClass != null) {
      _component=createInstance(handler.componentClass,true,true);
    }
    configureManagers();
    configureAdapters();
    startManagers();
    startAdapters();
  }
 catch (  CloudRuntimeException e) {
    s_logger.error("String_Node_Str" + _serverName + "String_Node_Str"+ filename,e);
    System.exit(1);
  }
catch (  Exception e) {
    s_logger.error("String_Node_Str" + _serverName + "String_Node_Str"+ filename,e);
    System.exit(1);
  }
}
Program: 107363
Project: 107363
Buggy source:
private VMTemplateVO findSystemVMTemplate(){
  SearchCriteria<VMTemplateVO> sc=tmpltTypeHyperSearch.create();
  sc.setParameters("String_Node_Str",Storage.TemplateType.SYSTEM);
  sc.setParameters("String_Node_Str",_defaultHyperType.toString());
  VMTemplateVO tmplt=findOneBy(sc);
  if (tmplt == null) {
    if (_defaultHyperType != HypervisorType.XenServer) {
      sc=tmpltTypeHyperSearch.create();
      sc.setParameters("String_Node_Str",Storage.TemplateType.SYSTEM);
      sc.setParameters("String_Node_Str",HypervisorType.XenServer);
      tmplt=findOneBy(sc);
      if (tmplt == null) {
        sc=tmpltTypeSearch.create();
        sc.setParameters("String_Node_Str",Storage.TemplateType.SYSTEM);
        tmplt=findOneBy(sc);
      }
    }
  }
  return tmplt;
}

Fixed version (ground truth):
private VMTemplateVO findSystemVMTemplate(){
  SearchCriteria<VMTemplateVO> sc=tmpltTypeHyperSearch.create();
  sc.setParameters("String_Node_Str",Storage.TemplateType.SYSTEM);
  sc.setParameters("String_Node_Str",_defaultHyperType.toString());
  VMTemplateVO tmplt=findOneBy(sc);
  if (tmplt == null) {
    if (_defaultHyperType != HypervisorType.XenServer) {
      sc=tmpltTypeHyperSearch.create();
      sc.setParameters("String_Node_Str",Storage.TemplateType.SYSTEM);
      sc.setParameters("String_Node_Str",HypervisorType.XenServer.toString());
      tmplt=findOneBy(sc);
      if (tmplt == null) {
        sc=tmpltTypeSearch.create();
        sc.setParameters("String_Node_Str",Storage.TemplateType.SYSTEM);
        tmplt=findOneBy(sc);
      }
    }
  }
  return tmplt;
}
Program: 107364
Project: 107364
Buggy source:
public static IPAddressResponse createIPAddressResponse(IPAddressVO ipAddress){
  VlanVO vlan=ApiDBUtils.findVlanById(ipAddress.getVlanDbId());
  boolean forVirtualNetworks=vlan.getVlanType().equals(VlanType.VirtualNetwork);
  IPAddressResponse ipResponse=new IPAddressResponse();
  ipResponse.setIpAddress(ipAddress.getAddress());
  if (ipAddress.getAllocated() != null) {
    ipResponse.setAllocated(ipAddress.getAllocated());
  }
  ipResponse.setZoneId(ipAddress.getDataCenterId());
  ipResponse.setZoneName(ApiDBUtils.findZoneById(ipAddress.getDataCenterId()).getName());
  ipResponse.setSourceNat(ipAddress.isSourceNat());
  Account accountTemp=ApiDBUtils.findAccountById(ipAddress.getAccountId());
  if (accountTemp != null) {
    ipResponse.setAccountName(accountTemp.getAccountName());
    ipResponse.setDomainId(accountTemp.getDomainId());
    ipResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
  }
  ipResponse.setForVirtualNetwork(forVirtualNetworks);
  ipResponse.setOneToOneNat(ipAddress.isOneToOneNat());
  Account account=UserContext.current().getAccount();
  if ((account == null) || account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
    ipResponse.setVlanId(ipAddress.getVlanDbId());
    ipResponse.setVlanName(ApiDBUtils.findVlanById(ipAddress.getVlanDbId()).getVlanId());
  }
  ipResponse.setObjectName("String_Node_Str");
  return ipResponse;
}

Fixed version (ground truth):
public static IPAddressResponse createIPAddressResponse(IPAddressVO ipAddress){
  VlanVO vlan=ApiDBUtils.findVlanById(ipAddress.getVlanDbId());
  boolean forVirtualNetworks=vlan.getVlanType().equals(VlanType.VirtualNetwork);
  IPAddressResponse ipResponse=new IPAddressResponse();
  ipResponse.setIpAddress(ipAddress.getAddress());
  if (ipAddress.getAllocated() != null) {
    ipResponse.setAllocated(ipAddress.getAllocated());
  }
  ipResponse.setZoneId(ipAddress.getDataCenterId());
  ipResponse.setZoneName(ApiDBUtils.findZoneById(ipAddress.getDataCenterId()).getName());
  ipResponse.setSourceNat(ipAddress.isSourceNat());
  Account accountTemp=ApiDBUtils.findAccountById(ipAddress.getAccountId());
  if (accountTemp != null) {
    ipResponse.setAccountName(accountTemp.getAccountName());
    ipResponse.setDomainId(accountTemp.getDomainId());
    ipResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
  }
  ipResponse.setForVirtualNetwork(forVirtualNetworks);
  ipResponse.setStaticNat(ipAddress.isOneToOneNat());
  Account account=UserContext.current().getAccount();
  if ((account == null) || account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
    ipResponse.setVlanId(ipAddress.getVlanDbId());
    ipResponse.setVlanName(ApiDBUtils.findVlanById(ipAddress.getVlanDbId()).getVlanId());
  }
  ipResponse.setObjectName("String_Node_Str");
  return ipResponse;
}
Program: 107365
Project: 107365
Buggy source:
@Override public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException {
  boolean result=BaseCmd._networkMgr.deletePortForwardingRule(this);
  if (result) {
    SuccessResponse response=new SuccessResponse(getName());
    this.setResponseObject(response);
  }
 else {
    throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException {
  boolean result=BaseCmd._networkMgr.deletePortForwardingRule(id,false);
  if (result) {
    SuccessResponse response=new SuccessResponse(getName());
    this.setResponseObject(response);
  }
 else {
    throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str");
  }
}
Program: 107366
Project: 107366
Buggy source:
public boolean deletePortForwardingRule(DeletePortForwardingRuleCmd cmd);

Fixed version (ground truth):
public boolean deletePortForwardingRule(Long id,boolean sysContext);
Program: 107370
Project: 107370
Buggy source:
@Override @DB public boolean deletePod(DeletePodCmd cmd){
  Long podId=cmd.getId();
  Long userId=1L;
  if (UserContext.current() != null)   userId=UserContext.current().getUserId();
  if (!validPod(podId)) {
    throw new InvalidParameterValueException("String_Node_Str" + podId + "String_Node_Str");
  }
  checkIfPodIsDeletable(podId);
  HostPodVO pod=_podDao.findById(podId);
  DataCenterVO zone=_zoneDao.findById(pod.getDataCenterId());
  if (_podDao.expunge(podId) && _privateIpAddressDao.deleteIpAddressByPod(podId)) {
    saveConfigurationEvent(userId,null,EventTypes.EVENT_POD_DELETE,"String_Node_Str" + pod.getName() + "String_Node_Str"+ zone.getName()+ "String_Node_Str","String_Node_Str" + podId,"String_Node_Str" + zone.getId());
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override @DB public boolean deletePod(DeletePodCmd cmd){
  Long podId=cmd.getId();
  Long userId=1L;
  if (UserContext.current() != null)   userId=UserContext.current().getUserId();
  if (!validPod(podId)) {
    throw new InvalidParameterValueException("String_Node_Str" + podId + "String_Node_Str");
  }
  checkIfPodIsDeletable(podId);
  HostPodVO pod=_podDao.findById(podId);
  DataCenterVO zone=_zoneDao.findById(pod.getDataCenterId());
  List<DataCenterIpAddressVO> privateIps=_privateIpAddressDao.listByPodIdDcId(Long.valueOf(podId),pod.getDataCenterId());
  if (privateIps != null && privateIps.size() != 0) {
    if (!(_privateIpAddressDao.deleteIpAddressByPod(podId))) {
      throw new CloudRuntimeException("String_Node_Str" + podId);
    }
  }
  if (!(_LinkLocalIpAllocDao.deleteIpAddressByPod(podId))) {
    throw new CloudRuntimeException("String_Node_Str" + podId);
  }
  if (!(_podDao.expunge(podId))) {
    throw new CloudRuntimeException("String_Node_Str" + podId);
  }
  saveConfigurationEvent(userId,null,EventTypes.EVENT_POD_DELETE,"String_Node_Str" + pod.getName() + "String_Node_Str"+ zone.getName()+ "String_Node_Str","String_Node_Str" + podId,"String_Node_Str" + zone.getId());
  return true;
}
Program: 107373
Project: 107373
Buggy source:
@Override public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException {
  VirtualMachine result=_mgr.startSystemVm(this);
  return result;
}

Fixed version (ground truth):
@Override public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException {
  VirtualMachine instance=_mgr.startSystemVm(this);
  SystemVmResponse response=ApiResponseHelper.createSystemVmResponse((VMInstanceVO)instance);
  response.setResponseName(getName());
  this.setResponseObject(response);
}
Program: 107374
Project: 107374
Buggy source:
@Override public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException {
  VirtualMachine result=_mgr.stopSystemVm(this);
  return result;
}

Fixed version (ground truth):
@Override public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException {
  VirtualMachine instance=_mgr.stopSystemVm(this);
  SystemVmResponse response=ApiResponseHelper.createSystemVmResponse((VMInstanceVO)instance);
  response.setResponseName(getName());
}
Program: 107375
Project: 107375
Buggy source:
boolean isDirectAttachedNetwork(String type){
  if ("String_Node_Str".equalsIgnoreCase(type))   return true;
 else   return false;
}

Fixed version (ground truth):
boolean isDirectAttachedNetwork(String type){
  if ("String_Node_Str".equalsIgnoreCase(type))   return true;
 else {
    try {
      Long vnetId=Long.valueOf(type);
    }
 catch (    NumberFormatException e) {
      return true;
    }
    return false;
  }
}
Program: 107378
Project: 107378
Buggy source:
protected DataCenterIpAddressDaoImpl(){
  super();
  AllFieldsSearch=createSearchBuilder();
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getIpAddress(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getDataCenterId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getPodId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getInstanceId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getIpAddress(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getReservationId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getTakenAt(),SearchCriteria.Op.EQ);
  AllFieldsSearch.done();
  AllIpCount=createSearchBuilder(Integer.class);
  AllIpCount.select(null,Func.COUNT,AllIpCount.entity().getId());
  AllIpCount.and("String_Node_Str",AllIpCount.entity().getPodId(),SearchCriteria.Op.EQ);
  AllIpCount.done();
  AllAllocatedIpCount=createSearchBuilder(Integer.class);
  AllAllocatedIpCount.select(null,Func.COUNT,AllIpCount.entity().getId());
  AllAllocatedIpCount.and("String_Node_Str",AllAllocatedIpCount.entity().getPodId(),SearchCriteria.Op.EQ);
  AllAllocatedIpCount.and("String_Node_Str",AllAllocatedIpCount.entity().getTakenAt(),SearchCriteria.Op.NNULL);
  AllAllocatedIpCount.done();
}

Fixed version (ground truth):
protected DataCenterIpAddressDaoImpl(){
  super();
  AllFieldsSearch=createSearchBuilder();
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getIpAddress(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getDataCenterId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getPodId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getInstanceId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getIpAddress(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getReservationId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getTakenAt(),SearchCriteria.Op.EQ);
  AllFieldsSearch.done();
  AllIpCount=createSearchBuilder(Integer.class);
  AllIpCount.select(null,Func.COUNT,AllIpCount.entity().getId());
  AllIpCount.and("String_Node_Str",AllIpCount.entity().getPodId(),SearchCriteria.Op.EQ);
  AllIpCount.done();
  AllAllocatedIpCount=createSearchBuilder(Integer.class);
  AllAllocatedIpCount.select(null,Func.COUNT,AllAllocatedIpCount.entity().getId());
  AllAllocatedIpCount.and("String_Node_Str",AllAllocatedIpCount.entity().getPodId(),SearchCriteria.Op.EQ);
  AllAllocatedIpCount.and("String_Node_Str",AllAllocatedIpCount.entity().getTakenAt(),SearchCriteria.Op.NNULL);
  AllAllocatedIpCount.done();
}
Program: 107379
Project: 107379
Buggy source:
protected DataCenterLinkLocalIpAddressDaoImpl(){
  super();
  AllFieldsSearch=createSearchBuilder();
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getIpAddress(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getDataCenterId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getPodId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getInstanceId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getReservationId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getTakenAt(),SearchCriteria.Op.EQ);
  AllFieldsSearch.done();
  AllIpCount=createSearchBuilder(Integer.class);
  AllIpCount.select(null,Func.COUNT,AllIpCount.entity().getId());
  AllIpCount.and("String_Node_Str",AllIpCount.entity().getPodId(),SearchCriteria.Op.EQ);
  AllIpCount.done();
  AllAllocatedIpCount=createSearchBuilder(Integer.class);
  AllAllocatedIpCount.select(null,Func.COUNT,AllIpCount.entity().getId());
  AllAllocatedIpCount.and("String_Node_Str",AllAllocatedIpCount.entity().getPodId(),SearchCriteria.Op.EQ);
  AllAllocatedIpCount.and("String_Node_Str",AllAllocatedIpCount.entity().getTakenAt(),SearchCriteria.Op.NNULL);
  AllAllocatedIpCount.done();
}

Fixed version (ground truth):
protected DataCenterLinkLocalIpAddressDaoImpl(){
  super();
  AllFieldsSearch=createSearchBuilder();
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getIpAddress(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getDataCenterId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getPodId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getInstanceId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getReservationId(),SearchCriteria.Op.EQ);
  AllFieldsSearch.and("String_Node_Str",AllFieldsSearch.entity().getTakenAt(),SearchCriteria.Op.EQ);
  AllFieldsSearch.done();
  AllIpCount=createSearchBuilder(Integer.class);
  AllIpCount.select(null,Func.COUNT,AllIpCount.entity().getId());
  AllIpCount.and("String_Node_Str",AllIpCount.entity().getPodId(),SearchCriteria.Op.EQ);
  AllIpCount.done();
  AllAllocatedIpCount=createSearchBuilder(Integer.class);
  AllAllocatedIpCount.select(null,Func.COUNT,AllAllocatedIpCount.entity().getId());
  AllAllocatedIpCount.and("String_Node_Str",AllAllocatedIpCount.entity().getPodId(),SearchCriteria.Op.EQ);
  AllAllocatedIpCount.and("String_Node_Str",AllAllocatedIpCount.entity().getTakenAt(),SearchCriteria.Op.NNULL);
  AllAllocatedIpCount.done();
}
Program: 107380
Project: 107380
Buggy source:
public Long getPageSizeVal(){
  Long pageSize=DEFAULT_PAGE_SIZE;
  Integer pageSizeInt=getPageSize();
  if (pageSizeInt != null) {
    if (pageSizeInt.longValue() == -1) {
      pageSize=null;
    }
 else {
      pageSize=pageSizeInt.longValue();
    }
  }
  return pageSize;
}

Fixed version (ground truth):
public Long getPageSizeVal(){
  Long pageSize=null;
  Integer pageSizeInt=getPageSize();
  if (pageSizeInt != null) {
    if (pageSizeInt.longValue() == -1) {
      pageSize=null;
    }
 else {
      pageSize=pageSizeInt.longValue();
    }
  }
  return pageSize;
}
Program: 107381
Project: 107381
Buggy source:
List<DomainVO> findAllChildren(String path);

Fixed version (ground truth):
List<DomainVO> findAllChildren(String path,Long parentId);
Program: 107382
Project: 107382
Buggy source:
@Override public List<DomainVO> findAllChildren(String path){
  SearchCriteria<DomainVO> sc=FindAllChildrenSearch.create();
  sc.setParameters("String_Node_Str",path);
  return listBy(sc);
}

Fixed version (ground truth):
@Override public List<DomainVO> findAllChildren(String path,Long parentId){
  SearchCriteria<DomainVO> sc=FindAllChildrenSearch.create();
  sc.setParameters("String_Node_Str","String_Node_Str" + path + "String_Node_Str");
  sc.setParameters("String_Node_Str",parentId);
  return listBy(sc);
}
Program: 107383
Project: 107383
Buggy source:
public DomainDaoImpl(){
  DomainNameLikeSearch=createSearchBuilder();
  DomainNameLikeSearch.and("String_Node_Str",DomainNameLikeSearch.entity().getName(),SearchCriteria.Op.LIKE);
  DomainNameLikeSearch.done();
  ParentDomainNameLikeSearch=createSearchBuilder();
  ParentDomainNameLikeSearch.and("String_Node_Str",ParentDomainNameLikeSearch.entity().getName(),SearchCriteria.Op.LIKE);
  ParentDomainNameLikeSearch.and("String_Node_Str",ParentDomainNameLikeSearch.entity().getName(),SearchCriteria.Op.EQ);
  ParentDomainNameLikeSearch.done();
  DomainPairSearch=createSearchBuilder();
  DomainPairSearch.and("String_Node_Str",DomainPairSearch.entity().getId(),SearchCriteria.Op.IN);
  DomainPairSearch.done();
  ImmediateChildDomainSearch=createSearchBuilder();
  ImmediateChildDomainSearch.and("String_Node_Str",ImmediateChildDomainSearch.entity().getParent(),SearchCriteria.Op.EQ);
  ImmediateChildDomainSearch.done();
  FindAllChildrenSearch=createSearchBuilder();
  FindAllChildrenSearch.and("String_Node_Str",FindAllChildrenSearch.entity().getPath(),SearchCriteria.Op.LIKE);
  FindAllChildrenSearch.done();
}

Fixed version (ground truth):
public DomainDaoImpl(){
  DomainNameLikeSearch=createSearchBuilder();
  DomainNameLikeSearch.and("String_Node_Str",DomainNameLikeSearch.entity().getName(),SearchCriteria.Op.LIKE);
  DomainNameLikeSearch.done();
  ParentDomainNameLikeSearch=createSearchBuilder();
  ParentDomainNameLikeSearch.and("String_Node_Str",ParentDomainNameLikeSearch.entity().getName(),SearchCriteria.Op.LIKE);
  ParentDomainNameLikeSearch.and("String_Node_Str",ParentDomainNameLikeSearch.entity().getName(),SearchCriteria.Op.EQ);
  ParentDomainNameLikeSearch.done();
  DomainPairSearch=createSearchBuilder();
  DomainPairSearch.and("String_Node_Str",DomainPairSearch.entity().getId(),SearchCriteria.Op.IN);
  DomainPairSearch.done();
  ImmediateChildDomainSearch=createSearchBuilder();
  ImmediateChildDomainSearch.and("String_Node_Str",ImmediateChildDomainSearch.entity().getParent(),SearchCriteria.Op.EQ);
  ImmediateChildDomainSearch.done();
  FindAllChildrenSearch=createSearchBuilder();
  FindAllChildrenSearch.and("String_Node_Str",FindAllChildrenSearch.entity().getPath(),SearchCriteria.Op.LIKE);
  FindAllChildrenSearch.and("String_Node_Str",FindAllChildrenSearch.entity().getId(),SearchCriteria.Op.NEQ);
  FindAllChildrenSearch.done();
}
Program: 107386
Project: 107386
Buggy source:
@Override public List<DomainVO> searchForDomainChildren(ListDomainChildrenCmd cmd) throws PermissionDeniedException {
  Filter searchFilter=new Filter(DomainVO.class,"String_Node_Str",true,cmd.getStartIndex(),cmd.getPageSizeVal());
  Long domainId=cmd.getId();
  String domainName=cmd.getDomainName();
  Object keyword=cmd.getKeyword();
  Account account=UserContext.current().getAccount();
  if (account != null) {
    if (domainId != null) {
      if (!_domainDao.isChildDomain(account.getDomainId(),domainId)) {
        throw new PermissionDeniedException("String_Node_Str" + domainId + "String_Node_Str");
      }
    }
 else {
      domainId=account.getDomainId();
    }
  }
  SearchCriteria<DomainVO> sc=_domainDao.createSearchCriteria();
  if (keyword != null) {
    SearchCriteria<DomainVO> ssc=_domainDao.createSearchCriteria();
    ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
    sc.addAnd("String_Node_Str",SearchCriteria.Op.SC,ssc);
  }
  if (domainId != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,domainId);
  }
  if (domainName != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + domainName + "String_Node_Str");
  }
  return _domainDao.search(sc,searchFilter);
}

Fixed version (ground truth):
private List<DomainVO> searchForDomainChildren(Filter searchFilter,Long domainId,String domainName,Object keyword){
  SearchCriteria<DomainVO> sc=_domainDao.createSearchCriteria();
  if (keyword != null) {
    SearchCriteria<DomainVO> ssc=_domainDao.createSearchCriteria();
    ssc.addOr("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + keyword + "String_Node_Str");
    sc.addAnd("String_Node_Str",SearchCriteria.Op.SC,ssc);
  }
  if (domainId != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.EQ,domainId);
  }
  if (domainName != null) {
    sc.addAnd("String_Node_Str",SearchCriteria.Op.LIKE,"String_Node_Str" + domainName + "String_Node_Str");
  }
  return _domainDao.search(sc,searchFilter);
}
Program: 107387
Project: 107387
Buggy source:
public static String toSerializedStringOld(Object result){
  if (result != null) {
    Class<?> clz=result.getClass();
    Gson gson=ApiGsonHelper.getBuilder().create();
    if (result instanceof ResponseObject) {
      return clz.getName() + token + ((ResponseObject)result).getResponseName()+ token+ gson.toJson(result);
    }
 else {
      return clz.getName() + token + gson.toJson(result);
    }
  }
  return null;
}

Fixed version (ground truth):
public static String toSerializedStringOld(Object result){
  if (result != null) {
    Class<?> clz=result.getClass();
    Gson gson=ApiGsonHelper.getBuilder().create();
    if (result instanceof ResponseObject) {
      return clz.getName() + token + ((ResponseObject)result).getObjectName()+ token+ gson.toJson(result);
    }
 else {
      return clz.getName() + token + gson.toJson(result);
    }
  }
  return null;
}
Program: 107388
Project: 107388
Buggy source:
public static Object fromSerializedString(String result){
  try {
    if (result != null && !result.isEmpty()) {
      String[] serializedParts=result.split(token);
      if (serializedParts.length < 2) {
        return null;
      }
      String clzName=serializedParts[0];
      String nameField=null;
      String content=null;
      if (serializedParts.length == 2) {
        content=serializedParts[1];
      }
 else {
        nameField=serializedParts[1];
        int index=result.indexOf(token + nameField + token);
        content=result.substring(index + nameField.length() + 2);
      }
      Class<?> clz;
      try {
        clz=Class.forName(clzName);
      }
 catch (      ClassNotFoundException e) {
        return null;
      }
      Gson gson=ApiGsonHelper.getBuilder().create();
      Object obj=gson.fromJson(content,clz);
      if (nameField != null) {
        ((ResponseObject)obj).setResponseName(nameField);
      }
      return obj;
    }
    return null;
  }
 catch (  RuntimeException e) {
    s_logger.error("String_Node_Str" + result);
    throw e;
  }
}

Fixed version (ground truth):
public static Object fromSerializedString(String result){
  try {
    if (result != null && !result.isEmpty()) {
      String[] serializedParts=result.split(token);
      if (serializedParts.length < 2) {
        return null;
      }
      String clzName=serializedParts[0];
      String nameField=null;
      String content=null;
      if (serializedParts.length == 2) {
        content=serializedParts[1];
      }
 else {
        nameField=serializedParts[1];
        int index=result.indexOf(token + nameField + token);
        content=result.substring(index + nameField.length() + 2);
      }
      Class<?> clz;
      try {
        clz=Class.forName(clzName);
      }
 catch (      ClassNotFoundException e) {
        return null;
      }
      Gson gson=ApiGsonHelper.getBuilder().create();
      Object obj=gson.fromJson(content,clz);
      if (nameField != null) {
        ((ResponseObject)obj).setObjectName(nameField);
      }
      return obj;
    }
    return null;
  }
 catch (  RuntimeException e) {
    s_logger.error("String_Node_Str" + result);
    throw e;
  }
}
Program: 107393
Project: 107393
Buggy source:
@Override public void evictTemplateFromStoragePool(VMTemplateStoragePoolVO templatePoolVO){
  StoragePoolVO pool=_poolDao.findById(templatePoolVO.getPoolId());
  VMTemplateVO template=_tmpltDao.findById(templatePoolVO.getTemplateId());
  long hostId;
  List<StoragePoolHostVO> poolHostVOs=_poolHostDao.listByPoolId(pool.getId());
  if (poolHostVOs.isEmpty()) {
    return;
  }
 else {
    hostId=poolHostVOs.get(0).getHostId();
  }
  DestroyCommand cmd=new DestroyCommand(pool,templatePoolVO);
  Answer answer=_agentMgr.easySend(hostId,cmd);
  if (answer != null && answer.getResult()) {
    if (_tmpltPoolDao.remove(templatePoolVO.getId())) {
      s_logger.debug("String_Node_Str" + template.getName() + "String_Node_Str"+ pool.getName());
    }
  }
}

Fixed version (ground truth):
@Override public void evictTemplateFromStoragePool(VMTemplateStoragePoolVO templatePoolVO){
  StoragePoolVO pool=_poolDao.findById(templatePoolVO.getPoolId());
  VMTemplateVO template=_tmpltDao.findByIdIncludingRemoved(templatePoolVO.getTemplateId());
  long hostId;
  List<StoragePoolHostVO> poolHostVOs=_poolHostDao.listByPoolId(pool.getId());
  if (poolHostVOs.isEmpty()) {
    return;
  }
 else {
    hostId=poolHostVOs.get(0).getHostId();
  }
  DestroyCommand cmd=new DestroyCommand(pool,templatePoolVO);
  Answer answer=_agentMgr.easySend(hostId,cmd);
  if (answer != null && answer.getResult()) {
    if (_tmpltPoolDao.remove(templatePoolVO.getId())) {
      s_logger.debug("String_Node_Str" + template.getName() + "String_Node_Str"+ pool.getName());
    }
  }
}
Program: 107394
Project: 107394
Buggy source:
@Override public boolean deleteTemplate(DeleteTemplateCmd cmd){
  Long templateId=cmd.getId();
  Long userId=UserContext.current().getUserId();
  Account account=UserContext.current().getAccount();
  Long zoneId=cmd.getZoneId();
  VMTemplateVO template=_tmpltDao.findById(templateId.longValue());
  if (template == null) {
    throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + templateId);
  }
  userId=accountAndUserValidation(account,userId,null,template,"String_Node_Str");
  UserVO user=_userDao.findById(userId);
  if (user == null) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  if (template.getFormat() == ImageFormat.ISO) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  if (template.getUniqueName().equals("String_Node_Str")) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  if (zoneId != null && (_hostDao.findSecondaryStorageHost(zoneId) == null)) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  return delete(userId,templateId,zoneId);
}

Fixed version (ground truth):
@Override public boolean deleteTemplate(DeleteTemplateCmd cmd){
  Long templateId=cmd.getId();
  Long userId=UserContext.current().getUserId();
  Account account=UserContext.current().getAccount();
  Long zoneId=cmd.getZoneId();
  VMTemplateVO template=_tmpltDao.findById(templateId.longValue());
  if (template == null) {
    throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + templateId);
  }
  userId=accountAndUserValidation(account,userId,null,template,"String_Node_Str");
  UserVO user=_userDao.findById(userId);
  if (user == null) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  if (template.getFormat() == ImageFormat.ISO) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  if (template.getTemplateType() == TemplateType.SYSTEM) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  if (zoneId != null && (_hostDao.findSecondaryStorageHost(zoneId) == null)) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  return delete(userId,templateId,zoneId);
}
Program: 107395
Project: 107395
Buggy source:
@Override public boolean templateIsDeleteable(VMTemplateHostVO templateHostRef){
  VMTemplateVO template=_tmpltDao.findById(templateHostRef.getTemplateId());
  long templateId=template.getId();
  HostVO secondaryStorageHost=_hostDao.findById(templateHostRef.getHostId());
  long zoneId=secondaryStorageHost.getDataCenterId();
  DataCenterVO zone=_dcDao.findById(zoneId);
  List<VMInstanceVO> nonExpungedVms=_vmInstanceDao.listNonExpungedByZoneAndTemplate(zoneId,templateId);
  if (!nonExpungedVms.isEmpty()) {
    s_logger.debug("String_Node_Str" + template.getName() + "String_Node_Str"+ zone.getName()+ "String_Node_Str");
    return false;
  }
  List<VolumeVO> volumes=_volumeDao.findByTemplateAndZone(templateId,zoneId);
  for (  VolumeVO volume : volumes) {
    List<SnapshotVO> snapshots=_snapshotDao.listByVolumeId(volume.getId());
    if (!snapshots.isEmpty()) {
      s_logger.debug("String_Node_Str" + template.getName() + "String_Node_Str"+ zone.getName()+ "String_Node_Str");
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean templateIsDeleteable(VMTemplateHostVO templateHostRef){
  VMTemplateVO template=_tmpltDao.findByIdIncludingRemoved(templateHostRef.getTemplateId());
  long templateId=template.getId();
  HostVO secondaryStorageHost=_hostDao.findById(templateHostRef.getHostId());
  long zoneId=secondaryStorageHost.getDataCenterId();
  DataCenterVO zone=_dcDao.findById(zoneId);
  List<VMInstanceVO> nonExpungedVms=_vmInstanceDao.listNonExpungedByZoneAndTemplate(zoneId,templateId);
  if (!nonExpungedVms.isEmpty()) {
    s_logger.debug("String_Node_Str" + template.getName() + "String_Node_Str"+ zone.getName()+ "String_Node_Str");
    return false;
  }
  List<VolumeVO> volumes=_volumeDao.findByTemplateAndZone(templateId,zoneId);
  for (  VolumeVO volume : volumes) {
    List<SnapshotVO> snapshots=_snapshotDao.listByVolumeId(volume.getId());
    if (!snapshots.isEmpty()) {
      s_logger.debug("String_Node_Str" + template.getName() + "String_Node_Str"+ zone.getName()+ "String_Node_Str");
      return false;
    }
  }
  return true;
}