nus-yam/ex-repair huggingface dataset:
Program: 105618
Project: 105618
Buggy source:
@Override protected void runInContext(){
  try {
    GlobalLock lock=GlobalLock.getInternLock("String_Node_Str");
    if (lock == null) {
      s_logger.debug("String_Node_Str");
      return;
    }
    if (!lock.lock(30)) {
      s_logger.debug("String_Node_Str");
      return;
    }
    try {
      List<VpcVO> inactiveVpcs=_vpcDao.listInactiveVpcs();
      s_logger.info("String_Node_Str" + inactiveVpcs.size() + "String_Node_Str");
      for (      VpcVO vpc : inactiveVpcs) {
        s_logger.debug("String_Node_Str" + vpc);
        destroyVpc(vpc,_accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM),User.UID_SYSTEM);
      }
    }
 catch (    Exception e) {
      s_logger.error("String_Node_Str",e);
    }
 finally {
      lock.unlock();
    }
  }
 catch (  Exception e) {
    s_logger.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Override protected void runInContext(){
  try {
    GlobalLock lock=GlobalLock.getInternLock("String_Node_Str");
    if (lock == null) {
      s_logger.debug("String_Node_Str");
      return;
    }
    if (!lock.lock(30)) {
      s_logger.debug("String_Node_Str");
      return;
    }
    try {
      List<VpcVO> inactiveVpcs=_vpcDao.listInactiveVpcs();
      if (inactiveVpcs != null) {
        s_logger.info("String_Node_Str" + inactiveVpcs.size() + "String_Node_Str");
        for (        VpcVO vpc : inactiveVpcs) {
          s_logger.debug("String_Node_Str" + vpc);
          destroyVpc(vpc,_accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM),User.UID_SYSTEM);
        }
      }
    }
 catch (    Exception e) {
      s_logger.error("String_Node_Str",e);
    }
 finally {
      lock.unlock();
    }
  }
 catch (  Exception e) {
    s_logger.error("String_Node_Str",e);
  }
}
Program: 105619
Project: 105619
Buggy source:
public List<LdapUser> getUsersInGroup(String groupName,DirContext context) throws NamingException {
  String attributeName=_ldapConfiguration.getGroupUniqueMemeberAttribute();
  final SearchControls controls=new SearchControls();
  controls.setSearchScope(_ldapConfiguration.getScope());
  controls.setReturningAttributes(new String[]{attributeName});
  NamingEnumeration<SearchResult> result=context.search(_ldapConfiguration.getBaseDn(),generateGroupSearchFilter(groupName),controls);
  final List<LdapUser> users=new ArrayList<LdapUser>();
  if (result.hasMoreElements()) {
    Attribute attribute=result.nextElement().getAttributes().get(attributeName);
    NamingEnumeration<?> values=attribute.getAll();
    while (values.hasMoreElements()) {
      String userdn=String.valueOf(values.nextElement());
      users.add(getUserForDn(userdn,context));
    }
  }
  Collections.sort(users);
  return users;
}

Fixed version (ground truth):
public List<LdapUser> getUsersInGroup(String groupName,DirContext context) throws NamingException {
  String attributeName=_ldapConfiguration.getGroupUniqueMemeberAttribute();
  final SearchControls controls=new SearchControls();
  controls.setSearchScope(_ldapConfiguration.getScope());
  controls.setReturningAttributes(new String[]{attributeName});
  NamingEnumeration<SearchResult> result=context.search(_ldapConfiguration.getBaseDn(),generateGroupSearchFilter(groupName),controls);
  final List<LdapUser> users=new ArrayList<LdapUser>();
  if (result.hasMoreElements()) {
    Attribute attribute=result.nextElement().getAttributes().get(attributeName);
    NamingEnumeration<?> values=attribute.getAll();
    while (values.hasMoreElements()) {
      String userdn=String.valueOf(values.nextElement());
      try {
        users.add(getUserForDn(userdn,context));
      }
 catch (      NamingException e) {
        s_logger.info("String_Node_Str" + userdn + "String_Node_Str"+ e.getMessage());
      }
    }
  }
  Collections.sort(users);
  return users;
}
Program: 105620
Project: 105620
Buggy source:
@Override public Long getVirtualSize(File file){
  return file.length();
}

Fixed version (ground truth):
@Override public long getVirtualSize(File file){
  return file.length();
}
Program: 105621
Project: 105621
Buggy source:
@Override public Long getVirtualSize(File file){
  try {
    long size=getTemplateVirtualSize(file.getParent(),file.getName());
    return size;
  }
 catch (  Exception e) {
  }
  return file.length();
}

Fixed version (ground truth):
@Override public long getVirtualSize(File file){
  try {
    long size=getTemplateVirtualSize(file.getParent(),file.getName());
    return size;
  }
 catch (  Exception e) {
  }
  return file.length();
}
Program: 105622
Project: 105622
Buggy source:
Long getVirtualSize(File file);

Fixed version (ground truth):
long getVirtualSize(File file) throws IOException ;
Program: 105623
Project: 105623
Buggy source:
@Override public FormatInfo process(String templatePath,ImageFormat format,String templateName){
  if (format != null) {
    s_logger.debug("String_Node_Str" + format + "String_Node_Str");
    return null;
  }
  String qcow2Path=templatePath + File.separator + templateName+ "String_Node_Str"+ ImageFormat.QCOW2.getFileExtension();
  if (!_storage.exists(qcow2Path)) {
    s_logger.debug("String_Node_Str" + qcow2Path);
    return null;
  }
  FormatInfo info=new FormatInfo();
  info.format=ImageFormat.QCOW2;
  info.filename=templateName + "String_Node_Str" + ImageFormat.QCOW2.getFileExtension();
  File qcow2File=_storage.getFile(qcow2Path);
  info.size=_storage.getSize(qcow2Path);
  FileInputStream strm=null;
  byte[] b=new byte[8];
  try {
    strm=new FileInputStream(qcow2File);
    strm.skip(24);
    strm.read(b);
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str" + qcow2Path,e);
    return null;
  }
 finally {
    if (strm != null) {
      try {
        strm.close();
      }
 catch (      IOException e) {
      }
    }
  }
  long templateSize=NumbersUtil.bytesToLong(b);
  info.virtualSize=templateSize;
  return info;
}

Fixed version (ground truth):
@Override public FormatInfo process(String templatePath,ImageFormat format,String templateName){
  if (format != null) {
    s_logger.debug("String_Node_Str" + format + "String_Node_Str");
    return null;
  }
  String qcow2Path=templatePath + File.separator + templateName+ "String_Node_Str"+ ImageFormat.QCOW2.getFileExtension();
  if (!_storage.exists(qcow2Path)) {
    s_logger.debug("String_Node_Str" + qcow2Path);
    return null;
  }
  FormatInfo info=new FormatInfo();
  info.format=ImageFormat.QCOW2;
  info.filename=templateName + "String_Node_Str" + ImageFormat.QCOW2.getFileExtension();
  File qcow2File=_storage.getFile(qcow2Path);
  info.size=_storage.getSize(qcow2Path);
  try {
    info.virtualSize=getVirtualSize(qcow2File);
  }
 catch (  IOException e) {
    s_logger.error("String_Node_Str" + qcow2File.getName());
    return null;
  }
  return info;
}
Program: 105624
Project: 105624
Buggy source:
@Override public Long getVirtualSize(File file){
  FileInputStream strm=null;
  byte[] b=new byte[8];
  try {
    strm=new FileInputStream(file);
    strm.skip(24);
    strm.read(b);
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str" + file,e);
    return null;
  }
 finally {
    if (strm != null) {
      try {
        strm.close();
      }
 catch (      IOException e) {
      }
    }
  }
  long templateSize=NumbersUtil.bytesToLong(b);
  return templateSize;
}

Fixed version (ground truth):
@Override public long getVirtualSize(File file) throws IOException {
  byte[] b=new byte[8];
  try (FileInputStream strm=new FileInputStream(file)){
    if (strm.skip(VIRTUALSIZE_HEADER_LOCATION) != VIRTUALSIZE_HEADER_LOCATION) {
      throw new IOException("String_Node_Str");
    }
    if (strm.read(b) != 8) {
      throw new IOException("String_Node_Str");
    }
  }
   return NumbersUtil.bytesToLong(b);
}
Program: 105625
Project: 105625
Buggy source:
@Override public Long getVirtualSize(File file){
  return file.length();
}

Fixed version (ground truth):
@Override public long getVirtualSize(File file){
  return file.length();
}
Program: 105626
Project: 105626
Buggy source:
@Override public Long getVirtualSize(File file){
  FileInputStream strm=null;
  byte[] currentSize=new byte[8];
  byte[] creatorApp=new byte[4];
  try {
    strm=new FileInputStream(file);
    strm.skip(file.length() - vhdFooterSize + vhdFooterCreatorAppOffset);
    strm.read(creatorApp);
    strm.skip(vhdFooterCurrentSizeOffset - vhdFooterCreatorVerOffset);
    strm.read(currentSize);
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str" + file.getAbsolutePath(),e);
    throw new CloudRuntimeException("String_Node_Str" + file.getAbsolutePath() + "String_Node_Str"+ e);
  }
 finally {
    if (strm != null) {
      try {
        strm.close();
      }
 catch (      IOException e) {
      }
    }
  }
  long templateSize=NumbersUtil.bytesToLong(currentSize);
  return templateSize;
}

Fixed version (ground truth):
@Override public long getVirtualSize(File file){
  FileInputStream strm=null;
  byte[] currentSize=new byte[8];
  byte[] creatorApp=new byte[4];
  try {
    strm=new FileInputStream(file);
    strm.skip(file.length() - vhdFooterSize + vhdFooterCreatorAppOffset);
    strm.read(creatorApp);
    strm.skip(vhdFooterCurrentSizeOffset - vhdFooterCreatorVerOffset);
    strm.read(currentSize);
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str" + file.getAbsolutePath(),e);
    throw new CloudRuntimeException("String_Node_Str" + file.getAbsolutePath() + "String_Node_Str"+ e);
  }
 finally {
    if (strm != null) {
      try {
        strm.close();
      }
 catch (      IOException e) {
      }
    }
  }
  long templateSize=NumbersUtil.bytesToLong(currentSize);
  return templateSize;
}
Program: 105627
Project: 105627
Buggy source:
@Override public Long getVirtualSize(File file){
  try {
    long size=getTemplateVirtualSize(file.getParent(),file.getName());
    return size;
  }
 catch (  Exception e) {
  }
  return file.length();
}

Fixed version (ground truth):
@Override public long getVirtualSize(File file){
  try {
    long size=getTemplateVirtualSize(file.getParent(),file.getName());
    return size;
  }
 catch (  Exception e) {
  }
  return file.length();
}
Program: 105628
Project: 105628
Buggy source:
public long getTemplateVirtualSize(String templatePath,String templateName) throws InternalErrorException {
  long virtualSize=0;
  String templateFileFullPath=templatePath.endsWith(File.separator) ? templatePath : templatePath + File.separator;
  templateFileFullPath+=templateName.endsWith(ImageFormat.VMDK.getFileExtension()) ? templateName : templateName + "String_Node_Str" + ImageFormat.VMDK.getFileExtension();
  String vmdkHeader="String_Node_Str";
  try {
    FileReader fileReader=new FileReader(templateFileFullPath);
    BufferedReader bufferedReader=new BufferedReader(fileReader);
    Pattern regex=Pattern.compile("String_Node_Str");
    String line=null;
    while ((line=bufferedReader.readLine()) != null) {
      Matcher m=regex.matcher(line);
      if (m.find()) {
        long sectors=Long.parseLong(m.group(2));
        virtualSize=sectors * 512;
        break;
      }
    }
    bufferedReader.close();
  }
 catch (  FileNotFoundException ex) {
    String msg="String_Node_Str" + templateFileFullPath + "String_Node_Str"+ ex.toString();
    s_logger.error(msg);
    throw new InternalErrorException(msg);
  }
catch (  IOException ex) {
    String msg="String_Node_Str" + templateFileFullPath + "String_Node_Str"+ ex.toString();
    s_logger.error(msg);
    throw new InternalErrorException(msg);
  }
  s_logger.debug("String_Node_Str" + virtualSize);
  return virtualSize;
}

Fixed version (ground truth):
public long getTemplateVirtualSize(String templatePath,String templateName) throws InternalErrorException {
  long virtualSize=0;
  String templateFileFullPath=templatePath.endsWith(File.separator) ? templatePath : templatePath + File.separator;
  templateFileFullPath+=templateName.endsWith(ImageFormat.VMDK.getFileExtension()) ? templateName : templateName + "String_Node_Str" + ImageFormat.VMDK.getFileExtension();
  try {
    FileReader fileReader=new FileReader(templateFileFullPath);
    BufferedReader bufferedReader=new BufferedReader(fileReader);
    Pattern regex=Pattern.compile("String_Node_Str");
    String line=null;
    while ((line=bufferedReader.readLine()) != null) {
      Matcher m=regex.matcher(line);
      if (m.find()) {
        long sectors=Long.parseLong(m.group(2));
        virtualSize=sectors * 512;
        break;
      }
    }
    bufferedReader.close();
  }
 catch (  FileNotFoundException ex) {
    String msg="String_Node_Str" + templateFileFullPath + "String_Node_Str"+ ex.toString();
    s_logger.error(msg);
    throw new InternalErrorException(msg);
  }
catch (  IOException ex) {
    String msg="String_Node_Str" + templateFileFullPath + "String_Node_Str"+ ex.toString();
    s_logger.error(msg);
    throw new InternalErrorException(msg);
  }
  s_logger.debug("String_Node_Str" + virtualSize);
  return virtualSize;
}
Program: 105629
Project: 105629
Buggy source:
protected Long getVirtualSize(File file,ImageFormat format){
  Processor processor=null;
  try {
    if (format == null) {
      return file.length();
    }
 else     if (format == ImageFormat.QCOW2) {
      processor=new QCOW2Processor();
    }
 else     if (format == ImageFormat.OVA) {
      processor=new OVAProcessor();
    }
 else     if (format == ImageFormat.VHD) {
      processor=new VhdProcessor();
    }
 else     if (format == ImageFormat.RAW) {
      processor=new RawImageProcessor();
    }
 else     if (format == ImageFormat.VMDK) {
      processor=new VmdkProcessor();
    }
    if (processor == null) {
      return file.length();
    }
    processor.configure("String_Node_Str",new HashMap<String,Object>());
    return processor.getVirtualSize(file);
  }
 catch (  Exception e) {
    s_logger.debug("String_Node_Str",e);
  }
  return file.length();
}

Fixed version (ground truth):
protected long getVirtualSize(File file,ImageFormat format){
  Processor processor=null;
  try {
    if (format == null) {
      return file.length();
    }
 else     if (format == ImageFormat.QCOW2) {
      processor=new QCOW2Processor();
    }
 else     if (format == ImageFormat.OVA) {
      processor=new OVAProcessor();
    }
 else     if (format == ImageFormat.VHD) {
      processor=new VhdProcessor();
    }
 else     if (format == ImageFormat.RAW) {
      processor=new RawImageProcessor();
    }
 else     if (format == ImageFormat.VMDK) {
      processor=new VmdkProcessor();
    }
    if (processor == null) {
      return file.length();
    }
    processor.configure("String_Node_Str",new HashMap<String,Object>());
    return processor.getVirtualSize(file);
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str",e);
    return file.length();
  }
}
Program: 105633
Project: 105633
Buggy source:
@Override public VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering){
  VpcOfferingResponse response=new VpcOfferingResponse();
  response.setId(offering.getUuid());
  response.setName(offering.getName());
  response.setDisplayText(offering.getDisplayText());
  response.setIsDefault(offering.isDefault());
  response.setState(offering.getState().name());
  response.setSupportsDistributedRouter(offering.supportsDistributedRouter());
  response.setSupportsRegionLevelVpc(offering.offersRegionLevelVPC());
  Map<Service,Set<Provider>> serviceProviderMap=ApiDBUtils.listVpcOffServices(offering.getId());
  List<ServiceResponse> serviceResponses=new ArrayList<ServiceResponse>();
  for (  Service service : serviceProviderMap.keySet()) {
    ServiceResponse svcRsp=new ServiceResponse();
    if (service == Service.Gateway) {
      continue;
    }
    svcRsp.setName(service.getName());
    List<ProviderResponse> providers=new ArrayList<ProviderResponse>();
    for (    Provider provider : serviceProviderMap.get(service)) {
      if (provider != null) {
        ProviderResponse providerRsp=new ProviderResponse();
        providerRsp.setName(provider.getName());
        providers.add(providerRsp);
      }
    }
    svcRsp.setProviders(providers);
    serviceResponses.add(svcRsp);
  }
  response.setServices(serviceResponses);
  response.setObjectName("String_Node_Str");
  return response;
}

Fixed version (ground truth):
@Override public VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering){
  VpcOfferingResponse response=new VpcOfferingResponse();
  response.setId(offering.getUuid());
  response.setName(offering.getName());
  response.setDisplayText(offering.getDisplayText());
  response.setIsDefault(offering.isDefault());
  response.setState(offering.getState().name());
  response.setSupportsDistributedRouter(offering.supportsDistributedRouter());
  response.setSupportsRegionLevelVpc(offering.offersRegionLevelVPC());
  Map<Service,Set<Provider>> serviceProviderMap=ApiDBUtils.listVpcOffServices(offering.getId());
  List<ServiceResponse> serviceResponses=new ArrayList<ServiceResponse>();
  for (  Map.Entry<Service,Set<Provider>> entry : serviceProviderMap.entrySet()) {
    Service service=entry.getKey();
    Set<Provider> srvc_providers=entry.getValue();
    ServiceResponse svcRsp=new ServiceResponse();
    if (service == Service.Gateway) {
      continue;
    }
    svcRsp.setName(service.getName());
    List<ProviderResponse> providers=new ArrayList<ProviderResponse>();
    for (    Provider provider : srvc_providers) {
      if (provider != null) {
        ProviderResponse providerRsp=new ProviderResponse();
        providerRsp.setName(provider.getName());
        providers.add(providerRsp);
      }
    }
    svcRsp.setProviders(providers);
    serviceResponses.add(svcRsp);
  }
  response.setServices(serviceResponses);
  response.setObjectName("String_Node_Str");
  return response;
}
Program: 105634
Project: 105634
Buggy source:
@Override public IpForwardingRuleResponse createIpForwardingRuleResponse(StaticNatRule fwRule){
  IpForwardingRuleResponse response=new IpForwardingRuleResponse();
  response.setId(fwRule.getUuid());
  response.setProtocol(fwRule.getProtocol());
  IpAddress ip=ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
  response.setPublicIpAddressId(ip.getId());
  response.setPublicIpAddress(ip.getAddress().addr());
  if (ip != null && fwRule.getDestIpAddress() != null) {
    UserVm vm=ApiDBUtils.findUserVmById(ip.getAssociatedWithVmId());
    if (vm != null) {
      response.setVirtualMachineId(vm.getUuid());
      response.setVirtualMachineName(vm.getHostName());
      if (vm.getDisplayName() != null) {
        response.setVirtualMachineDisplayName(vm.getDisplayName());
      }
 else {
        response.setVirtualMachineDisplayName(vm.getHostName());
      }
    }
  }
  FirewallRule.State state=fwRule.getState();
  String stateToSet=state.toString();
  if (state.equals(FirewallRule.State.Revoke)) {
    stateToSet="String_Node_Str";
  }
  response.setStartPort(fwRule.getSourcePortStart());
  response.setEndPort(fwRule.getSourcePortEnd());
  response.setProtocol(fwRule.getProtocol());
  response.setState(stateToSet);
  response.setObjectName("String_Node_Str");
  return response;
}

Fixed version (ground truth):
@Override public IpForwardingRuleResponse createIpForwardingRuleResponse(StaticNatRule fwRule){
  IpForwardingRuleResponse response=new IpForwardingRuleResponse();
  response.setId(fwRule.getUuid());
  response.setProtocol(fwRule.getProtocol());
  IpAddress ip=ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
  if (ip != null) {
    response.setPublicIpAddressId(ip.getId());
    response.setPublicIpAddress(ip.getAddress().addr());
    if (fwRule.getDestIpAddress() != null) {
      UserVm vm=ApiDBUtils.findUserVmById(ip.getAssociatedWithVmId());
      if (vm != null) {
        response.setVirtualMachineId(vm.getUuid());
        response.setVirtualMachineName(vm.getHostName());
        if (vm.getDisplayName() != null) {
          response.setVirtualMachineDisplayName(vm.getDisplayName());
        }
 else {
          response.setVirtualMachineDisplayName(vm.getHostName());
        }
      }
    }
  }
  FirewallRule.State state=fwRule.getState();
  String stateToSet=state.toString();
  if (state.equals(FirewallRule.State.Revoke)) {
    stateToSet="String_Node_Str";
  }
  response.setStartPort(fwRule.getSourcePortStart());
  response.setEndPort(fwRule.getSourcePortEnd());
  response.setProtocol(fwRule.getProtocol());
  response.setState(stateToSet);
  response.setObjectName("String_Node_Str");
  return response;
}
Program: 105641
Project: 105641
Buggy source:
private void dropInvalidKeyFromStoragePoolTable(Connection conn){
  HashMap<String,List<String>> uniqueKeys=new HashMap<String,List<String>>();
  List<String> keys=new ArrayList<String>();
  keys.add("String_Node_Str");
  uniqueKeys.put("String_Node_Str",keys);
  s_logger.debug("String_Node_Str");
  for (  String tableName : uniqueKeys.keySet()) {
    DbUpgradeUtils.dropKeysIfExist(conn,tableName,uniqueKeys.get(tableName),false);
  }
}

Fixed version (ground truth):
private void dropInvalidKeyFromStoragePoolTable(Connection conn){
  HashMap<String,List<String>> uniqueKeys=new HashMap<String,List<String>>();
  List<String> keys=new ArrayList<String>();
  keys.add("String_Node_Str");
  uniqueKeys.put("String_Node_Str",keys);
  s_logger.debug("String_Node_Str");
  for (  Map.Entry<String,List<String>> entry : uniqueKeys.entrySet()) {
    DbUpgradeUtils.dropKeysIfExist(conn,entry.getKey(),entry.getValue(),false);
  }
}
Program: 105644
Project: 105644
Buggy source:
private void cleanUpTmpDomVif(Connection conn,Network nw) throws XenAPIException, XmlRpcException {
  Pair<VM,VM.Record> vm=getControlDomain(conn);
  VM dom0=vm.first();
  Set<VIF> dom0Vifs=dom0.getVIFs(conn);
  for (  VIF v : dom0Vifs) {
    String vifName="String_Node_Str";
    try {
      VIF.Record vifr=v.getRecord(conn);
      if (v.getNetwork(conn).getUuid(conn).equals(nw.getUuid(conn))) {
        Map<String,String> config=vifr.otherConfig;
        vifName=config.get("String_Node_Str");
        s_logger.debug("String_Node_Str");
        v.destroy(conn);
        s_logger.debug("String_Node_Str" + vifName + "String_Node_Str");
      }
    }
 catch (    Exception e) {
      s_logger.warn("String_Node_Str" + vifName + "String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
private void cleanUpTmpDomVif(Connection conn,Network nw) throws XenAPIException, XmlRpcException {
  Pair<VM,VM.Record> vm=getControlDomain(conn);
  VM dom0=vm.first();
  Set<VIF> dom0Vifs=dom0.getVIFs(conn);
  for (  VIF v : dom0Vifs) {
    String vifName="String_Node_Str";
    try {
      VIF.Record vifr=v.getRecord(conn);
      if (v.getNetwork(conn).getUuid(conn).equals(nw.getUuid(conn))) {
        if (vifr != null) {
          Map<String,String> config=vifr.otherConfig;
          vifName=config.get("String_Node_Str");
        }
        s_logger.debug("String_Node_Str");
        v.destroy(conn);
        s_logger.debug("String_Node_Str" + vifName + "String_Node_Str");
      }
    }
 catch (    Exception e) {
      s_logger.warn("String_Node_Str" + vifName + "String_Node_Str",e);
    }
  }
}
Program: 105645
Project: 105645
Buggy source:
@Override public List<VMTemplateStoragePoolVO> listByTemplateStatus(long templateId,long datacenterId,long podId,VMTemplateStoragePoolVO.Status downloadState){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  PreparedStatement pstmt=null;
  List<VMTemplateStoragePoolVO> result=new ArrayList<VMTemplateStoragePoolVO>();
  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<VMTemplateStoragePoolVO> listByTemplateStatus(long templateId,long datacenterId,long podId,VMTemplateStoragePoolVO.Status downloadState){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  List<VMTemplateStoragePoolVO> result=new ArrayList<VMTemplateStoragePoolVO>();
  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 (    Exception e) {
      s_logger.warn("String_Node_Str",e);
    }
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str",e);
  }
  return result;
}
Program: 105646
Project: 105646
Buggy source:
public List<VMTemplateStoragePoolVO> listByHostTemplate(long hostId,long templateId){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  PreparedStatement pstmt=null;
  List<VMTemplateStoragePoolVO> result=new ArrayList<VMTemplateStoragePoolVO>();
  ResultSet rs=null;
  try {
    String sql=HOST_TEMPLATE_SEARCH;
    pstmt=txn.prepareStatement(sql);
    pstmt.setLong(1,hostId);
    pstmt.setLong(2,templateId);
    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):
public List<VMTemplateStoragePoolVO> listByHostTemplate(long hostId,long templateId){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  List<VMTemplateStoragePoolVO> result=new ArrayList<VMTemplateStoragePoolVO>();
  String sql=HOST_TEMPLATE_SEARCH;
  try (PreparedStatement pstmt=txn.prepareStatement(sql)){
    pstmt.setLong(1,hostId);
    pstmt.setLong(2,templateId);
    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: 105647
Project: 105647
Buggy source:
@DB protected EndPoint findEndPointInScope(Scope scope,String sqlBase,Long poolId){
  StringBuilder sbuilder=new StringBuilder();
  sbuilder.append(sqlBase);
  if (scope.getScopeType() == ScopeType.HOST) {
    sbuilder.append("String_Node_Str");
    sbuilder.append(scope.getScopeId());
  }
 else   if (scope.getScopeType() == ScopeType.CLUSTER) {
    sbuilder.append("String_Node_Str");
    sbuilder.append(scope.getScopeId());
  }
 else   if (scope.getScopeType() == ScopeType.ZONE) {
    sbuilder.append("String_Node_Str");
    sbuilder.append(scope.getScopeId());
  }
  sbuilder.append("String_Node_Str");
  String sql=sbuilder.toString();
  PreparedStatement pstmt=null;
  ResultSet rs=null;
  HostVO host=null;
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  try {
    pstmt=txn.prepareStatement(sql);
    pstmt.setLong(1,poolId);
    rs=pstmt.executeQuery();
    while (rs.next()) {
      long id=rs.getLong(1);
      host=hostDao.findById(id);
    }
  }
 catch (  SQLException e) {
    s_logger.warn("String_Node_Str",e);
  }
 finally {
    try {
      if (rs != null) {
        rs.close();
      }
      if (pstmt != null) {
        pstmt.close();
      }
    }
 catch (    SQLException e) {
    }
  }
  if (host == null) {
    return null;
  }
  return RemoteHostEndPoint.getHypervisorHostEndPoint(host);
}

Fixed version (ground truth):
@DB protected EndPoint findEndPointInScope(Scope scope,String sqlBase,Long poolId){
  StringBuilder sbuilder=new StringBuilder();
  sbuilder.append(sqlBase);
  if (scope.getScopeType() == ScopeType.HOST) {
    sbuilder.append("String_Node_Str");
    sbuilder.append(scope.getScopeId());
  }
 else   if (scope.getScopeType() == ScopeType.CLUSTER) {
    sbuilder.append("String_Node_Str");
    sbuilder.append(scope.getScopeId());
  }
 else   if (scope.getScopeType() == ScopeType.ZONE) {
    sbuilder.append("String_Node_Str");
    sbuilder.append(scope.getScopeId());
  }
  sbuilder.append("String_Node_Str");
  String sql=sbuilder.toString();
  HostVO host=null;
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  try (PreparedStatement pstmt=txn.prepareStatement(sql)){
    pstmt.setLong(1,poolId);
    try (ResultSet rs=pstmt.executeQuery()){
      while (rs.next()) {
        long id=rs.getLong(1);
        host=hostDao.findById(id);
      }
    }
 catch (    SQLException e) {
      s_logger.warn("String_Node_Str",e);
    }
  }
 catch (  SQLException e) {
    s_logger.warn("String_Node_Str",e);
  }
  if (host == null) {
    return null;
  }
  return RemoteHostEndPoint.getHypervisorHostEndPoint(host);
}
Program: 105649
Project: 105649
Buggy source:
static void addDir(File dirObj,ZipOutputStream out) throws IOException {
  File[] files=dirObj.listFiles();
  byte[] tmpBuf=new byte[1024];
  String pathToDir=s_dirName;
  for (int i=0; i < files.length; i++) {
    if (files[i].isDirectory()) {
      addDir(files[i],out);
      continue;
    }
    FileInputStream in=new FileInputStream(files[i].getPath());
    out.putNextEntry(new ZipEntry(files[i].getPath().substring(pathToDir.length())));
    int len;
    while ((len=in.read(tmpBuf)) > 0) {
      out.write(tmpBuf,0,len);
    }
    out.closeEntry();
    in.close();
  }
}

Fixed version (ground truth):
static void addDir(File dirObj,ZipOutputStream out) throws IOException {
  File[] files=dirObj.listFiles();
  byte[] tmpBuf=new byte[1024];
  String pathToDir=s_dirName;
  for (int i=0; i < files.length; i++) {
    if (files[i].isDirectory()) {
      addDir(files[i],out);
      continue;
    }
    try (FileInputStream in=new FileInputStream(files[i].getPath())){
      out.putNextEntry(new ZipEntry(files[i].getPath().substring(pathToDir.length())));
      int len;
      while ((len=in.read(tmpBuf)) > 0) {
        out.write(tmpBuf,0,len);
      }
      out.closeEntry();
    }
 catch (    IOException ex) {
      s_logger.error("String_Node_Str" + ex.getMessage(),ex);
    }
  }
}
Program: 105650
Project: 105650
Buggy source:
private static void writeAlertTypes(String dirName){
  XStream xs=new XStream();
  xs.alias("String_Node_Str",Alert.class);
  try {
    ObjectOutputStream out=xs.createObjectOutputStream(new FileWriter(dirName + "String_Node_Str"),"String_Node_Str");
    for (    Field f : AlertManager.class.getFields()) {
      if (f.getClass().isAssignableFrom(Number.class)) {
        String name=f.getName().substring(11);
        Alert alert=new Alert(name,f.getInt(null));
        out.writeObject(alert);
      }
    }
    out.close();
  }
 catch (  IOException e) {
    s_logger.error("String_Node_Str",e);
  }
catch (  IllegalAccessException e) {
    s_logger.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
private static void writeAlertTypes(String dirName){
  XStream xs=new XStream();
  xs.alias("String_Node_Str",Alert.class);
  try (ObjectOutputStream out=xs.createObjectOutputStream(new FileWriter(dirName + "String_Node_Str"),"String_Node_Str")){
    for (    Field f : AlertManager.class.getFields()) {
      if (f.getClass().isAssignableFrom(Number.class)) {
        String name=f.getName().substring(11);
        Alert alert=new Alert(name,f.getInt(null));
        out.writeObject(alert);
      }
    }
  }
 catch (  IOException e) {
    s_logger.error("String_Node_Str",e);
  }
catch (  IllegalAccessException e) {
    s_logger.error("String_Node_Str",e);
  }
}
Program: 105651
Project: 105651
Buggy source:
public Map<String,String> getDetails(){
  Map<String,String> customparameterMap=new HashMap<String,String>();
  if (details != null && details.size() != 0) {
    Collection parameterCollection=details.values();
    Iterator iter=parameterCollection.iterator();
    while (iter.hasNext()) {
      HashMap<String,String> value=(HashMap<String,String>)iter.next();
      for (      String key : value.keySet()) {
        customparameterMap.put(key,value.get(key));
      }
    }
  }
  if (rootdisksize != null && !customparameterMap.containsKey("String_Node_Str")) {
    customparameterMap.put("String_Node_Str",rootdisksize.toString());
  }
  return customparameterMap;
}

Fixed version (ground truth):
public Map<String,String> getDetails(){
  Map<String,String> customparameterMap=new HashMap<String,String>();
  if (details != null && details.size() != 0) {
    Collection parameterCollection=details.values();
    Iterator iter=parameterCollection.iterator();
    while (iter.hasNext()) {
      HashMap<String,String> value=(HashMap<String,String>)iter.next();
      for (      Map.Entry<String,String> entry : value.entrySet()) {
        customparameterMap.put(entry.getKey(),entry.getValue());
      }
    }
  }
  if (rootdisksize != null && !customparameterMap.containsKey("String_Node_Str")) {
    customparameterMap.put("String_Node_Str",rootdisksize.toString());
  }
  return customparameterMap;
}
Program: 105655
Project: 105655
Buggy source:
public Map<String,String> getDetails(){
  Map<String,String> customparameterMap=new HashMap<String,String>();
  if (details != null && details.size() != 0) {
    Collection parameterCollection=details.values();
    Iterator iter=parameterCollection.iterator();
    while (iter.hasNext()) {
      HashMap<String,String> value=(HashMap<String,String>)iter.next();
      for (      String key : value.keySet()) {
        customparameterMap.put(key,value.get(key));
      }
    }
  }
  if (rootdisksize != null && !customparameterMap.containsKey("String_Node_Str")) {
    customparameterMap.put("String_Node_Str",rootdisksize.toString());
  }
  return customparameterMap;
}

Fixed version (ground truth):
public Map<String,String> getDetails(){
  Map<String,String> customparameterMap=new HashMap<String,String>();
  if (details != null && details.size() != 0) {
    Collection parameterCollection=details.values();
    Iterator iter=parameterCollection.iterator();
    while (iter.hasNext()) {
      HashMap<String,String> value=(HashMap<String,String>)iter.next();
      for (      Map.Entry<String,String> entry : value.entrySet()) {
        customparameterMap.put(entry.getKey(),entry.getValue());
      }
    }
  }
  if (rootdisksize != null && !customparameterMap.containsKey("String_Node_Str")) {
    customparameterMap.put("String_Node_Str",rootdisksize.toString());
  }
  return customparameterMap;
}
Program: 105656
Project: 105656
Buggy source:
@Override public List<VMTemplateStoragePoolVO> listByTemplateStatus(long templateId,long datacenterId,long podId,VMTemplateStoragePoolVO.Status downloadState){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  PreparedStatement pstmt=null;
  List<VMTemplateStoragePoolVO> result=new ArrayList<VMTemplateStoragePoolVO>();
  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<VMTemplateStoragePoolVO> listByTemplateStatus(long templateId,long datacenterId,long podId,VMTemplateStoragePoolVO.Status downloadState){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  List<VMTemplateStoragePoolVO> result=new ArrayList<VMTemplateStoragePoolVO>();
  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 (    Exception e) {
      s_logger.warn("String_Node_Str",e);
    }
  }
 catch (  Exception e) {
    s_logger.warn("String_Node_Str",e);
  }
  return result;
}
Program: 105657
Project: 105657
Buggy source:
public List<VMTemplateStoragePoolVO> listByHostTemplate(long hostId,long templateId){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  PreparedStatement pstmt=null;
  List<VMTemplateStoragePoolVO> result=new ArrayList<VMTemplateStoragePoolVO>();
  ResultSet rs=null;
  try {
    String sql=HOST_TEMPLATE_SEARCH;
    pstmt=txn.prepareStatement(sql);
    pstmt.setLong(1,hostId);
    pstmt.setLong(2,templateId);
    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):
public List<VMTemplateStoragePoolVO> listByHostTemplate(long hostId,long templateId){
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  List<VMTemplateStoragePoolVO> result=new ArrayList<VMTemplateStoragePoolVO>();
  String sql=HOST_TEMPLATE_SEARCH;
  try (PreparedStatement pstmt=txn.prepareStatement(sql)){
    pstmt.setLong(1,hostId);
    pstmt.setLong(2,templateId);
    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: 105658
Project: 105658
Buggy source:
private void dropInvalidKeyFromStoragePoolTable(Connection conn){
  HashMap<String,List<String>> uniqueKeys=new HashMap<String,List<String>>();
  List<String> keys=new ArrayList<String>();
  keys.add("String_Node_Str");
  uniqueKeys.put("String_Node_Str",keys);
  s_logger.debug("String_Node_Str");
  for (  String tableName : uniqueKeys.keySet()) {
    DbUpgradeUtils.dropKeysIfExist(conn,tableName,uniqueKeys.get(tableName),false);
  }
}

Fixed version (ground truth):
private void dropInvalidKeyFromStoragePoolTable(Connection conn){
  HashMap<String,List<String>> uniqueKeys=new HashMap<String,List<String>>();
  List<String> keys=new ArrayList<String>();
  keys.add("String_Node_Str");
  uniqueKeys.put("String_Node_Str",keys);
  s_logger.debug("String_Node_Str");
  for (  Map.Entry<String,List<String>> entry : uniqueKeys.entrySet()) {
    DbUpgradeUtils.dropKeysIfExist(conn,entry.getKey(),entry.getValue(),false);
  }
}
Program: 105659
Project: 105659
Buggy source:
@DB protected EndPoint findEndPointInScope(Scope scope,String sqlBase,Long poolId){
  StringBuilder sbuilder=new StringBuilder();
  sbuilder.append(sqlBase);
  if (scope.getScopeType() == ScopeType.HOST) {
    sbuilder.append("String_Node_Str");
    sbuilder.append(scope.getScopeId());
  }
 else   if (scope.getScopeType() == ScopeType.CLUSTER) {
    sbuilder.append("String_Node_Str");
    sbuilder.append(scope.getScopeId());
  }
 else   if (scope.getScopeType() == ScopeType.ZONE) {
    sbuilder.append("String_Node_Str");
    sbuilder.append(scope.getScopeId());
  }
  sbuilder.append("String_Node_Str");
  String sql=sbuilder.toString();
  PreparedStatement pstmt=null;
  ResultSet rs=null;
  HostVO host=null;
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  try {
    pstmt=txn.prepareStatement(sql);
    pstmt.setLong(1,poolId);
    rs=pstmt.executeQuery();
    while (rs.next()) {
      long id=rs.getLong(1);
      host=hostDao.findById(id);
    }
  }
 catch (  SQLException e) {
    s_logger.warn("String_Node_Str",e);
  }
 finally {
    try {
      if (rs != null) {
        rs.close();
      }
      if (pstmt != null) {
        pstmt.close();
      }
    }
 catch (    SQLException e) {
    }
  }
  if (host == null) {
    return null;
  }
  return RemoteHostEndPoint.getHypervisorHostEndPoint(host);
}

Fixed version (ground truth):
@DB protected EndPoint findEndPointInScope(Scope scope,String sqlBase,Long poolId){
  StringBuilder sbuilder=new StringBuilder();
  sbuilder.append(sqlBase);
  if (scope.getScopeType() == ScopeType.HOST) {
    sbuilder.append("String_Node_Str");
    sbuilder.append(scope.getScopeId());
  }
 else   if (scope.getScopeType() == ScopeType.CLUSTER) {
    sbuilder.append("String_Node_Str");
    sbuilder.append(scope.getScopeId());
  }
 else   if (scope.getScopeType() == ScopeType.ZONE) {
    sbuilder.append("String_Node_Str");
    sbuilder.append(scope.getScopeId());
  }
  sbuilder.append("String_Node_Str");
  String sql=sbuilder.toString();
  HostVO host=null;
  TransactionLegacy txn=TransactionLegacy.currentTxn();
  try (PreparedStatement pstmt=txn.prepareStatement(sql)){
    pstmt.setLong(1,poolId);
    try (ResultSet rs=pstmt.executeQuery()){
      while (rs.next()) {
        long id=rs.getLong(1);
        host=hostDao.findById(id);
      }
    }
 catch (    SQLException e) {
      s_logger.warn("String_Node_Str",e);
    }
  }
 catch (  SQLException e) {
    s_logger.warn("String_Node_Str",e);
  }
  if (host == null) {
    return null;
  }
  return RemoteHostEndPoint.getHypervisorHostEndPoint(host);
}
Program: 105664
Project: 105664
Buggy source:
@Override public VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering){
  VpcOfferingResponse response=new VpcOfferingResponse();
  response.setId(offering.getUuid());
  response.setName(offering.getName());
  response.setDisplayText(offering.getDisplayText());
  response.setIsDefault(offering.isDefault());
  response.setState(offering.getState().name());
  response.setSupportsDistributedRouter(offering.supportsDistributedRouter());
  response.setSupportsRegionLevelVpc(offering.offersRegionLevelVPC());
  Map<Service,Set<Provider>> serviceProviderMap=ApiDBUtils.listVpcOffServices(offering.getId());
  List<ServiceResponse> serviceResponses=new ArrayList<ServiceResponse>();
  for (  Service service : serviceProviderMap.keySet()) {
    ServiceResponse svcRsp=new ServiceResponse();
    if (service == Service.Gateway) {
      continue;
    }
    svcRsp.setName(service.getName());
    List<ProviderResponse> providers=new ArrayList<ProviderResponse>();
    for (    Provider provider : serviceProviderMap.get(service)) {
      if (provider != null) {
        ProviderResponse providerRsp=new ProviderResponse();
        providerRsp.setName(provider.getName());
        providers.add(providerRsp);
      }
    }
    svcRsp.setProviders(providers);
    serviceResponses.add(svcRsp);
  }
  response.setServices(serviceResponses);
  response.setObjectName("String_Node_Str");
  return response;
}

Fixed version (ground truth):
@Override public VpcOfferingResponse createVpcOfferingResponse(VpcOffering offering){
  VpcOfferingResponse response=new VpcOfferingResponse();
  response.setId(offering.getUuid());
  response.setName(offering.getName());
  response.setDisplayText(offering.getDisplayText());
  response.setIsDefault(offering.isDefault());
  response.setState(offering.getState().name());
  response.setSupportsDistributedRouter(offering.supportsDistributedRouter());
  response.setSupportsRegionLevelVpc(offering.offersRegionLevelVPC());
  Map<Service,Set<Provider>> serviceProviderMap=ApiDBUtils.listVpcOffServices(offering.getId());
  List<ServiceResponse> serviceResponses=new ArrayList<ServiceResponse>();
  for (  Map.Entry<Service,Set<Provider>> entry : serviceProviderMap.entrySet()) {
    Service service=entry.getKey();
    Set<Provider> srvc_providers=entry.getValue();
    ServiceResponse svcRsp=new ServiceResponse();
    if (service == Service.Gateway) {
      continue;
    }
    svcRsp.setName(service.getName());
    List<ProviderResponse> providers=new ArrayList<ProviderResponse>();
    for (    Provider provider : srvc_providers) {
      if (provider != null) {
        ProviderResponse providerRsp=new ProviderResponse();
        providerRsp.setName(provider.getName());
        providers.add(providerRsp);
      }
    }
    svcRsp.setProviders(providers);
    serviceResponses.add(svcRsp);
  }
  response.setServices(serviceResponses);
  response.setObjectName("String_Node_Str");
  return response;
}
Program: 105665
Project: 105665
Buggy source:
@Override public IpForwardingRuleResponse createIpForwardingRuleResponse(StaticNatRule fwRule){
  IpForwardingRuleResponse response=new IpForwardingRuleResponse();
  response.setId(fwRule.getUuid());
  response.setProtocol(fwRule.getProtocol());
  IpAddress ip=ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
  response.setPublicIpAddressId(ip.getId());
  response.setPublicIpAddress(ip.getAddress().addr());
  if (ip != null && fwRule.getDestIpAddress() != null) {
    UserVm vm=ApiDBUtils.findUserVmById(ip.getAssociatedWithVmId());
    if (vm != null) {
      response.setVirtualMachineId(vm.getUuid());
      response.setVirtualMachineName(vm.getHostName());
      if (vm.getDisplayName() != null) {
        response.setVirtualMachineDisplayName(vm.getDisplayName());
      }
 else {
        response.setVirtualMachineDisplayName(vm.getHostName());
      }
    }
  }
  FirewallRule.State state=fwRule.getState();
  String stateToSet=state.toString();
  if (state.equals(FirewallRule.State.Revoke)) {
    stateToSet="String_Node_Str";
  }
  response.setStartPort(fwRule.getSourcePortStart());
  response.setEndPort(fwRule.getSourcePortEnd());
  response.setProtocol(fwRule.getProtocol());
  response.setState(stateToSet);
  response.setObjectName("String_Node_Str");
  return response;
}

Fixed version (ground truth):
@Override public IpForwardingRuleResponse createIpForwardingRuleResponse(StaticNatRule fwRule){
  IpForwardingRuleResponse response=new IpForwardingRuleResponse();
  response.setId(fwRule.getUuid());
  response.setProtocol(fwRule.getProtocol());
  IpAddress ip=ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
  if (ip != null) {
    response.setPublicIpAddressId(ip.getId());
    response.setPublicIpAddress(ip.getAddress().addr());
    if (fwRule.getDestIpAddress() != null) {
      UserVm vm=ApiDBUtils.findUserVmById(ip.getAssociatedWithVmId());
      if (vm != null) {
        response.setVirtualMachineId(vm.getUuid());
        response.setVirtualMachineName(vm.getHostName());
        if (vm.getDisplayName() != null) {
          response.setVirtualMachineDisplayName(vm.getDisplayName());
        }
 else {
          response.setVirtualMachineDisplayName(vm.getHostName());
        }
      }
    }
  }
  FirewallRule.State state=fwRule.getState();
  String stateToSet=state.toString();
  if (state.equals(FirewallRule.State.Revoke)) {
    stateToSet="String_Node_Str";
  }
  response.setStartPort(fwRule.getSourcePortStart());
  response.setEndPort(fwRule.getSourcePortEnd());
  response.setProtocol(fwRule.getProtocol());
  response.setState(stateToSet);
  response.setObjectName("String_Node_Str");
  return response;
}