nus-yam/ex-repair huggingface dataset:
Program: 89616
Project: 89616
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: 89619
Project: 89619
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: 89620
Project: 89620
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: 89622
Project: 89622
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: 89623
Project: 89623
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: 89625
Project: 89625
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: 89626
Project: 89626
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: 89628
Project: 89628
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: 89629
Project: 89629
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: 89631
Project: 89631
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: 89632
Project: 89632
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: 89633
Project: 89633
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: 89636
Project: 89636
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: 89638
Project: 89638
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: 89639
Project: 89639
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: 89643
Project: 89643
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: 89646
Project: 89646
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: 89651
Project: 89651
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: 89652
Project: 89652
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: 89654
Project: 89654
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: 89655
Project: 89655
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: 89657
Project: 89657
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: 89658
Project: 89658
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: 89659
Project: 89659
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: 89660
Project: 89660
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: 89661
Project: 89661
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: 89662
Project: 89662
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: 89663
Project: 89663
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: 89664
Project: 89664
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: 89665
Project: 89665
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: 89666
Project: 89666
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);
    }
  }
}
Program: 89667
Project: 89667
Buggy source:
@Override public NicProfile allocate(Network network,NicProfile nic,VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
  DataCenter dc=_dcDao.findById(network.getDataCenterId());
  NetworkOffering offering=_networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId());
  if (!canHandle(offering,dc)) {
    return null;
  }
  if (nic == null) {
    nic=new NicProfile(ReservationStrategy.Create,null,null,null,null);
  }
 else   if (nic.getIp4Address() == null) {
    nic.setStrategy(ReservationStrategy.Start);
  }
 else {
    nic.setStrategy(ReservationStrategy.Create);
  }
  getIp(nic,dc,vm,network);
  if (network.isSecurityGroupEnabled() && nic.getIp4Address() != null) {
    nic.setStrategy(ReservationStrategy.Create);
  }
  return nic;
}

Fixed version (ground truth):
@Override public NicProfile allocate(Network network,NicProfile nic,VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
  DataCenter dc=_dcDao.findById(network.getDataCenterId());
  NetworkOffering offering=_networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId());
  if (!canHandle(offering,dc)) {
    return null;
  }
  if (nic == null) {
    nic=new NicProfile(ReservationStrategy.Create,null,null,null,null);
  }
 else   if (nic.getIp4Address() == null) {
    nic.setStrategy(ReservationStrategy.Start);
  }
 else {
    nic.setStrategy(ReservationStrategy.Create);
  }
  getIp(nic,dc,vm,network);
  nic.setStrategy(ReservationStrategy.Create);
  return nic;
}