nus-yam/ex-repair huggingface dataset:
Program: 105554
Project: 105554
Buggy source:
@Override public long getResourceId(String resourceId,ResourceObjectType resourceType){
  Class<?> clazz=s_typeMap.get(resourceType);
  Object entity=_entityMgr.findByUuid(clazz,resourceId);
  if (entity != null) {
    return ((InternalIdentity)entity).getId();
  }
  entity=_entityMgr.findById(clazz,resourceId);
  if (entity != null) {
    return ((InternalIdentity)entity).getId();
  }
  throw new InvalidParameterValueException("String_Node_Str" + resourceId + "String_Node_Str"+ resourceType);
}

Fixed version (ground truth):
@Override public long getResourceId(String resourceId,ResourceObjectType resourceType){
  Class<?> clazz=s_typeMap.get(resourceType);
  Object entity=_entityMgr.findByUuid(clazz,resourceId);
  if (entity != null) {
    return ((InternalIdentity)entity).getId();
  }
  if (!StringUtils.isNumeric(resourceId)) {
    throw new InvalidParameterValueException("String_Node_Str" + resourceId + "String_Node_Str"+ resourceType);
  }
  entity=_entityMgr.findById(clazz,resourceId);
  if (entity != null) {
    return ((InternalIdentity)entity).getId();
  }
  throw new InvalidParameterValueException("String_Node_Str" + resourceId + "String_Node_Str"+ resourceType);
}
Program: 105555
Project: 105555
Buggy source:
@Override public String getUuid(String resourceId,ResourceObjectType resourceType){
  Class<?> clazz=s_typeMap.get(resourceType);
  Object entity=_entityMgr.findById(clazz,resourceId);
  if (entity != null && entity instanceof Identity) {
    return ((Identity)entity).getUuid();
  }
  return resourceId;
}

Fixed version (ground truth):
@Override public String getUuid(String resourceId,ResourceObjectType resourceType){
  if (!StringUtils.isNumeric(resourceId)) {
    return resourceId;
  }
  Class<?> clazz=s_typeMap.get(resourceType);
  Object entity=_entityMgr.findById(clazz,resourceId);
  if (entity != null && entity instanceof Identity) {
    return ((Identity)entity).getUuid();
  }
  return resourceId;
}
Program: 105556
Project: 105556
Buggy source:
protected List<String> getWarnings(){
synchronized (_warnings) {
    final ArrayList<String> results=_warnings;
    _warnings=new ArrayList<String>();
    return results;
  }
}

Fixed version (ground truth):
protected List<String> getWarnings(){
synchronized (_warnings) {
    final List<String> results=new LinkedList<String>(_warnings);
    _warnings.clear();
    return results;
  }
}
Program: 105557
Project: 105557
Buggy source:
protected List<String> getErrors(){
synchronized (_errors) {
    final ArrayList<String> result=_errors;
    _errors=new ArrayList<String>();
    return result;
  }
}

Fixed version (ground truth):
protected List<String> getErrors(){
synchronized (_errors) {
    final List<String> result=new LinkedList<String>(_errors);
    _errors.clear();
    return result;
  }
}
Program: 105558
Project: 105558
Buggy source:
protected List<String> getWarnings(){
synchronized (_warnings) {
    final ArrayList<String> results=_warnings;
    _warnings=new ArrayList<String>();
    return results;
  }
}

Fixed version (ground truth):
protected List<String> getWarnings(){
synchronized (_warnings) {
    final List<String> results=new LinkedList<String>(_warnings);
    _warnings.clear();
    return results;
  }
}
Program: 105559
Project: 105559
Buggy source:
protected List<String> getErrors(){
synchronized (_errors) {
    final ArrayList<String> result=_errors;
    _errors=new ArrayList<String>();
    return result;
  }
}

Fixed version (ground truth):
protected List<String> getErrors(){
synchronized (_errors) {
    final List<String> result=new LinkedList<String>(_errors);
    _errors.clear();
    return result;
  }
}
Program: 105560
Project: 105560
Buggy source:
private File getSystemVMKeyFile(){
  URL url=this.getClass().getClassLoader().getResource("String_Node_Str");
  File keyFile=null;
  if (url != null) {
    keyFile=new File(url.getPath());
  }
  if (keyFile == null || !keyFile.exists()) {
    keyFile=new File("String_Node_Str");
  }
  assert(keyFile != null);
  if (!keyFile.exists()) {
    s_logger.error("String_Node_Str" + keyFile.toString());
  }
  return keyFile;
}

Fixed version (ground truth):
private File getSystemVMKeyFile(){
  URL url=this.getClass().getClassLoader().getResource("String_Node_Str");
  File keyFile=null;
  if (url != null) {
    keyFile=new File(url.getPath());
  }
  if (keyFile == null || !keyFile.canRead()) {
    s_logger.error("String_Node_Str");
    return null;
  }
  return keyFile;
}
Program: 105562
Project: 105562
Buggy source:
@Override public String getName(){
  return _name;
}

Fixed version (ground truth):
@Override public synchronized String getName(){
  return _name;
}
Program: 105566
Project: 105566
Buggy source:
public static void setVirtualHost(String virtualHost){
  RabbitMQEventBus.virtualHost=virtualHost;
}

Fixed version (ground truth):
public synchronized static void setVirtualHost(String virtualHost){
  RabbitMQEventBus.virtualHost=virtualHost;
}
Program: 105567
Project: 105567
Buggy source:
@Override public boolean stop(){
  if (s_connection.isOpen()) {
    for (    String subscriberId : s_subscribers.keySet()) {
      Ternary<String,Channel,EventSubscriber> subscriberDetails=s_subscribers.get(subscriberId);
      Channel channel=subscriberDetails.second();
      String queueName=subscriberId;
      try {
        channel.queueDelete(queueName);
        channel.abort();
      }
 catch (      IOException ioe) {
        s_logger.warn("String_Node_Str" + queueName + "String_Node_Str"+ ioe.getMessage());
      }
    }
  }
  closeConnection();
  return true;
}

Fixed version (ground truth):
@Override public synchronized boolean stop(){
  if (s_connection.isOpen()) {
    for (    String subscriberId : s_subscribers.keySet()) {
      Ternary<String,Channel,EventSubscriber> subscriberDetails=s_subscribers.get(subscriberId);
      Channel channel=subscriberDetails.second();
      String queueName=subscriberId;
      try {
        channel.queueDelete(queueName);
        channel.abort();
      }
 catch (      IOException ioe) {
        s_logger.warn("String_Node_Str" + queueName + "String_Node_Str"+ ioe.getMessage());
      }
    }
  }
  closeConnection();
  return true;
}
Program: 105568
Project: 105568
Buggy source:
private void shutdownCleanup(){
  s_logger.info("String_Node_Str");
  for (  String mountPoint : _storageMounts.values()) {
    s_logger.info("String_Node_Str" + mountPoint);
    String result=null;
    Script command=new Script(true,"String_Node_Str",_timeout,s_logger);
    command.add(mountPoint);
    result=command.execute();
    if (result != null) {
      s_logger.warn("String_Node_Str" + mountPoint + "String_Node_Str"+ result);
    }
    File file=new File(mountPoint);
    if (file.exists()) {
      file.delete();
    }
  }
}

Fixed version (ground truth):
private void shutdownCleanup(){
  s_logger.info("String_Node_Str");
synchronized (_storageMounts) {
    for (    String mountPoint : _storageMounts.values()) {
      s_logger.info("String_Node_Str" + mountPoint);
      String result=null;
      Script command=new Script(true,"String_Node_Str",_timeout,s_logger);
      command.add(mountPoint);
      result=command.execute();
      if (result != null) {
        s_logger.warn("String_Node_Str" + mountPoint + "String_Node_Str"+ result);
      }
      File file=new File(mountPoint);
      if (file.exists()) {
        file.delete();
      }
    }
  }
}
Program: 105569
Project: 105569
Buggy source:
public static int getNextSequenceId(){
  return s_nextSequence++;
}

Fixed version (ground truth):
public synchronized static int getNextSequenceId(){
  return s_nextSequence++;
}
Program: 105570
Project: 105570
Buggy source:
public int getWeek(){
  return _week;
}

Fixed version (ground truth):
public int getWeek(){
synchronized (this) {
    return _week;
  }
}
Program: 105571
Project: 105571
Buggy source:
public int getDay(){
  return _day;
}

Fixed version (ground truth):
public int getDay(){
synchronized (this) {
    return _day;
  }
}
Program: 105572
Project: 105572
Buggy source:
public int getYear(){
  return _year;
}

Fixed version (ground truth):
public int getYear(){
synchronized (this) {
    return _year;
  }
}
Program: 105573
Project: 105573
Buggy source:
public int getMinute(){
  return _minute;
}

Fixed version (ground truth):
public int getMinute(){
synchronized (this) {
    return _minute;
  }
}
Program: 105574
Project: 105574
Buggy source:
public int getHour(){
  return _hour;
}

Fixed version (ground truth):
public int getHour(){
synchronized (this) {
    return _hour;
  }
}
Program: 105575
Project: 105575
Buggy source:
public int getMonth(){
  return _month;
}

Fixed version (ground truth):
public int getMonth(){
synchronized (this) {
    return _month;
  }
}
Program: 105576
Project: 105576
Buggy source:
public void sendStartup(Link link){
  final StartupCommand[] startup=_resource.initialize();
  final Command[] commands=new Command[startup.length];
  for (int i=0; i < startup.length; i++) {
    setupStartupCommand(startup[i]);
    commands[i]=startup[i];
  }
  final Request request=new Request(_id != null ? _id : -1,-1,commands,false,false);
  request.setSequence(getNextSequence());
  if (s_logger.isDebugEnabled()) {
    s_logger.debug("String_Node_Str" + request.toString());
  }
synchronized (this) {
    _startup=new StartupTask(link);
    _timer.schedule(_startup,_startupWait);
  }
  try {
    link.send(request.toBytes());
  }
 catch (  final ClosedChannelException e) {
    s_logger.warn("String_Node_Str" + request.toString());
  }
}

Fixed version (ground truth):
public void sendStartup(Link link){
  final StartupCommand[] startup=_resource.initialize();
  if (startup != null) {
    final Command[] commands=new Command[startup.length];
    for (int i=0; i < startup.length; i++) {
      setupStartupCommand(startup[i]);
      commands[i]=startup[i];
    }
    final Request request=new Request(_id != null ? _id : -1,-1,commands,false,false);
    request.setSequence(getNextSequence());
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + request.toString());
    }
synchronized (this) {
      _startup=new StartupTask(link);
      _timer.schedule(_startup,_startupWait);
    }
    try {
      link.send(request.toBytes());
    }
 catch (    final ClosedChannelException e) {
      s_logger.warn("String_Node_Str" + request.toString());
    }
  }
}
Program: 105578
Project: 105578
Buggy source:
private void disableRpFilter(){
  try {
    FileWriter fstream=new FileWriter("String_Node_Str");
    BufferedWriter out=new BufferedWriter(fstream);
    out.write("String_Node_Str");
    out.close();
  }
 catch (  IOException e) {
    s_logger.warn("String_Node_Str");
  }
}

Fixed version (ground truth):
private void disableRpFilter(){
  try (FileWriter fstream=new FileWriter("String_Node_Str");BufferedWriter out=new BufferedWriter(fstream)){
    out.write("String_Node_Str");
  }
 catch (  IOException e) {
    s_logger.warn("String_Node_Str");
  }
}
Program: 105579
Project: 105579
Buggy source:
@Override public void create(){
  if (getSourceCidrList() != null) {
    for (    String cidr : getSourceCidrList()) {
      if (!NetUtils.isValidCIDR(cidr)) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR,"String_Node_Str" + cidr);
      }
    }
  }
  try {
    FirewallRule result=_firewallService.createIngressFirewallRule(this);
    setEntityId(result.getId());
    setEntityUuid(result.getUuid());
  }
 catch (  NetworkRuleConflictException ex) {
    s_logger.info("String_Node_Str" + ex.getMessage());
    s_logger.trace("String_Node_Str",ex);
    throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR,ex.getMessage());
  }
}

Fixed version (ground truth):
@Override public void create(){
  if (getSourceCidrList() != null) {
    for (    String cidr : getSourceCidrList()) {
      if (!NetUtils.isValidCIDR(cidr)) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR,"String_Node_Str" + cidr);
      }
    }
  }
  try {
    FirewallRule result=_firewallService.createIngressFirewallRule(this);
    if (result != null) {
      setEntityId(result.getId());
      setEntityUuid(result.getUuid());
    }
  }
 catch (  NetworkRuleConflictException ex) {
    s_logger.info("String_Node_Str" + ex.getMessage());
    s_logger.trace("String_Node_Str",ex);
    throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR,ex.getMessage());
  }
}
Program: 105580
Project: 105580
Buggy source:
@Override public Integer getSourcePortStart(){
  if (publicStartPort != null) {
    return publicStartPort.intValue();
  }
  return null;
}

Fixed version (ground truth):
@Override public Integer getSourcePortStart(){
  if (publicStartPort != null) {
    return publicStartPort;
  }
  return null;
}
Program: 105581
Project: 105581
Buggy source:
@Override public Integer getSourcePortEnd(){
  if (publicEndPort == null) {
    if (publicStartPort != null) {
      return publicStartPort.intValue();
    }
  }
 else {
    return publicEndPort.intValue();
  }
  return null;
}

Fixed version (ground truth):
@Override public Integer getSourcePortEnd(){
  if (publicEndPort == null) {
    if (publicStartPort != null) {
      return publicStartPort;
    }
  }
 else {
    return publicEndPort;
  }
  return null;
}
Program: 105582
Project: 105582
Buggy source:
public StaticNatRuleImpl(FirewallRuleVO rule,String dstIp){
  id=rule.getId();
  xid=rule.getXid();
  uuid=rule.getUuid();
  protocol=rule.getProtocol();
  portStart=rule.getSourcePortStart();
  portEnd=rule.getSourcePortEnd();
  state=rule.getState();
  accountId=rule.getAccountId();
  domainId=rule.getDomainId();
  networkId=rule.getNetworkId();
  sourceIpAddressId=rule.getSourceIpAddressId();
  destIpAddress=dstIp;
  forDisplay=rule.isDisplay();
}

Fixed version (ground truth):
public StaticNatRuleImpl(FirewallRuleVO rule,String dstIp){
  id=rule.getId();
  xid=rule.getXid();
  uuid=rule.getUuid();
  protocol=rule.getProtocol();
  portStart=rule.getSourcePortStart().intValue();
  portEnd=rule.getSourcePortEnd().intValue();
  state=rule.getState();
  accountId=rule.getAccountId();
  domainId=rule.getDomainId();
  networkId=rule.getNetworkId();
  sourceIpAddressId=rule.getSourceIpAddressId();
  destIpAddress=dstIp;
  forDisplay=rule.isDisplay();
}
Program: 105584
Project: 105584
Buggy source:
public void complete(RpcException e){
  _responseResult=e;
synchronized (_responseLock) {
    _responseDone=true;
    _responseLock.notifyAll();
  }
  if (_callbackListeners.size() > 0) {
    for (    @SuppressWarnings("String_Node_Str") RpcCallbackListener listener : _callbackListeners)     listener.onFailure(e);
  }
 else {
    if (_callbackDispatcher != null)     _callbackDispatcher.dispatch(this);
  }
}

Fixed version (ground truth):
public void complete(RpcException e){
synchronized (_responseLock) {
    _responseResult=e;
    _responseDone=true;
    _responseLock.notifyAll();
  }
  if (_callbackListeners.size() > 0) {
    for (    @SuppressWarnings("String_Node_Str") RpcCallbackListener listener : _callbackListeners)     listener.onFailure(e);
  }
 else {
    if (_callbackDispatcher != null)     _callbackDispatcher.dispatch(this);
  }
}
Program: 105585
Project: 105585
Buggy source:
public static ConsoleProxyClientStatsCollector getStatsCollector(){
  return new ConsoleProxyClientStatsCollector(connectionMap);
}

Fixed version (ground truth):
public static ConsoleProxyClientStatsCollector getStatsCollector(){
synchronized (connectionMap) {
    return new ConsoleProxyClientStatsCollector(connectionMap);
  }
}
Program: 105587
Project: 105587
Buggy source:
private long getVMSnapshotChainSize(Connection conn,VolumeObjectTO volumeTo,String vmName) throws BadServerResponse, XenAPIException, XmlRpcException {
  Set<VDI> allvolumeVDIs=VDI.getByNameLabel(conn,volumeTo.getName());
  long size=0;
  for (  VDI vdi : allvolumeVDIs) {
    try {
      if (vdi.getIsASnapshot(conn) && vdi.getSmConfig(conn).get("String_Node_Str") != null) {
        String parentUuid=vdi.getSmConfig(conn).get("String_Node_Str");
        VDI parentVDI=VDI.getByUuid(conn,parentUuid);
        size=size + vdi.getPhysicalUtilisation(conn);
        if (parentVDI != null)         size=size + parentVDI.getPhysicalUtilisation(conn).longValue();
      }
    }
 catch (    Exception e) {
      s_logger.debug("String_Node_Str" + "String_Node_Str" + e.getMessage());
      continue;
    }
  }
  if (volumeTo.getVolumeType() == Volume.Type.ROOT) {
    Map<VM,VM.Record> allVMs=VM.getAllRecords(conn);
    if (allVMs.size() > 0) {
      for (      VM vmr : allVMs.keySet()) {
        try {
          String vName=vmr.getNameLabel(conn);
          if (vName != null && vName.contains(vmName) && vmr.getIsASnapshot(conn)) {
            VDI memoryVDI=vmr.getSuspendVDI(conn);
            size=size + memoryVDI.getParent(conn).getPhysicalUtilisation(conn);
            size=size + memoryVDI.getPhysicalUtilisation(conn);
          }
        }
 catch (        Exception e) {
          s_logger.debug("String_Node_Str" + "String_Node_Str" + e.getMessage());
          continue;
        }
      }
    }
  }
  return size;
}

Fixed version (ground truth):
private long getVMSnapshotChainSize(Connection conn,VolumeObjectTO volumeTo,String vmName) throws BadServerResponse, XenAPIException, XmlRpcException {
  Set<VDI> allvolumeVDIs=VDI.getByNameLabel(conn,volumeTo.getName());
  long size=0;
  for (  VDI vdi : allvolumeVDIs) {
    try {
      if (vdi.getIsASnapshot(conn) && vdi.getSmConfig(conn).get("String_Node_Str") != null) {
        String parentUuid=vdi.getSmConfig(conn).get("String_Node_Str");
        VDI parentVDI=VDI.getByUuid(conn,parentUuid);
        size=size + vdi.getPhysicalUtilisation(conn);
        if (parentVDI != null)         size=size + parentVDI.getPhysicalUtilisation(conn).longValue();
      }
    }
 catch (    Exception e) {
      s_logger.debug("String_Node_Str" + "String_Node_Str" + e.getMessage());
      continue;
    }
  }
  if (volumeTo.getVolumeType() == Volume.Type.ROOT) {
    Map<VM,VM.Record> allVMs=VM.getAllRecords(conn);
    if (allVMs != null && allVMs.size() > 0) {
      for (      VM vmr : allVMs.keySet()) {
        try {
          String vName=vmr.getNameLabel(conn);
          if (vName != null && vName.contains(vmName) && vmr.getIsASnapshot(conn)) {
            VDI memoryVDI=vmr.getSuspendVDI(conn);
            size=size + memoryVDI.getParent(conn).getPhysicalUtilisation(conn);
            size=size + memoryVDI.getPhysicalUtilisation(conn);
          }
        }
 catch (        Exception e) {
          s_logger.debug("String_Node_Str" + "String_Node_Str" + e.getMessage());
          continue;
        }
      }
    }
  }
  return size;
}
Program: 105588
Project: 105588
Buggy source:
protected HashMap<String,String> clusterVMMetaDataSync(Connection conn){
  final HashMap<String,String> vmMetaDatum=new HashMap<String,String>();
  try {
    Map<VM,VM.Record> vm_map=VM.getAllRecords(conn);
    for (    VM.Record record : vm_map.values()) {
      if (record.isControlDomain || record.isASnapshot || record.isATemplate) {
        continue;
      }
      vmMetaDatum.put(record.nameLabel,StringUtils.mapToString(record.platform));
    }
  }
 catch (  final Throwable e) {
    String msg="String_Node_Str" + _host.uuid + "String_Node_Str"+ e.toString();
    s_logger.warn(msg,e);
    throw new CloudRuntimeException(msg);
  }
  return vmMetaDatum;
}

Fixed version (ground truth):
protected HashMap<String,String> clusterVMMetaDataSync(Connection conn){
  final HashMap<String,String> vmMetaDatum=new HashMap<String,String>();
  try {
    Map<VM,VM.Record> vm_map=VM.getAllRecords(conn);
    if (vm_map != null) {
      for (      VM.Record record : vm_map.values()) {
        if (record.isControlDomain || record.isASnapshot || record.isATemplate) {
          continue;
        }
        vmMetaDatum.put(record.nameLabel,StringUtils.mapToString(record.platform));
      }
    }
  }
 catch (  final Throwable e) {
    String msg="String_Node_Str" + _host.uuid + "String_Node_Str"+ e.toString();
    s_logger.warn(msg,e);
    throw new CloudRuntimeException(msg);
  }
  return vmMetaDatum;
}
Program: 105590
Project: 105590
Buggy source:
protected ExecutionResult prepareNetworkElementCommand(SetNetworkACLCommand cmd){
  Connection conn=getConnection();
  String routerName=cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
  try {
    VM router=getVM(conn,routerName);
    NicTO nic=cmd.getNic();
    VIF vif=getVifByMac(conn,router,nic.getMac());
    nic.setDeviceId(Integer.valueOf(vif.getDevice(conn)));
  }
 catch (  Exception e) {
    String msg="String_Node_Str" + e.toString();
    s_logger.error(msg,e);
    return new ExecutionResult(false,msg);
  }
  return new ExecutionResult(true,null);
}

Fixed version (ground truth):
protected ExecutionResult prepareNetworkElementCommand(SetNetworkACLCommand cmd){
  Connection conn=getConnection();
  String routerName=cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
  try {
    VM router=getVM(conn,routerName);
    NicTO nic=cmd.getNic();
    if (nic != null) {
      VIF vif=getVifByMac(conn,router,nic.getMac());
      if (vif == null) {
        String msg="String_Node_Str" + nic.getMac() + "String_Node_Str"+ routerName;
        s_logger.error(msg);
        return new ExecutionResult(false,msg);
      }
      nic.setDeviceId(Integer.valueOf(vif.getDevice(conn)));
    }
 else {
      String msg="String_Node_Str" + routerName;
      s_logger.error(msg);
      return new ExecutionResult(false,msg);
    }
  }
 catch (  Exception e) {
    String msg="String_Node_Str" + e.toString();
    s_logger.error(msg,e);
    return new ExecutionResult(false,msg);
  }
  return new ExecutionResult(true,null);
}
Program: 105591
Project: 105591
Buggy source:
protected SR getLocalLVMSR(Connection conn){
  try {
    Map<SR,SR.Record> map=SR.getAllRecords(conn);
    for (    Map.Entry<SR,SR.Record> entry : map.entrySet()) {
      SR.Record srRec=entry.getValue();
      if (SRType.LVM.equals(srRec.type)) {
        Set<PBD> pbds=srRec.PBDs;
        if (pbds == null) {
          continue;
        }
        for (        PBD pbd : pbds) {
          Host host=pbd.getHost(conn);
          if (!isRefNull(host) && host.getUuid(conn).equals(_host.uuid)) {
            if (!pbd.getCurrentlyAttached(conn)) {
              pbd.plug(conn);
            }
            SR sr=entry.getKey();
            sr.scan(conn);
            return sr;
          }
        }
      }
    }
  }
 catch (  XenAPIException e) {
    String msg="String_Node_Str" + _host.uuid + e.toString();
    s_logger.warn(msg);
  }
catch (  XmlRpcException e) {
    String msg="String_Node_Str" + _host.uuid + e.getCause();
    s_logger.warn(msg);
  }
  return null;
}

Fixed version (ground truth):
protected SR getLocalLVMSR(Connection conn){
  try {
    Map<SR,SR.Record> map=SR.getAllRecords(conn);
    if (map != null && !map.isEmpty()) {
      for (      Map.Entry<SR,SR.Record> entry : map.entrySet()) {
        SR.Record srRec=entry.getValue();
        if (SRType.LVM.equals(srRec.type)) {
          Set<PBD> pbds=srRec.PBDs;
          if (pbds == null) {
            continue;
          }
          for (          PBD pbd : pbds) {
            Host host=pbd.getHost(conn);
            if (!isRefNull(host) && host.getUuid(conn).equals(_host.uuid)) {
              if (!pbd.getCurrentlyAttached(conn)) {
                pbd.plug(conn);
              }
              SR sr=entry.getKey();
              sr.scan(conn);
              return sr;
            }
          }
        }
      }
    }
  }
 catch (  XenAPIException e) {
    String msg="String_Node_Str" + _host.uuid + e.toString();
    s_logger.warn(msg);
  }
catch (  XmlRpcException e) {
    String msg="String_Node_Str" + _host.uuid + e.getCause();
    s_logger.warn(msg);
  }
  return null;
}
Program: 105593
Project: 105593
Buggy source:
protected boolean cleanupHaltedVms(Connection conn) throws XenAPIException, XmlRpcException {
  Host host=Host.getByUuid(conn,_host.uuid);
  Map<VM,VM.Record> vms=VM.getAllRecords(conn);
  boolean success=true;
  for (  Map.Entry<VM,VM.Record> entry : vms.entrySet()) {
    VM vm=entry.getKey();
    VM.Record vmRec=entry.getValue();
    if (vmRec.isATemplate || vmRec.isControlDomain) {
      continue;
    }
    if (VmPowerState.HALTED.equals(vmRec.powerState) && vmRec.affinity.equals(host) && !isAlienVm(vm,conn)) {
      try {
        vm.destroy(conn);
      }
 catch (      Exception e) {
        s_logger.warn("String_Node_Str" + e.getClass().getName() + "String_Node_Str"+ vmRec.nameLabel+ "String_Node_Str",e);
        success=false;
      }
    }
  }
  return success;
}

Fixed version (ground truth):
protected boolean cleanupHaltedVms(Connection conn) throws XenAPIException, XmlRpcException {
  Host host=Host.getByUuid(conn,_host.uuid);
  Map<VM,VM.Record> vms=VM.getAllRecords(conn);
  boolean success=true;
  if (vms != null && !vms.isEmpty()) {
    for (    Map.Entry<VM,VM.Record> entry : vms.entrySet()) {
      VM vm=entry.getKey();
      VM.Record vmRec=entry.getValue();
      if (vmRec.isATemplate || vmRec.isControlDomain) {
        continue;
      }
      if (VmPowerState.HALTED.equals(vmRec.powerState) && vmRec.affinity.equals(host) && !isAlienVm(vm,conn)) {
        try {
          vm.destroy(conn);
        }
 catch (        Exception e) {
          s_logger.warn("String_Node_Str" + e.getClass().getName() + "String_Node_Str"+ vmRec.nameLabel+ "String_Node_Str",e);
          success=false;
        }
      }
    }
  }
  return success;
}
Program: 105595
Project: 105595
Buggy source:
protected SR getLocalEXTSR(Connection conn){
  try {
    Map<SR,SR.Record> map=SR.getAllRecords(conn);
    for (    Map.Entry<SR,SR.Record> entry : map.entrySet()) {
      SR.Record srRec=entry.getValue();
      if (SRType.FILE.equals(srRec.type) || SRType.EXT.equals(srRec.type)) {
        Set<PBD> pbds=srRec.PBDs;
        if (pbds == null) {
          continue;
        }
        for (        PBD pbd : pbds) {
          Host host=pbd.getHost(conn);
          if (!isRefNull(host) && host.getUuid(conn).equals(_host.uuid)) {
            if (!pbd.getCurrentlyAttached(conn)) {
              pbd.plug(conn);
            }
            SR sr=entry.getKey();
            sr.scan(conn);
            return sr;
          }
        }
      }
    }
  }
 catch (  XenAPIException e) {
    String msg="String_Node_Str" + _host.uuid + e.toString();
    s_logger.warn(msg);
  }
catch (  XmlRpcException e) {
    String msg="String_Node_Str" + _host.uuid + e.getCause();
    s_logger.warn(msg);
  }
  return null;
}

Fixed version (ground truth):
protected SR getLocalEXTSR(Connection conn){
  try {
    Map<SR,SR.Record> map=SR.getAllRecords(conn);
    if (map != null && !map.isEmpty()) {
      for (      Map.Entry<SR,SR.Record> entry : map.entrySet()) {
        SR.Record srRec=entry.getValue();
        if (SRType.FILE.equals(srRec.type) || SRType.EXT.equals(srRec.type)) {
          Set<PBD> pbds=srRec.PBDs;
          if (pbds == null) {
            continue;
          }
          for (          PBD pbd : pbds) {
            Host host=pbd.getHost(conn);
            if (!isRefNull(host) && host.getUuid(conn).equals(_host.uuid)) {
              if (!pbd.getCurrentlyAttached(conn)) {
                pbd.plug(conn);
              }
              SR sr=entry.getKey();
              sr.scan(conn);
              return sr;
            }
          }
        }
      }
    }
  }
 catch (  XenAPIException e) {
    String msg="String_Node_Str" + _host.uuid + e.toString();
    s_logger.warn(msg);
  }
catch (  XmlRpcException e) {
    String msg="String_Node_Str" + _host.uuid + e.getCause();
    s_logger.warn(msg);
  }
  return null;
}
Program: 105596
Project: 105596
Buggy source:
private Hashtable<String,String> getEnvironment(final String principal,final String password,final String providerUrl,final boolean isSystemContext){
  final String factory=_ldapConfiguration.getFactory();
  final String url=providerUrl == null ? _ldapConfiguration.getProviderUrl() : providerUrl;
  final Hashtable<String,String> environment=new Hashtable<String,String>();
  environment.put(Context.INITIAL_CONTEXT_FACTORY,factory);
  environment.put(Context.PROVIDER_URL,url);
  environment.put("String_Node_Str","String_Node_Str");
  environment.put("String_Node_Str","String_Node_Str");
  enableSSL(environment);
  setAuthentication(environment,isSystemContext);
  if (principal != null) {
    environment.put(Context.SECURITY_PRINCIPAL,principal);
  }
  if (password != null) {
    environment.put(Context.SECURITY_CREDENTIALS,password);
  }
  return environment;
}

Fixed version (ground truth):
private Hashtable<String,String> getEnvironment(final String principal,final String password,final String providerUrl,final boolean isSystemContext){
  final String factory=_ldapConfiguration.getFactory();
  final String url=providerUrl == null ? _ldapConfiguration.getProviderUrl() : providerUrl;
  final Hashtable<String,String> environment=new Hashtable<String,String>();
  environment.put(Context.INITIAL_CONTEXT_FACTORY,factory);
  environment.put(Context.PROVIDER_URL,url);
  environment.put("String_Node_Str",_ldapConfiguration.getReadTimeout().toString());
  environment.put("String_Node_Str","String_Node_Str");
  enableSSL(environment);
  setAuthentication(environment,isSystemContext);
  if (principal != null) {
    environment.put(Context.SECURITY_PRINCIPAL,principal);
  }
  if (password != null) {
    environment.put(Context.SECURITY_CREDENTIALS,password);
  }
  return environment;
}
Program: 105597
Project: 105597
Buggy source:
@Override public int registerForInitialConnects(final StartupCommandProcessor creator,boolean priority){
synchronized (_hostMonitors) {
    _monitorId++;
    if (priority) {
      _creationMonitors.add(0,new Pair<Integer,StartupCommandProcessor>(_monitorId,creator));
    }
 else {
      _creationMonitors.add(new Pair<Integer,StartupCommandProcessor>(_monitorId,creator));
    }
  }
  return _monitorId;
}

Fixed version (ground truth):
@Override public int registerForInitialConnects(final StartupCommandProcessor creator,boolean priority){
synchronized (_hostMonitors) {
    _monitorId++;
    if (priority) {
      _creationMonitors.add(0,new Pair<Integer,StartupCommandProcessor>(_monitorId,creator));
    }
 else {
      _creationMonitors.add(new Pair<Integer,StartupCommandProcessor>(_monitorId,creator));
    }
    return _monitorId;
  }
}
Program: 105598
Project: 105598
Buggy source:
@Override public void registerResourceStateAdapter(String name,ResourceStateAdapter adapter){
  if (_resourceStateAdapters.get(name) != null) {
    throw new CloudRuntimeException(name + "String_Node_Str");
  }
synchronized (_resourceStateAdapters) {
    _resourceStateAdapters.put(name,adapter);
  }
}

Fixed version (ground truth):
@Override public void registerResourceStateAdapter(String name,ResourceStateAdapter adapter){
synchronized (_resourceStateAdapters) {
    if (_resourceStateAdapters.get(name) != null) {
      throw new CloudRuntimeException(name + "String_Node_Str");
    }
    _resourceStateAdapters.put(name,adapter);
  }
}
Program: 105599
Project: 105599
Buggy source:
protected List<String> getWarnings(){
synchronized (this) {
    final ArrayList<String> results=_warnings;
    _warnings=new ArrayList<String>();
    return results;
  }
}

Fixed version (ground truth):
protected List<String> getWarnings(){
synchronized (_warnings) {
    final ArrayList<String> results=_warnings;
    _warnings=new ArrayList<String>();
    return results;
  }
}
Program: 105600
Project: 105600
Buggy source:
protected List<String> getErrors(){
synchronized (this) {
    final ArrayList<String> result=_errors;
    _errors=new ArrayList<String>();
    return result;
  }
}

Fixed version (ground truth):
protected List<String> getErrors(){
synchronized (_errors) {
    final ArrayList<String> result=_errors;
    _errors=new ArrayList<String>();
    return result;
  }
}
Program: 105601
Project: 105601
Buggy source:
private String getEnvironmentProperty(String name){
  try {
    final File propsFile=PropertiesUtil.findConfigFile("String_Node_Str");
    if (propsFile == null) {
      return null;
    }
 else {
      final FileInputStream finputstream=new FileInputStream(propsFile);
      final Properties props=new Properties();
      props.load(finputstream);
      finputstream.close();
      return props.getProperty("String_Node_Str");
    }
  }
 catch (  IOException e) {
    return null;
  }
}

Fixed version (ground truth):
private String getEnvironmentProperty(String name){
  try {
    final File propsFile=PropertiesUtil.findConfigFile("String_Node_Str");
    if (propsFile == null) {
      return null;
    }
 else {
      final Properties props=new Properties();
      try (final FileInputStream finputstream=new FileInputStream(propsFile)){
        props.load(finputstream);
      }
 catch (      IOException e) {
        s_logger.error("String_Node_Str" + e.getMessage());
      }
      return props.getProperty("String_Node_Str");
    }
  }
 catch (  Exception e) {
    return null;
  }
}
Program: 105602
Project: 105602
Buggy source:
private void writeKeyToDisk(String key,String keyPath){
  File keyfile=new File(keyPath);
  if (!keyfile.exists()) {
    try {
      keyfile.createNewFile();
    }
 catch (    IOException e) {
      s_logger.warn("String_Node_Str" + e.toString());
      throw new CloudRuntimeException("String_Node_Str" + keyPath);
    }
  }
  if (keyfile.exists()) {
    try {
      FileOutputStream kStream=new FileOutputStream(keyfile);
      kStream.write(key.getBytes());
      kStream.close();
    }
 catch (    FileNotFoundException e) {
      s_logger.warn("String_Node_Str" + keyfile.getAbsolutePath());
      throw new CloudRuntimeException("String_Node_Str" + keyPath);
    }
catch (    IOException e) {
      s_logger.warn("String_Node_Str" + keyfile.getAbsolutePath());
      throw new CloudRuntimeException("String_Node_Str" + keyPath);
    }
  }
}

Fixed version (ground truth):
private void writeKeyToDisk(String key,String keyPath){
  File keyfile=new File(keyPath);
  if (!keyfile.exists()) {
    try {
      keyfile.createNewFile();
    }
 catch (    IOException e) {
      s_logger.warn("String_Node_Str" + e.toString());
      throw new CloudRuntimeException("String_Node_Str" + keyPath);
    }
  }
  if (keyfile.exists()) {
    try (FileOutputStream kStream=new FileOutputStream(keyfile)){
      if (kStream != null) {
        kStream.write(key.getBytes());
      }
    }
 catch (    FileNotFoundException e) {
      s_logger.warn("String_Node_Str" + keyfile.getAbsolutePath());
      throw new CloudRuntimeException("String_Node_Str" + keyPath);
    }
catch (    IOException e) {
      s_logger.warn("String_Node_Str" + keyfile.getAbsolutePath());
      throw new CloudRuntimeException("String_Node_Str" + keyPath);
    }
  }
}
Program: 105605
Project: 105605
Buggy source:
private static void responseFileContent(HttpExchange t,File f) throws Exception {
  OutputStream os=t.getResponseBody();
  FileInputStream fis=new FileInputStream(f);
  while (true) {
    byte[] b=new byte[8192];
    int n=fis.read(b);
    if (n < 0) {
      break;
    }
    os.write(b,0,n);
  }
  fis.close();
  os.close();
}

Fixed version (ground truth):
private static void responseFileContent(HttpExchange t,File f) throws Exception {
  try (OutputStream os=t.getResponseBody();FileInputStream fis=new FileInputStream(f)){
    while (true) {
      byte[] b=new byte[8192];
      int n=fis.read(b);
      if (n < 0) {
        break;
      }
      os.write(b,0,n);
    }
  }
 }
Program: 105606
Project: 105606
Buggy source:
@Override public List<StoragePoolHostVO> listByHostStatus(long poolId,Status hostStatus){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  PreparedStatement pstmt=null;
  List<StoragePoolHostVO> result=new ArrayList<StoragePoolHostVO>();
  ResultSet rs=null;
  try {
    String sql=HOST_FOR_POOL_SEARCH;
    pstmt=txn.prepareStatement(sql);
    pstmt.setLong(1,poolId);
    pstmt.setString(2,hostStatus.toString());
    rs=pstmt.executeQuery();
    while (rs.next()) {
      long id=rs.getLong(1);
      result.add(findById(id));
    }
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str",e);
  }
 finally {
    try {
      if (rs != null) {
        rs.close();
      }
      if (pstmt != null) {
        pstmt.close();
      }
    }
 catch (    SQLException e) {
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public List<StoragePoolHostVO> listByHostStatus(long poolId,Status hostStatus){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  String sql=HOST_FOR_POOL_SEARCH;
  List<StoragePoolHostVO> result=new ArrayList<StoragePoolHostVO>();
  try (PreparedStatement pstmt=txn.prepareStatement(sql)){
    pstmt.setLong(1,poolId);
    pstmt.setString(2,hostStatus.toString());
    try (ResultSet rs=pstmt.executeQuery()){
      while (rs.next()) {
        long id=rs.getLong(1);
        result.add(findById(id));
      }
    }
 catch (    SQLException e) {
      s_logger.warn("String_Node_Str",e);
    }
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str",e);
  }
  return result;
}
Program: 105607
Project: 105607
Buggy source:
@Override public List<Pair<Long,Integer>> getDatacenterStoragePoolHostInfo(long dcId,boolean sharedOnly){
  ArrayList<Pair<Long,Integer>> l=new ArrayList<Pair<Long,Integer>>();
  String sql=sharedOnly ? SHARED_STORAGE_POOL_HOST_INFO : STORAGE_POOL_HOST_INFO;
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  ;
  PreparedStatement pstmt=null;
  try {
    pstmt=txn.prepareAutoCloseStatement(sql);
    pstmt.setLong(1,dcId);
    ResultSet rs=pstmt.executeQuery();
    while (rs.next()) {
      l.add(new Pair<Long,Integer>(rs.getLong(1),rs.getInt(2)));
    }
  }
 catch (  SQLException e) {
    s_logger.debug("String_Node_Str",e);
  }
  return l;
}

Fixed version (ground truth):
@Override public List<Pair<Long,Integer>> getDatacenterStoragePoolHostInfo(long dcId,boolean sharedOnly){
  ArrayList<Pair<Long,Integer>> l=new ArrayList<Pair<Long,Integer>>();
  String sql=sharedOnly ? SHARED_STORAGE_POOL_HOST_INFO : STORAGE_POOL_HOST_INFO;
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  PreparedStatement pstmt=null;
  try {
    pstmt=txn.prepareAutoCloseStatement(sql);
    pstmt.setLong(1,dcId);
    ResultSet rs=pstmt.executeQuery();
    while (rs.next()) {
      l.add(new Pair<Long,Integer>(rs.getLong(1),rs.getInt(2)));
    }
  }
 catch (  SQLException e) {
    s_logger.debug("String_Node_Str",e);
  }
  return l;
}
Program: 105609
Project: 105609
Buggy source:
private Hashtable<String,String> getEnvironment(final String principal,final String password,final String providerUrl,final boolean isSystemContext){
  final String factory=_ldapConfiguration.getFactory();
  final String url=providerUrl == null ? _ldapConfiguration.getProviderUrl() : providerUrl;
  final Hashtable<String,String> environment=new Hashtable<String,String>();
  environment.put(Context.INITIAL_CONTEXT_FACTORY,factory);
  environment.put(Context.PROVIDER_URL,url);
  environment.put("String_Node_Str",_ldapConfiguration.getReadTimeout().toString());
  environment.put("String_Node_Str","String_Node_Str");
  enableSSL(environment);
  setAuthentication(environment,isSystemContext);
  if (principal != null) {
    environment.put(Context.SECURITY_PRINCIPAL,principal);
  }
  if (password != null) {
    environment.put(Context.SECURITY_CREDENTIALS,password);
  }
  return environment;
}

Fixed version (ground truth):
private Hashtable<String,String> getEnvironment(final String principal,final String password,final String providerUrl,final boolean isSystemContext){
  final String factory=_ldapConfiguration.getFactory();
  final String url=providerUrl == null ? _ldapConfiguration.getProviderUrl() : providerUrl;
  final Hashtable<String,String> environment=new Hashtable<String,String>();
  environment.put(Context.INITIAL_CONTEXT_FACTORY,factory);
  environment.put(Context.PROVIDER_URL,url);
  environment.put("String_Node_Str","String_Node_Str");
  environment.put("String_Node_Str","String_Node_Str");
  enableSSL(environment);
  setAuthentication(environment,isSystemContext);
  if (principal != null) {
    environment.put(Context.SECURITY_PRINCIPAL,principal);
  }
  if (password != null) {
    environment.put(Context.SECURITY_CREDENTIALS,password);
  }
  return environment;
}
Program: 105610
Project: 105610
Buggy source:
@Override public List<VMTemplateHostVO> listByTemplateStatus(long templateId,long datacenterId,long podId,VMTemplateHostVO.Status downloadState){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  PreparedStatement pstmt=null;
  List<VMTemplateHostVO> result=new ArrayList<VMTemplateHostVO>();
  ResultSet rs=null;
  try {
    String sql=DOWNLOADS_STATE_DC_POD;
    pstmt=txn.prepareStatement(sql);
    pstmt.setLong(1,datacenterId);
    pstmt.setLong(2,podId);
    pstmt.setLong(3,templateId);
    pstmt.setString(4,downloadState.toString());
    rs=pstmt.executeQuery();
    while (rs.next()) {
      long id=rs.getLong(1);
      result.add(findById(id));
    }
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str",e);
  }
 finally {
    try {
      if (rs != null) {
        rs.close();
      }
      if (pstmt != null) {
        pstmt.close();
      }
    }
 catch (    SQLException e) {
    }
  }
  return result;
}

Fixed version (ground truth):
@Override public List<VMTemplateHostVO> listByTemplateStatus(long templateId,long datacenterId,long podId,VMTemplateHostVO.Status downloadState){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  List<VMTemplateHostVO> result=new ArrayList<VMTemplateHostVO>();
  String sql=DOWNLOADS_STATE_DC_POD;
  try (PreparedStatement pstmt=txn.prepareStatement(sql)){
    pstmt.setLong(1,datacenterId);
    pstmt.setLong(2,podId);
    pstmt.setLong(3,templateId);
    pstmt.setString(4,downloadState.toString());
    try (ResultSet rs=pstmt.executeQuery()){
      while (rs.next()) {
        long id=rs.getLong(1);
        result.add(findById(id));
      }
    }
 catch (    SQLException e) {
      s_logger.warn("String_Node_Str" + e.getMessage(),e);
    }
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str" + e.getMessage(),e);
  }
  return result;
}
Program: 105611
Project: 105611
Buggy source:
@DB @Override public List<EngineHostVO> findLostHosts(long timeout){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  PreparedStatement pstmt=null;
  List<EngineHostVO> result=new ArrayList<EngineHostVO>();
  ResultSet rs=null;
  try {
    String sql="String_Node_Str";
    pstmt=txn.prepareStatement(sql);
    pstmt.setLong(1,timeout);
    rs=pstmt.executeQuery();
    while (rs.next()) {
      long id=rs.getLong(1);
      result.add(findById(id));
    }
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str",e);
  }
 finally {
    try {
      if (rs != null) {
        rs.close();
      }
      if (pstmt != null) {
        pstmt.close();
      }
    }
 catch (    SQLException e) {
    }
  }
  return result;
}

Fixed version (ground truth):
@DB @Override public List<EngineHostVO> findLostHosts(long timeout){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  List<EngineHostVO> result=new ArrayList<EngineHostVO>();
  String sql="String_Node_Str";
  try (PreparedStatement pstmt=txn.prepareStatement(sql)){
    pstmt.setLong(1,timeout);
    try (ResultSet rs=pstmt.executeQuery()){
      while (rs.next()) {
        long id=rs.getLong(1);
        result.add(findById(id));
      }
    }
 catch (    Exception e) {
      s_logger.warn("String_Node_Str",e);
    }
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str",e);
  }
  return result;
}
Program: 105613
Project: 105613
Buggy source:
private Hashtable<String,String> getEnvironment(final String principal,final String password,final String providerUrl,final boolean isSystemContext){
  final String factory=_ldapConfiguration.getFactory();
  final String url=providerUrl == null ? _ldapConfiguration.getProviderUrl() : providerUrl;
  final Hashtable<String,String> environment=new Hashtable<String,String>();
  environment.put(Context.INITIAL_CONTEXT_FACTORY,factory);
  environment.put(Context.PROVIDER_URL,url);
  environment.put("String_Node_Str","String_Node_Str");
  environment.put("String_Node_Str","String_Node_Str");
  enableSSL(environment);
  setAuthentication(environment,isSystemContext);
  if (principal != null) {
    environment.put(Context.SECURITY_PRINCIPAL,principal);
  }
  if (password != null) {
    environment.put(Context.SECURITY_CREDENTIALS,password);
  }
  return environment;
}

Fixed version (ground truth):
private Hashtable<String,String> getEnvironment(final String principal,final String password,final String providerUrl,final boolean isSystemContext){
  final String factory=_ldapConfiguration.getFactory();
  final String url=providerUrl == null ? _ldapConfiguration.getProviderUrl() : providerUrl;
  final Hashtable<String,String> environment=new Hashtable<String,String>();
  environment.put(Context.INITIAL_CONTEXT_FACTORY,factory);
  environment.put(Context.PROVIDER_URL,url);
  environment.put("String_Node_Str",_ldapConfiguration.getReadTimeout().toString());
  environment.put("String_Node_Str","String_Node_Str");
  enableSSL(environment);
  setAuthentication(environment,isSystemContext);
  if (principal != null) {
    environment.put(Context.SECURITY_PRINCIPAL,principal);
  }
  if (password != null) {
    environment.put(Context.SECURITY_CREDENTIALS,password);
  }
  return environment;
}
Program: 105614
Project: 105614
Buggy source:
@Override public NicTO toNicTO(NicProfile profile){
  NicTO to=new NicTO();
  to.setDeviceId(profile.getDeviceId());
  to.setBroadcastType(profile.getBroadcastType());
  to.setType(profile.getTrafficType());
  to.setIp(profile.getIp4Address());
  to.setNetmask(profile.getNetmask());
  to.setMac(profile.getMacAddress());
  to.setDns1(profile.getDns1());
  to.setDns2(profile.getDns2());
  to.setGateway(profile.getGateway());
  to.setDefaultNic(profile.isDefaultNic());
  to.setBroadcastUri(profile.getBroadCastUri());
  to.setIsolationuri(profile.getIsolationUri());
  to.setNetworkRateMbps(profile.getNetworkRate());
  to.setName(profile.getName());
  to.setSecurityGroupEnabled(profile.isSecurityGroupEnabled());
  NetworkVO network=_networkDao.findById(profile.getNetworkId());
  to.setNetworkUuid(network.getUuid());
  NicVO nicVO=_nicDao.findById(profile.getId());
  if (nicVO != null) {
    to.setUuid(nicVO.getUuid());
    if (nicVO.getVmType() != VirtualMachine.Type.User) {
      to.setPxeDisable(true);
    }
  }
 else {
    s_logger.warn("String_Node_Str" + profile.getId());
  }
  List<String> secIps=null;
  if (nicVO.getSecondaryIp()) {
    secIps=_nicSecIpDao.getSecondaryIpAddressesForNic(nicVO.getId());
  }
  to.setNicSecIps(secIps);
  return to;
}

Fixed version (ground truth):
@Override public NicTO toNicTO(NicProfile profile){
  NicTO to=new NicTO();
  to.setDeviceId(profile.getDeviceId());
  to.setBroadcastType(profile.getBroadcastType());
  to.setType(profile.getTrafficType());
  to.setIp(profile.getIp4Address());
  to.setNetmask(profile.getNetmask());
  to.setMac(profile.getMacAddress());
  to.setDns1(profile.getDns1());
  to.setDns2(profile.getDns2());
  to.setGateway(profile.getGateway());
  to.setDefaultNic(profile.isDefaultNic());
  to.setBroadcastUri(profile.getBroadCastUri());
  to.setIsolationuri(profile.getIsolationUri());
  to.setNetworkRateMbps(profile.getNetworkRate());
  to.setName(profile.getName());
  to.setSecurityGroupEnabled(profile.isSecurityGroupEnabled());
  NetworkVO network=_networkDao.findById(profile.getNetworkId());
  to.setNetworkUuid(network.getUuid());
  NicVO nicVO=_nicDao.findById(profile.getId());
  if (nicVO != null) {
    to.setUuid(nicVO.getUuid());
    if (nicVO.getVmType() != VirtualMachine.Type.User) {
      to.setPxeDisable(true);
    }
    List<String> secIps=null;
    if (nicVO.getSecondaryIp()) {
      secIps=_nicSecIpDao.getSecondaryIpAddressesForNic(nicVO.getId());
    }
    to.setNicSecIps(secIps);
  }
 else {
    s_logger.warn("String_Node_Str" + profile.getId());
  }
  return to;
}