nus-yam/ex-repair huggingface dataset:
Program: 106994
Project: 106994
Buggy source:
private static Map<Service,Map<Capability,String>> setCapabilities(){
  Map<Service,Map<Capability,String>> capabilities=new HashMap<Service,Map<Capability,String>>();
  Map<Capability,String> lbCapabilities=new HashMap<Capability,String>();
  lbCapabilities.put(Capability.SupportedLBAlgorithms,"String_Node_Str");
  lbCapabilities.put(Capability.SupportedProtocols,"String_Node_Str");
  capabilities.put(Service.Lb,lbCapabilities);
  Map<Capability,String> firewallCapabilities=new HashMap<Capability,String>();
  firewallCapabilities.put(Capability.PortForwarding,"String_Node_Str");
  firewallCapabilities.put(Capability.TrafficStatistics,"String_Node_Str");
  firewallCapabilities.put(Capability.StaticNat,"String_Node_Str");
  firewallCapabilities.put(Capability.SupportedProtocols,"String_Node_Str");
  firewallCapabilities.put(Capability.MultipleIps,"String_Node_Str");
  firewallCapabilities.put(Capability.SupportedSourceNatTypes,"String_Node_Str");
  capabilities.put(Service.Firewall,firewallCapabilities);
  Map<Capability,String> vpnCapabilities=new HashMap<Capability,String>();
  vpnCapabilities.put(Capability.SupportedVpnTypes,"String_Node_Str");
  capabilities.put(Service.Vpn,vpnCapabilities);
  capabilities.put(Service.Dns,null);
  capabilities.put(Service.UserData,null);
  capabilities.put(Service.Dhcp,null);
  capabilities.put(Service.Gateway,null);
  return capabilities;
}

Fixed version (ground truth):
private static Map<Service,Map<Capability,String>> setCapabilities(){
  Map<Service,Map<Capability,String>> capabilities=new HashMap<Service,Map<Capability,String>>();
  Map<Capability,String> lbCapabilities=new HashMap<Capability,String>();
  lbCapabilities.put(Capability.SupportedLBAlgorithms,"String_Node_Str");
  lbCapabilities.put(Capability.SupportedProtocols,"String_Node_Str");
  capabilities.put(Service.Lb,lbCapabilities);
  Map<Capability,String> firewallCapabilities=new HashMap<Capability,String>();
  firewallCapabilities.put(Capability.PortForwarding,"String_Node_Str");
  firewallCapabilities.put(Capability.TrafficStatistics,"String_Node_Str");
  firewallCapabilities.put(Capability.StaticNat,"String_Node_Str");
  firewallCapabilities.put(Capability.SupportedProtocols,"String_Node_Str");
  firewallCapabilities.put(Capability.MultipleIps,"String_Node_Str");
  firewallCapabilities.put(Capability.SupportedSourceNatTypes,"String_Node_Str");
  capabilities.put(Service.Firewall,firewallCapabilities);
  Map<Capability,String> vpnCapabilities=new HashMap<Capability,String>();
  vpnCapabilities.put(Capability.SupportedVpnTypes,"String_Node_Str");
  capabilities.put(Service.Vpn,vpnCapabilities);
  Map<Capability,String> dnsCapabilities=new HashMap<Capability,String>();
  dnsCapabilities.put(Capability.AllowDnsSuffixModification,"String_Node_Str");
  capabilities.put(Service.Dns,dnsCapabilities);
  capabilities.put(Service.UserData,null);
  capabilities.put(Service.Dhcp,null);
  capabilities.put(Service.Gateway,null);
  return capabilities;
}
Program: 106997
Project: 106997
Buggy source:
/** 
 * Returns the secondary storage host
 * @param zoneId
 * @return secondary storage host
 */
public VMTemplateHostVO findVmTemplateHost(long templateId,long dcId,Long podId);

Fixed version (ground truth):
/** 
 * Returns the secondary storage host
 * @param zoneId
 * @return secondary storage host
 */
public VMTemplateHostVO findVmTemplateHost(long templateId,StoragePool pool);
Program: 106998
Project: 106998
Buggy source:
@Override public VMTemplateHostVO findVmTemplateHost(long templateId,long dcId,Long podId){
  List<HostVO> secHosts=_hostDao.listSecondaryStorageHosts(dcId);
  if (secHosts.size() == 1) {
    VMTemplateHostVO templateHostVO=_templateHostDao.findByHostTemplate(secHosts.get(0).getId(),templateId);
    return templateHostVO;
  }
  if (podId != null) {
    List<VMTemplateHostVO> templHosts=_templateHostDao.listByTemplateStatus(templateId,dcId,podId,VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
    if (templHosts != null && !templHosts.isEmpty()) {
      Collections.shuffle(templHosts);
      return templHosts.get(0);
    }
  }
  List<VMTemplateHostVO> templHosts=_templateHostDao.listByTemplateStatus(templateId,dcId,VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
  if (templHosts != null && !templHosts.isEmpty()) {
    Collections.shuffle(templHosts);
    return templHosts.get(0);
  }
  return null;
}

Fixed version (ground truth):
@Override public VMTemplateHostVO findVmTemplateHost(long templateId,StoragePool pool){
  long dcId=pool.getDataCenterId();
  Long podId=pool.getPodId();
  if (pool.isLocal() && pool.getPoolType() == StoragePoolType.Filesystem) {
    List<StoragePoolHostVO> sphs=_storagePoolHostDao.listByPoolId(pool.getId());
    if (!sphs.isEmpty()) {
      StoragePoolHostVO localStoragePoolHost=sphs.get(0);
      return _templateHostDao.findLocalSecondaryStorageByHostTemplate(localStoragePoolHost.getHostId(),templateId);
    }
 else {
      return null;
    }
  }
  List<HostVO> secHosts=_hostDao.listSecondaryStorageHosts(dcId);
  if (secHosts.size() == 1) {
    VMTemplateHostVO templateHostVO=_templateHostDao.findByHostTemplate(secHosts.get(0).getId(),templateId);
    return templateHostVO;
  }
  if (podId != null) {
    List<VMTemplateHostVO> templHosts=_templateHostDao.listByTemplateStatus(templateId,dcId,podId,VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
    if (templHosts != null && !templHosts.isEmpty()) {
      Collections.shuffle(templHosts);
      return templHosts.get(0);
    }
  }
  List<VMTemplateHostVO> templHosts=_templateHostDao.listByTemplateStatus(templateId,dcId,VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
  if (templHosts != null && !templHosts.isEmpty()) {
    Collections.shuffle(templHosts);
    return templHosts.get(0);
  }
  return null;
}
Program: 107000
Project: 107000
Buggy source:
@Override public boolean configure(String name,Map<String,Object> params) throws ConfigurationException {
  boolean result=super.configure(name,params);
  ZONE_TEMPLATE_SEARCH=createSearchBuilder();
  ZONE_TEMPLATE_SEARCH.and("String_Node_Str",ZONE_TEMPLATE_SEARCH.entity().getTemplateId(),SearchCriteria.Op.EQ);
  ZONE_TEMPLATE_SEARCH.and("String_Node_Str",ZONE_TEMPLATE_SEARCH.entity().getDownloadState(),SearchCriteria.Op.EQ);
  SearchBuilder<HostVO> hostSearch=_hostDao.createSearchBuilder();
  hostSearch.and("String_Node_Str",hostSearch.entity().getDataCenterId(),SearchCriteria.Op.EQ);
  ZONE_TEMPLATE_SEARCH.join("String_Node_Str",hostSearch,hostSearch.entity().getId(),ZONE_TEMPLATE_SEARCH.entity().getHostId(),JoinBuilder.JoinType.INNER);
  ZONE_TEMPLATE_SEARCH.done();
  return result;
}

Fixed version (ground truth):
@Override public boolean configure(String name,Map<String,Object> params) throws ConfigurationException {
  boolean result=super.configure(name,params);
  ZONE_TEMPLATE_SEARCH=createSearchBuilder();
  ZONE_TEMPLATE_SEARCH.and("String_Node_Str",ZONE_TEMPLATE_SEARCH.entity().getTemplateId(),SearchCriteria.Op.EQ);
  ZONE_TEMPLATE_SEARCH.and("String_Node_Str",ZONE_TEMPLATE_SEARCH.entity().getDownloadState(),SearchCriteria.Op.EQ);
  SearchBuilder<HostVO> hostSearch=_hostDao.createSearchBuilder();
  hostSearch.and("String_Node_Str",hostSearch.entity().getDataCenterId(),SearchCriteria.Op.EQ);
  ZONE_TEMPLATE_SEARCH.join("String_Node_Str",hostSearch,hostSearch.entity().getId(),ZONE_TEMPLATE_SEARCH.entity().getHostId(),JoinBuilder.JoinType.INNER);
  ZONE_TEMPLATE_SEARCH.done();
  LOCAL_SECONDARY_STORAGE_SEARCH=createSearchBuilder();
  LOCAL_SECONDARY_STORAGE_SEARCH.and("String_Node_Str",LOCAL_SECONDARY_STORAGE_SEARCH.entity().getTemplateId(),SearchCriteria.Op.EQ);
  LOCAL_SECONDARY_STORAGE_SEARCH.and("String_Node_Str",LOCAL_SECONDARY_STORAGE_SEARCH.entity().getDownloadState(),SearchCriteria.Op.EQ);
  SearchBuilder<HostVO> localSecondaryHost=_hostDao.createSearchBuilder();
  localSecondaryHost.and("String_Node_Str",localSecondaryHost.entity().getPrivateIpAddress(),SearchCriteria.Op.EQ);
  localSecondaryHost.and("String_Node_Str",localSecondaryHost.entity().getStatus(),SearchCriteria.Op.EQ);
  localSecondaryHost.and("String_Node_Str",localSecondaryHost.entity().getDataCenterId(),SearchCriteria.Op.EQ);
  localSecondaryHost.and("String_Node_Str",localSecondaryHost.entity().getType(),SearchCriteria.Op.EQ);
  LOCAL_SECONDARY_STORAGE_SEARCH.join("String_Node_Str",localSecondaryHost,localSecondaryHost.entity().getId(),LOCAL_SECONDARY_STORAGE_SEARCH.entity().getHostId(),JoinBuilder.JoinType.INNER);
  LOCAL_SECONDARY_STORAGE_SEARCH.done();
  return result;
}
Program: 107001
Project: 107001
Buggy source:
@Override public List<VMTemplateHostVO> listByZoneTemplate(long dcId,long templateId,boolean readyOnly){
  SearchCriteria<VMTemplateHostVO> sc=ZONE_TEMPLATE_SEARCH.create();
  sc.setParameters("String_Node_Str",templateId);
  sc.setJoinParameters("String_Node_Str","String_Node_Str",dcId);
  if (readyOnly) {
    sc.setParameters("String_Node_Str",VMTemplateHostVO.Status.DOWNLOADED);
    List<VMTemplateHostVO> tmplHost=new ArrayList<VMTemplateHostVO>();
    tmplHost.add(findOneBy(sc));
    return tmplHost;
  }
 else {
    return listBy(sc);
  }
}

Fixed version (ground truth):
@Override public List<VMTemplateHostVO> listByZoneTemplate(long dcId,long templateId,boolean readyOnly){
  SearchCriteria<VMTemplateHostVO> sc=ZONE_TEMPLATE_SEARCH.create();
  sc.setParameters("String_Node_Str",templateId);
  sc.setJoinParameters("String_Node_Str","String_Node_Str",dcId);
  if (readyOnly) {
    sc.setParameters("String_Node_Str",VMTemplateHostVO.Status.DOWNLOADED);
  }
  return listBy(sc);
}
Program: 107003
Project: 107003
Buggy source:
/** 
 * Returns the secondary storage host
 * @param zoneId
 * @return secondary storage host
 */
public VMTemplateHostVO findVmTemplateHost(long templateId,long dcId,Long podId);

Fixed version (ground truth):
/** 
 * Returns the secondary storage host
 * @param zoneId
 * @return secondary storage host
 */
public VMTemplateHostVO findVmTemplateHost(long templateId,StoragePool pool);
Program: 107004
Project: 107004
Buggy source:
@Override public VMTemplateHostVO findVmTemplateHost(long templateId,long dcId,Long podId){
  List<HostVO> secHosts=_hostDao.listSecondaryStorageHosts(dcId);
  if (secHosts.size() == 1) {
    VMTemplateHostVO templateHostVO=_templateHostDao.findByHostTemplate(secHosts.get(0).getId(),templateId);
    return templateHostVO;
  }
  if (podId != null) {
    List<VMTemplateHostVO> templHosts=_templateHostDao.listByTemplateStatus(templateId,dcId,podId,VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
    if (templHosts != null && !templHosts.isEmpty()) {
      Collections.shuffle(templHosts);
      return templHosts.get(0);
    }
  }
  List<VMTemplateHostVO> templHosts=_templateHostDao.listByTemplateStatus(templateId,dcId,VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
  if (templHosts != null && !templHosts.isEmpty()) {
    Collections.shuffle(templHosts);
    return templHosts.get(0);
  }
  return null;
}

Fixed version (ground truth):
@Override public VMTemplateHostVO findVmTemplateHost(long templateId,StoragePool pool){
  long dcId=pool.getDataCenterId();
  Long podId=pool.getPodId();
  if (pool.isLocal() && pool.getPoolType() == StoragePoolType.Filesystem) {
    List<StoragePoolHostVO> sphs=_storagePoolHostDao.listByPoolId(pool.getId());
    if (!sphs.isEmpty()) {
      StoragePoolHostVO localStoragePoolHost=sphs.get(0);
      return _templateHostDao.findLocalSecondaryStorageByHostTemplate(localStoragePoolHost.getHostId(),templateId);
    }
 else {
      return null;
    }
  }
  List<HostVO> secHosts=_hostDao.listSecondaryStorageHosts(dcId);
  if (secHosts.size() == 1) {
    VMTemplateHostVO templateHostVO=_templateHostDao.findByHostTemplate(secHosts.get(0).getId(),templateId);
    return templateHostVO;
  }
  if (podId != null) {
    List<VMTemplateHostVO> templHosts=_templateHostDao.listByTemplateStatus(templateId,dcId,podId,VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
    if (templHosts != null && !templHosts.isEmpty()) {
      Collections.shuffle(templHosts);
      return templHosts.get(0);
    }
  }
  List<VMTemplateHostVO> templHosts=_templateHostDao.listByTemplateStatus(templateId,dcId,VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
  if (templHosts != null && !templHosts.isEmpty()) {
    Collections.shuffle(templHosts);
    return templHosts.get(0);
  }
  return null;
}
Program: 107006
Project: 107006
Buggy source:
@Override public boolean configure(String name,Map<String,Object> params) throws ConfigurationException {
  boolean result=super.configure(name,params);
  ZONE_TEMPLATE_SEARCH=createSearchBuilder();
  ZONE_TEMPLATE_SEARCH.and("String_Node_Str",ZONE_TEMPLATE_SEARCH.entity().getTemplateId(),SearchCriteria.Op.EQ);
  ZONE_TEMPLATE_SEARCH.and("String_Node_Str",ZONE_TEMPLATE_SEARCH.entity().getDownloadState(),SearchCriteria.Op.EQ);
  SearchBuilder<HostVO> hostSearch=_hostDao.createSearchBuilder();
  hostSearch.and("String_Node_Str",hostSearch.entity().getDataCenterId(),SearchCriteria.Op.EQ);
  ZONE_TEMPLATE_SEARCH.join("String_Node_Str",hostSearch,hostSearch.entity().getId(),ZONE_TEMPLATE_SEARCH.entity().getHostId(),JoinBuilder.JoinType.INNER);
  ZONE_TEMPLATE_SEARCH.done();
  return result;
}

Fixed version (ground truth):
@Override public boolean configure(String name,Map<String,Object> params) throws ConfigurationException {
  boolean result=super.configure(name,params);
  ZONE_TEMPLATE_SEARCH=createSearchBuilder();
  ZONE_TEMPLATE_SEARCH.and("String_Node_Str",ZONE_TEMPLATE_SEARCH.entity().getTemplateId(),SearchCriteria.Op.EQ);
  ZONE_TEMPLATE_SEARCH.and("String_Node_Str",ZONE_TEMPLATE_SEARCH.entity().getDownloadState(),SearchCriteria.Op.EQ);
  SearchBuilder<HostVO> hostSearch=_hostDao.createSearchBuilder();
  hostSearch.and("String_Node_Str",hostSearch.entity().getDataCenterId(),SearchCriteria.Op.EQ);
  ZONE_TEMPLATE_SEARCH.join("String_Node_Str",hostSearch,hostSearch.entity().getId(),ZONE_TEMPLATE_SEARCH.entity().getHostId(),JoinBuilder.JoinType.INNER);
  ZONE_TEMPLATE_SEARCH.done();
  LOCAL_SECONDARY_STORAGE_SEARCH=createSearchBuilder();
  LOCAL_SECONDARY_STORAGE_SEARCH.and("String_Node_Str",LOCAL_SECONDARY_STORAGE_SEARCH.entity().getTemplateId(),SearchCriteria.Op.EQ);
  LOCAL_SECONDARY_STORAGE_SEARCH.and("String_Node_Str",LOCAL_SECONDARY_STORAGE_SEARCH.entity().getDownloadState(),SearchCriteria.Op.EQ);
  SearchBuilder<HostVO> localSecondaryHost=_hostDao.createSearchBuilder();
  localSecondaryHost.and("String_Node_Str",localSecondaryHost.entity().getPrivateIpAddress(),SearchCriteria.Op.EQ);
  localSecondaryHost.and("String_Node_Str",localSecondaryHost.entity().getStatus(),SearchCriteria.Op.EQ);
  localSecondaryHost.and("String_Node_Str",localSecondaryHost.entity().getDataCenterId(),SearchCriteria.Op.EQ);
  localSecondaryHost.and("String_Node_Str",localSecondaryHost.entity().getType(),SearchCriteria.Op.EQ);
  LOCAL_SECONDARY_STORAGE_SEARCH.join("String_Node_Str",localSecondaryHost,localSecondaryHost.entity().getId(),LOCAL_SECONDARY_STORAGE_SEARCH.entity().getHostId(),JoinBuilder.JoinType.INNER);
  LOCAL_SECONDARY_STORAGE_SEARCH.done();
  return result;
}
Program: 107007
Project: 107007
Buggy source:
@Override public List<VMTemplateHostVO> listByZoneTemplate(long dcId,long templateId,boolean readyOnly){
  SearchCriteria<VMTemplateHostVO> sc=ZONE_TEMPLATE_SEARCH.create();
  sc.setParameters("String_Node_Str",templateId);
  sc.setJoinParameters("String_Node_Str","String_Node_Str",dcId);
  if (readyOnly) {
    sc.setParameters("String_Node_Str",VMTemplateHostVO.Status.DOWNLOADED);
    List<VMTemplateHostVO> tmplHost=new ArrayList<VMTemplateHostVO>();
    tmplHost.add(findOneBy(sc));
    return tmplHost;
  }
 else {
    return listBy(sc);
  }
}

Fixed version (ground truth):
@Override public List<VMTemplateHostVO> listByZoneTemplate(long dcId,long templateId,boolean readyOnly){
  SearchCriteria<VMTemplateHostVO> sc=ZONE_TEMPLATE_SEARCH.create();
  sc.setParameters("String_Node_Str",templateId);
  sc.setJoinParameters("String_Node_Str","String_Node_Str",dcId);
  if (readyOnly) {
    sc.setParameters("String_Node_Str",VMTemplateHostVO.Status.DOWNLOADED);
  }
  return listBy(sc);
}
Program: 107009
Project: 107009
Buggy source:
private boolean validateVolumeSizeRange(long size){
  if (size < 0 || (size > 0 && size < (1024 * 1024 * 1024))) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
 else   if (size > _maxVolumeSizeInGb) {
    throw new InvalidParameterValueException("String_Node_Str" + _maxVolumeSizeInGb + "String_Node_Str");
  }
  return true;
}

Fixed version (ground truth):
private boolean validateVolumeSizeRange(long size){
  if (size < 0 || (size > 0 && size < (1024 * 1024 * 1024))) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
 else   if (size > (_maxVolumeSizeInGb * 1024 * 1024* 1024)) {
    throw new InvalidParameterValueException("String_Node_Str" + size + "String_Node_Str"+ _maxVolumeSizeInGb+ "String_Node_Str");
  }
  return true;
}
Program: 107013
Project: 107013
Buggy source:
public static long getAgentId(final byte[] bytes){
  return NumbersUtil.bytesToLong(bytes,28);
}

Fixed version (ground truth):
public static long getAgentId(final byte[] bytes){
  return NumbersUtil.bytesToLong(bytes,24);
}
Program: 107014
Project: 107014
Buggy source:
/** 
 */
public static Request parse(final byte[] bytes) throws ClassNotFoundException, UnsupportedVersionException {
  final ByteBuffer buff=ByteBuffer.wrap(bytes);
  final byte ver=buff.get();
  final Version version=Version.get(ver);
  if (version.ordinal() != Version.v1.ordinal()) {
    throw new UnsupportedVersionException("String_Node_Str" + version.toString(),UnsupportedVersionException.IncompatibleVersion);
  }
  final byte reserved=buff.get();
  final short flags=buff.getShort();
  final boolean isRequest=(flags & FLAG_REQUEST) > 0;
  final long seq=buff.getLong();
  final int size=buff.getInt();
  final long mgmtId=buff.getLong();
  final long agentId=buff.getLong();
  final long via=buff.getLong();
  byte[] command=null;
  int offset=0;
  if (buff.hasArray()) {
    command=buff.array();
    offset=buff.arrayOffset() + buff.position();
  }
 else {
    command=new byte[buff.remaining()];
    buff.get(command);
    offset=0;
  }
  final String content=new String(command,offset,command.length - offset);
  if (isRequest) {
    return new Request(version,seq,agentId,mgmtId,via,flags,content);
  }
 else {
    return new Response(Version.get(ver),seq,agentId,mgmtId,via,flags,content);
  }
}

Fixed version (ground truth):
/** 
 */
public static Request parse(final byte[] bytes) throws ClassNotFoundException, UnsupportedVersionException {
  final ByteBuffer buff=ByteBuffer.wrap(bytes);
  final byte ver=buff.get();
  final Version version=Version.get(ver);
  if (version.ordinal() != Version.v1.ordinal() && version.ordinal() != Version.v3.ordinal()) {
    throw new UnsupportedVersionException("String_Node_Str" + version.toString(),UnsupportedVersionException.IncompatibleVersion);
  }
  final byte reserved=buff.get();
  final short flags=buff.getShort();
  final boolean isRequest=(flags & FLAG_REQUEST) > 0;
  final long seq=buff.getLong();
  final int size=buff.getInt();
  final long mgmtId=buff.getLong();
  final long agentId=buff.getLong();
  long via;
  if (version.ordinal() == Version.v1.ordinal()) {
    via=buff.getLong();
  }
 else {
    via=agentId;
  }
  byte[] command=null;
  int offset=0;
  if (buff.hasArray()) {
    command=buff.array();
    offset=buff.arrayOffset() + buff.position();
  }
 else {
    command=new byte[buff.remaining()];
    buff.get(command);
    offset=0;
  }
  final String content=new String(command,offset,command.length - offset);
  if (isRequest) {
    return new Request(version,seq,agentId,mgmtId,via,flags,content);
  }
 else {
    return new Response(Version.get(ver),seq,agentId,mgmtId,via,flags,content);
  }
}
Program: 107015
Project: 107015
Buggy source:
public static long getViaAgentId(final byte[] bytes){
  return NumbersUtil.bytesToLong(bytes,24);
}

Fixed version (ground truth):
public static long getViaAgentId(final byte[] bytes){
  return NumbersUtil.bytesToLong(bytes,32);
}
Program: 107018
Project: 107018
Buggy source:
@Override public Map<String,TemplateInfo> gatherTemplateInfo(String rootDir){
  Map<String,TemplateInfo> result=new HashMap<String,TemplateInfo>();
  String templateDir=rootDir + File.separator + _templateDir;
  List<String> publicTmplts=listTemplates(templateDir);
  for (  String tmplt : publicTmplts) {
    String path=tmplt.substring(0,tmplt.lastIndexOf(File.separator));
    TemplateLocation loc=new TemplateLocation(_storage,path);
    try {
      if (!loc.load()) {
        s_logger.warn("String_Node_Str" + path);
        _storage.cleanup(path,templateDir);
        continue;
      }
    }
 catch (    IOException e) {
      s_logger.warn("String_Node_Str" + path,e);
      try {
        _storage.cleanup(path,templateDir);
      }
 catch (      IOException e1) {
        s_logger.warn("String_Node_Str" + path,e1);
      }
      continue;
    }
    TemplateInfo tInfo=loc.getTemplateInfo();
    result.put(tInfo.templateName,tInfo);
    s_logger.debug("String_Node_Str" + tInfo.templateName + "String_Node_Str"+ tmplt);
  }
  return result;
}

Fixed version (ground truth):
@Override public Map<String,TemplateInfo> gatherTemplateInfo(String rootDir){
  Map<String,TemplateInfo> result=new HashMap<String,TemplateInfo>();
  String templateDir=rootDir + File.separator + _templateDir;
  if (!_storage.exists(templateDir)) {
    _storage.mkdirs(templateDir);
  }
  List<String> publicTmplts=listTemplates(templateDir);
  for (  String tmplt : publicTmplts) {
    String path=tmplt.substring(0,tmplt.lastIndexOf(File.separator));
    TemplateLocation loc=new TemplateLocation(_storage,path);
    try {
      if (!loc.load()) {
        s_logger.warn("String_Node_Str" + path);
        _storage.cleanup(path,templateDir);
        continue;
      }
    }
 catch (    IOException e) {
      s_logger.warn("String_Node_Str" + path,e);
      try {
        _storage.cleanup(path,templateDir);
      }
 catch (      IOException e1) {
        s_logger.warn("String_Node_Str" + path,e1);
      }
      continue;
    }
    TemplateInfo tInfo=loc.getTemplateInfo();
    result.put(tInfo.templateName,tInfo);
    s_logger.debug("String_Node_Str" + tInfo.templateName + "String_Node_Str"+ tmplt);
  }
  return result;
}
Program: 107019
Project: 107019
Buggy source:
protected Status investigate(AgentAttache agent){
  Long hostId=agent.getId();
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + hostId + "String_Node_Str");
  }
  try {
    Request req=new Request(hostId,_nodeId,new CheckHealthCommand(),true);
    Answer[] answers=agent.send(req,50 * 1000);
    if (answers != null && answers[0] != null) {
      Status status=answers[0].getResult() ? Status.Up : Status.Down;
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ status);
      }
      return status;
    }
  }
 catch (  AgentUnavailableException e) {
    s_logger.debug("String_Node_Str");
  }
catch (  OperationTimedoutException e) {
    s_logger.debug("String_Node_Str" + e.getMessage());
  }
  return _haMgr.investigate(hostId);
}

Fixed version (ground truth):
protected Status investigate(AgentAttache agent){
  Long hostId=agent.getId();
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + hostId + "String_Node_Str");
  }
  try {
    Request req=new Request(hostId,_nodeId,new CheckHealthCommand(),true);
    req.setSequence(agent.getNextSequence());
    Answer[] answers=agent.send(req,50 * 1000);
    if (answers != null && answers[0] != null) {
      Status status=answers[0].getResult() ? Status.Up : Status.Down;
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ status);
      }
      return status;
    }
  }
 catch (  AgentUnavailableException e) {
    s_logger.debug("String_Node_Str");
  }
catch (  OperationTimedoutException e) {
    s_logger.debug("String_Node_Str" + e.getMessage());
  }
  return _haMgr.investigate(hostId);
}
Program: 107022
Project: 107022
Buggy source:
protected void runScript(File file){
  try {
    FileReader reader=new FileReader(file);
    Connection conn=Transaction.getStandaloneConnection();
    ScriptRunner runner=new ScriptRunner(conn,false,true);
    runner.runScript(reader);
  }
 catch (  FileNotFoundException e) {
    s_logger.error("String_Node_Str" + file.getAbsolutePath(),e);
    throw new CloudRuntimeException("String_Node_Str" + file.getAbsolutePath(),e);
  }
catch (  IOException e) {
    s_logger.error("String_Node_Str" + file.getAbsolutePath(),e);
    throw new CloudRuntimeException("String_Node_Str" + file.getAbsolutePath(),e);
  }
catch (  SQLException e) {
    s_logger.error("String_Node_Str" + file.getAbsolutePath(),e);
    throw new CloudRuntimeException("String_Node_Str" + file.getAbsolutePath(),e);
  }
}

Fixed version (ground truth):
protected void runScript(Connection conn,File file){
  try {
    FileReader reader=new FileReader(file);
    ScriptRunner runner=new ScriptRunner(conn,false,true);
    runner.runScript(reader);
  }
 catch (  FileNotFoundException e) {
    s_logger.error("String_Node_Str" + file.getAbsolutePath(),e);
    throw new CloudRuntimeException("String_Node_Str" + file.getAbsolutePath(),e);
  }
catch (  IOException e) {
    s_logger.error("String_Node_Str" + file.getAbsolutePath(),e);
    throw new CloudRuntimeException("String_Node_Str" + file.getAbsolutePath(),e);
  }
catch (  SQLException e) {
    s_logger.error("String_Node_Str" + file.getAbsolutePath(),e);
    throw new CloudRuntimeException("String_Node_Str" + file.getAbsolutePath(),e);
  }
}
Program: 107025
Project: 107025
Buggy source:
@Override public <T extends VMInstanceVO>T advanceReboot(T vm,Map<VirtualMachineProfile.Param,Object> params,User caller,Account account) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
  T rebootedVm=null;
  DataCenter dc=_configMgr.getZone(vm.getDataCenterId());
  HostPodVO pod=_configMgr.getPod(vm.getPodId());
  Host host=_hostDao.findById(vm.getHostId());
  Cluster cluster=null;
  if (host != null) {
    cluster=_configMgr.getCluster(host.getClusterId());
  }
  DeployDestination dest=new DeployDestination(dc,pod,cluster,host);
  try {
    Commands cmds=new Commands(OnError.Revert);
    cmds.addCommand(new RebootCommand(vm.getInstanceName()));
    _agentMgr.send(host.getId(),cmds);
    Answer rebootAnswer=cmds.getAnswer(RebootAnswer.class);
    if (rebootAnswer != null && rebootAnswer.getResult()) {
      rebootedVm=vm;
      return rebootedVm;
    }
    s_logger.info("String_Node_Str" + vm + "String_Node_Str"+ dest.getHost()+ "String_Node_Str"+ (rebootAnswer == null ? "String_Node_Str" : rebootAnswer.getDetails()));
  }
 catch (  OperationTimedoutException e) {
    s_logger.warn("String_Node_Str" + dest.getHost() + "String_Node_Str"+ vm+ "String_Node_Str",e);
    throw new CloudRuntimeException("String_Node_Str" + dest.getHost());
  }
  return rebootedVm;
}

Fixed version (ground truth):
@Override public <T extends VMInstanceVO>T advanceReboot(T vm,Map<VirtualMachineProfile.Param,Object> params,User caller,Account account) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
  T rebootedVm=null;
  DataCenter dc=_configMgr.getZone(vm.getDataCenterId());
  Host host=_hostDao.findById(vm.getHostId());
  Cluster cluster=null;
  if (host != null) {
    cluster=_configMgr.getCluster(host.getClusterId());
  }
  HostPodVO pod=_configMgr.getPod(host.getPodId());
  DeployDestination dest=new DeployDestination(dc,pod,cluster,host);
  try {
    Commands cmds=new Commands(OnError.Revert);
    cmds.addCommand(new RebootCommand(vm.getInstanceName()));
    _agentMgr.send(host.getId(),cmds);
    Answer rebootAnswer=cmds.getAnswer(RebootAnswer.class);
    if (rebootAnswer != null && rebootAnswer.getResult()) {
      rebootedVm=vm;
      return rebootedVm;
    }
    s_logger.info("String_Node_Str" + vm + "String_Node_Str"+ dest.getHost()+ "String_Node_Str"+ (rebootAnswer == null ? "String_Node_Str" : rebootAnswer.getDetails()));
  }
 catch (  OperationTimedoutException e) {
    s_logger.warn("String_Node_Str" + dest.getHost() + "String_Node_Str"+ vm+ "String_Node_Str",e);
    throw new CloudRuntimeException("String_Node_Str" + dest.getHost());
  }
  return rebootedVm;
}
Program: 107027
Project: 107027
Buggy source:
@Override public void performDataMigration(Connection conn){
  createSecurityGroups(conn);
}

Fixed version (ground truth):
@Override public void performDataMigration(Connection conn){
  createSecurityGroups(conn);
  dropKeysIfExist(conn);
  dropTableColumnsIfExist(conn);
  addMissingKeys(conn);
  addMissingOvsAccount(conn);
}
Program: 107028
Project: 107028
Buggy source:
@Override public File[] getCleanupScripts(){
  return null;
}

Fixed version (ground truth):
@Override public File[] getCleanupScripts(){
  String file=Script.findScript("String_Node_Str","String_Node_Str");
  if (file == null) {
    throw new CloudRuntimeException("String_Node_Str");
  }
  return new File[]{new File(file)};
}
Program: 107029
Project: 107029
Buggy source:
@Override public Answer executeRequest(Command cmd){
  if (cmd instanceof DownloadProgressCommand) {
    return _dlMgr.handleDownloadCommand(this,(DownloadProgressCommand)cmd);
  }
 else   if (cmd instanceof DownloadCommand) {
    return _dlMgr.handleDownloadCommand(this,(DownloadCommand)cmd);
  }
 else   if (cmd instanceof CheckHealthCommand) {
    return new CheckHealthAnswer((CheckHealthCommand)cmd,true);
  }
 else   if (cmd instanceof SecStorageSetupCommand) {
    return new Answer(cmd,true,"String_Node_Str");
  }
 else   if (cmd instanceof ReadyCommand) {
    return new ReadyAnswer((ReadyCommand)cmd);
  }
 else   if (cmd instanceof ListTemplateCommand) {
    return execute((ListTemplateCommand)cmd);
  }
 else {
    return Answer.createUnsupportedCommandAnswer(cmd);
  }
}

Fixed version (ground truth):
@Override public Answer executeRequest(Command cmd){
  if (cmd instanceof DownloadProgressCommand) {
    return _dlMgr.handleDownloadCommand(this,(DownloadProgressCommand)cmd);
  }
 else   if (cmd instanceof DownloadCommand) {
    return _dlMgr.handleDownloadCommand(this,(DownloadCommand)cmd);
  }
 else   if (cmd instanceof CheckHealthCommand) {
    return new CheckHealthAnswer((CheckHealthCommand)cmd,true);
  }
 else   if (cmd instanceof SecStorageSetupCommand) {
    return new Answer(cmd,true,"String_Node_Str");
  }
 else   if (cmd instanceof ReadyCommand) {
    return new ReadyAnswer((ReadyCommand)cmd);
  }
 else   if (cmd instanceof ListTemplateCommand) {
    return execute((ListTemplateCommand)cmd);
  }
 else   if (cmd instanceof ComputeChecksumCommand) {
    return execute((ComputeChecksumCommand)cmd);
  }
 else {
    return Answer.createUnsupportedCommandAnswer(cmd);
  }
}
Program: 107031
Project: 107031
Buggy source:
@Override public HostVO getSecondaryStorageHost(long zoneId){
  List<HostVO> hosts=_hostDao.listSecondaryStorageHosts(zoneId);
  if (hosts == null || hosts.size() == 0) {
    return null;
  }
  int size=hosts.size();
  Random rn=new Random();
  int index=rn.nextInt(size);
  return hosts.get(index);
}

Fixed version (ground truth):
@Override public HostVO getSecondaryStorageHost(long zoneId){
  List<HostVO> hosts=_hostDao.listSecondaryStorageHosts(zoneId);
  if (hosts == null || hosts.size() == 0) {
    hosts=_hostDao.listLocalSecondaryStorageHosts(zoneId);
    if (hosts.isEmpty()) {
      return null;
    }
  }
  int size=hosts.size();
  Random rn=new Random();
  int index=rn.nextInt(size);
  return hosts.get(index);
}
Program: 107032
Project: 107032
Buggy source:
@Override public boolean downloadTemplateToStorage(Long templateId,Long zoneId){
  List<DataCenterVO> dcs=new ArrayList<DataCenterVO>();
  if (zoneId == null) {
    dcs.addAll(_dcDao.listAll());
  }
 else {
    dcs.add(_dcDao.findById(zoneId));
  }
  for (  DataCenterVO dc : dcs) {
    List<HostVO> ssHosts=_hostDao.listBy(Host.Type.SecondaryStorage,dc.getId());
    for (    HostVO ssHost : ssHosts) {
      if (isTemplateUpdateable(ssHost.getId(),templateId)) {
        initiateTemplateDownload(templateId,ssHost);
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean downloadTemplateToStorage(Long templateId,Long zoneId){
  List<DataCenterVO> dcs=new ArrayList<DataCenterVO>();
  if (zoneId == null) {
    dcs.addAll(_dcDao.listAll());
  }
 else {
    dcs.add(_dcDao.findById(zoneId));
  }
  for (  DataCenterVO dc : dcs) {
    List<HostVO> ssHosts=_hostDao.listAllSecondaryStorageHosts(dc.getId());
    for (    HostVO ssHost : ssHosts) {
      if (isTemplateUpdateable(ssHost.getId(),templateId)) {
        initiateTemplateDownload(templateId,ssHost);
      }
    }
  }
  return true;
}
Program: 107034
Project: 107034
Buggy source:
@Override public String getChecksum(Long hostId,String templatePath){
  HostVO ssHost=_hostDao.findById(hostId);
  Host.Type type=ssHost.getType();
  if (type != Host.Type.SecondaryStorage && type != Host.Type.LocalSecondaryStorage) {
    return null;
  }
  String secUrl=ssHost.getStorageUrl();
  Answer answer;
  answer=_agentMgr.sendToSecStorage(ssHost,new ComputeChecksumCommand(secUrl,templatePath));
  if (answer.getResult()) {
    return answer.getDetails();
  }
  return null;
}

Fixed version (ground truth):
@Override public String getChecksum(Long hostId,String templatePath){
  HostVO ssHost=_hostDao.findById(hostId);
  Host.Type type=ssHost.getType();
  if (type != Host.Type.SecondaryStorage && type != Host.Type.LocalSecondaryStorage) {
    return null;
  }
  String secUrl=ssHost.getStorageUrl();
  Answer answer;
  answer=_agentMgr.sendToSecStorage(ssHost,new ComputeChecksumCommand(secUrl,templatePath));
  if (answer != null && answer.getResult()) {
    return answer.getDetails();
  }
  return null;
}
Program: 107037
Project: 107037
Buggy source:
private void dropTableColumnsIfExist(Connection conn,String tableName,List<String> columns){
  try {
    for (    String column : columns) {
      try {
        PreparedStatement pstmt=conn.prepareStatement("String_Node_Str" + column + "String_Node_Str"+ tableName);
        pstmt.executeQuery();
      }
 catch (      SQLException e) {
        s_logger.trace("String_Node_Str" + column + "String_Node_Str"+ tableName);
        continue;
      }
      PreparedStatement pstmt=conn.prepareStatement("String_Node_Str" + tableName + "String_Node_Str"+ column);
      pstmt.executeUpdate();
      s_logger.debug("String_Node_Str" + column + "String_Node_Str"+ tableName);
      pstmt.close();
    }
  }
 catch (  SQLException e) {
    throw new CloudRuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
private void dropTableColumnsIfExist(Connection conn,String tableName,List<String> columns){
  PreparedStatement pstmt=null;
  try {
    for (    String column : columns) {
      try {
        pstmt=conn.prepareStatement("String_Node_Str" + column + "String_Node_Str"+ tableName);
        pstmt.executeQuery();
      }
 catch (      SQLException e) {
        s_logger.trace("String_Node_Str" + column + "String_Node_Str"+ tableName);
        continue;
      }
      pstmt=conn.prepareStatement("String_Node_Str" + tableName + "String_Node_Str"+ column);
      pstmt.executeUpdate();
      s_logger.debug("String_Node_Str" + column + "String_Node_Str"+ tableName);
      pstmt.close();
    }
  }
 catch (  SQLException e) {
    s_logger.warn("String_Node_Str" + pstmt + "String_Node_Str",e);
    throw new CloudRuntimeException("String_Node_Str",e);
  }
}
Program: 107038
Project: 107038
Buggy source:
@Override public long getEntityOwnerId(){
  VirtualMachineTemplate iso=_responseGenerator.findTemplateById(getId());
  if (iso == null) {
    return Account.ACCOUNT_ID_SYSTEM;
  }
  return iso.getAccountId();
}

Fixed version (ground truth):
@Override public long getEntityOwnerId(){
  UserVm vm=_entityMgr.findById(UserVm.class,getVirtualMachineId());
  if (vm == null) {
    throw new InvalidParameterValueException("String_Node_Str" + getVirtualMachineId());
  }
  return vm.getAccountId();
}
Program: 107039
Project: 107039
Buggy source:
@Override public long getEntityOwnerId(){
  UserVm vm=_entityMgr.findById(UserVm.class,getVirtualMachineId());
  if (vm != null) {
    return vm.getAccountId();
  }
  return Account.ACCOUNT_ID_SYSTEM;
}

Fixed version (ground truth):
@Override public long getEntityOwnerId(){
  UserVm vm=_entityMgr.findById(UserVm.class,getVirtualMachineId());
  if (vm != null) {
    return vm.getAccountId();
  }
 else {
    throw new InvalidParameterValueException("String_Node_Str" + getVirtualMachineId());
  }
}
Program: 107040
Project: 107040
Buggy source:
@Override public long getEntityOwnerId(){
  Account account=UserContext.current().getCaller();
  if ((account == null) || isAdmin(account.getType())) {
    if ((domainId != null) && (accountName != null)) {
      Account userAccount=_responseGenerator.findAccountByNameDomain(accountName,domainId);
      if (userAccount != null) {
        return userAccount.getId();
      }
    }
  }
  if (account != null) {
    return account.getId();
  }
  return Account.ACCOUNT_ID_SYSTEM;
}

Fixed version (ground truth):
@Override public long getEntityOwnerId(){
  Account account=UserContext.current().getCaller();
  if (isAdmin(account.getType())) {
    if ((domainId != null) && (accountName != null)) {
      Account userAccount=_responseGenerator.findAccountByNameDomain(accountName,domainId);
      if (userAccount != null) {
        return userAccount.getId();
      }
 else {
        throw new InvalidParameterValueException("String_Node_Str" + getAccountName() + "String_Node_Str"+ getDomainId());
      }
    }
  }
  return account.getId();
}
Program: 107041
Project: 107041
Buggy source:
@Override public long getEntityOwnerId(){
  Account account=UserContext.current().getCaller();
  if ((account == null) || isAdmin(account.getType())) {
    if ((domainId != null) && (accountName != null)) {
      Account userAccount=_responseGenerator.findAccountByNameDomain(accountName,domainId);
      if (userAccount != null) {
        return userAccount.getId();
      }
    }
  }
  if (account != null) {
    return account.getId();
  }
  return Account.ACCOUNT_ID_SYSTEM;
}

Fixed version (ground truth):
@Override public long getEntityOwnerId(){
  Account account=UserContext.current().getCaller();
  if (isAdmin(account.getType())) {
    if ((domainId != null) && (accountName != null)) {
      Account userAccount=_responseGenerator.findAccountByNameDomain(accountName,domainId);
      if (userAccount != null) {
        return userAccount.getId();
      }
 else {
        throw new InvalidParameterValueException("String_Node_Str" + getAccountName() + "String_Node_Str"+ getDomainId());
      }
    }
  }
  return account.getId();
}
Program: 107042
Project: 107042
Buggy source:
private Long accountAndUserValidation(Account account,Long userId,UserVmVO vmInstanceCheck,VMTemplateVO template,String msg) throws PermissionDeniedException {
  if (account != null) {
    if (!isAdmin(account.getType())) {
      if ((vmInstanceCheck != null) && (account.getId() != vmInstanceCheck.getAccountId())) {
        throw new PermissionDeniedException(msg + "String_Node_Str");
      }
      if ((template != null) && (!template.isPublicTemplate() && (account.getId() != template.getAccountId()) && (template.getTemplateType() != TemplateType.PERHOST))) {
        throw new PermissionDeniedException(msg + "String_Node_Str");
      }
    }
 else {
      if ((vmInstanceCheck != null) && !_domainDao.isChildDomain(account.getDomainId(),vmInstanceCheck.getDomainId())) {
        throw new PermissionDeniedException(msg + "String_Node_Str");
      }
      if (template != null) {
        Account templateOwner=_accountDao.findById(template.getAccountId());
        if ((templateOwner != null) && !_domainDao.isChildDomain(account.getDomainId(),templateOwner.getDomainId())) {
          throw new PermissionDeniedException(msg + "String_Node_Str");
        }
      }
    }
  }
  if (userId == null) {
    userId=new Long(1);
  }
  return userId;
}

Fixed version (ground truth):
private Long accountAndUserValidation(Account caller,Long userId,UserVmVO userVm,VMTemplateVO template,String msg) throws PermissionDeniedException {
  if (caller != null) {
    if (!isAdmin(caller.getType())) {
      if ((userVm != null) && (caller.getId() != userVm.getAccountId())) {
        throw new PermissionDeniedException(msg + "String_Node_Str");
      }
      if ((template != null) && (!template.isPublicTemplate() && (caller.getId() != template.getAccountId()) && (template.getTemplateType() != TemplateType.PERHOST))) {
        throw new PermissionDeniedException(msg + "String_Node_Str");
      }
    }
 else {
      if (userVm != null) {
        _accountMgr.checkAccess(caller,userVm);
      }
      if (template != null && !template.isPublicTemplate()) {
        Account templateOwner=_accountDao.findById(template.getAccountId());
        _accountMgr.checkAccess(caller,templateOwner);
      }
    }
  }
  return userId;
}
Program: 107043
Project: 107043
Buggy source:
@Override public boolean attachIso(AttachIsoCmd cmd){
  Account account=UserContext.current().getCaller();
  Long userId=UserContext.current().getCallerUserId();
  Long vmId=cmd.getVirtualMachineId();
  Long isoId=cmd.getId();
  UserVmVO vmInstanceCheck=_userVmDao.findById(vmId);
  if (vmInstanceCheck == null) {
    throw new InvalidParameterValueException("String_Node_Str" + vmId);
  }
  VMTemplateVO iso=_tmpltDao.findById(isoId);
  if (iso == null) {
    throw new InvalidParameterValueException("String_Node_Str" + isoId);
  }
  State vmState=vmInstanceCheck.getState();
  if (vmState != State.Running && vmState != State.Stopped) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  String errMsg="String_Node_Str" + isoId + "String_Node_Str"+ vmId;
  userId=accountAndUserValidation(account,userId,vmInstanceCheck,iso,errMsg);
  if ("String_Node_Str".equals(iso.getDisplayText()) && vmInstanceCheck.getHypervisorType() != Hypervisor.HypervisorType.XenServer) {
    throw new InvalidParameterValueException("String_Node_Str" + vmInstanceCheck.getHypervisorType());
  }
  return attachISOToVM(vmId,userId,isoId,true);
}

Fixed version (ground truth):
@Override public boolean attachIso(AttachIsoCmd cmd){
  Account caller=UserContext.current().getCaller();
  Long userId=UserContext.current().getCallerUserId();
  Long vmId=cmd.getVirtualMachineId();
  Long isoId=cmd.getId();
  UserVmVO vm=_userVmDao.findById(vmId);
  if (vm == null) {
    throw new InvalidParameterValueException("String_Node_Str" + vmId);
  }
  VMTemplateVO iso=_tmpltDao.findById(isoId);
  if (iso == null) {
    throw new InvalidParameterValueException("String_Node_Str" + isoId);
  }
  State vmState=vm.getState();
  if (vmState != State.Running && vmState != State.Stopped) {
    throw new InvalidParameterValueException("String_Node_Str");
  }
  String errMsg="String_Node_Str" + isoId + "String_Node_Str"+ vmId;
  userId=accountAndUserValidation(caller,userId,vm,iso,errMsg);
  if ("String_Node_Str".equals(iso.getDisplayText()) && vm.getHypervisorType() != Hypervisor.HypervisorType.XenServer) {
    throw new InvalidParameterValueException("String_Node_Str" + vm.getHypervisorType());
  }
  return attachISOToVM(vmId,userId,isoId,true);
}
Program: 107044
Project: 107044
Buggy source:
@Override public void handleSysTemplateDownload(HostVO host){
  List<HypervisorType> hypers=_hostDao.getAvailHypervisorInZone(host.getId(),host.getDataCenterId());
  HypervisorType hostHyper=host.getHypervisorType();
  if (hypers.contains(hostHyper)) {
    return;
  }
  Set<VMTemplateVO> toBeDownloaded=new HashSet<VMTemplateVO>();
  List<HostVO> ssHosts=_hostDao.listBy(Host.Type.SecondaryStorage,host.getDataCenterId());
  if (ssHosts == null || ssHosts.isEmpty()) {
    return;
  }
  HostVO sshost=ssHosts.get(0);
  List<VMTemplateVO> rtngTmplts=_templateDao.listAllSystemVMTemplates();
  List<VMTemplateVO> defaultBuiltin=_templateDao.listDefaultBuiltinTemplates();
  for (  VMTemplateVO rtngTmplt : rtngTmplts) {
    if (rtngTmplt.getHypervisorType() == hostHyper) {
      toBeDownloaded.add(rtngTmplt);
    }
  }
  for (  VMTemplateVO builtinTmplt : defaultBuiltin) {
    if (builtinTmplt.getHypervisorType() == hostHyper) {
      toBeDownloaded.add(builtinTmplt);
    }
  }
  for (  VMTemplateVO template : toBeDownloaded) {
    VMTemplateHostVO tmpltHost=_vmTemplateHostDao.findByHostTemplate(sshost.getId(),template.getId());
    if (tmpltHost == null || tmpltHost.getDownloadState() != Status.DOWNLOADED) {
      downloadTemplateToStorage(template,sshost);
    }
  }
}

Fixed version (ground truth):
@Override public void handleSysTemplateDownload(HostVO host){
  List<HypervisorType> hypers=_hostDao.getAvailHypervisorInZone(host.getId(),host.getDataCenterId());
  HypervisorType hostHyper=host.getHypervisorType();
  if (hypers.contains(hostHyper)) {
    return;
  }
  Set<VMTemplateVO> toBeDownloaded=new HashSet<VMTemplateVO>();
  List<HostVO> ssHosts=_hostDao.listBy(Host.Type.SecondaryStorage,host.getDataCenterId());
  if (ssHosts == null || ssHosts.isEmpty()) {
    return;
  }
  HostVO sshost=ssHosts.get(0);
  List<VMTemplateVO> rtngTmplts=_templateDao.listAllSystemVMTemplates();
  List<VMTemplateVO> defaultBuiltin=_templateDao.listDefaultBuiltinTemplates();
  for (  VMTemplateVO rtngTmplt : rtngTmplts) {
    if (rtngTmplt.getHypervisorType() == hostHyper) {
      toBeDownloaded.add(rtngTmplt);
    }
  }
  for (  VMTemplateVO builtinTmplt : defaultBuiltin) {
    if (builtinTmplt.getHypervisorType() == hostHyper) {
      toBeDownloaded.add(builtinTmplt);
    }
  }
  for (  VMTemplateVO template : toBeDownloaded) {
    VMTemplateHostVO tmpltHost=_vmTemplateHostDao.findByHostTemplate(sshost.getId(),template.getId());
    if (tmpltHost == null || tmpltHost.getDownloadState() != Status.DOWNLOADED) {
      if (_vmTemplateZoneDao.findByZoneTemplate(sshost.getDataCenterId(),template.getId()) == null) {
        _templateDao.addTemplateToZone(template,sshost.getDataCenterId());
      }
      downloadTemplateToStorage(template,sshost);
    }
  }
}