Program: 107115
Project: 107115
Buggy source:
protected SR getIscsiSR(Connection conn,StorageFilerTO pool){
synchronized (pool.getUuid().intern()) {
    Map<String,String> deviceConfig=new HashMap<String,String>();
    try {
      String target=pool.getHost();
      String path=pool.getPath();
      if (path.endsWith("String_Node_Str")) {
        path=path.substring(0,path.length() - 1);
      }
      String tmp[]=path.split("String_Node_Str");
      if (tmp.length != 3) {
        String msg="String_Node_Str" + pool.getPath() + "String_Node_Str";
        s_logger.warn(msg);
        throw new CloudRuntimeException(msg);
      }
      String targetiqn=tmp[1].trim();
      String lunid=tmp[2].trim();
      String scsiid="String_Node_Str";
      Set<SR> srs=SR.getByNameLabel(conn,pool.getUuid());
      for (      SR sr : srs) {
        if (!SRType.LVMOISCSI.equals(sr.getType(conn))) {
          continue;
        }
        Set<PBD> pbds=sr.getPBDs(conn);
        if (pbds.isEmpty()) {
          continue;
        }
        PBD pbd=pbds.iterator().next();
        Map<String,String> dc=pbd.getDeviceConfig(conn);
        if (dc == null) {
          continue;
        }
        if (dc.get("String_Node_Str") == null) {
          continue;
        }
        if (dc.get("String_Node_Str") == null) {
          continue;
        }
        if (dc.get("String_Node_Str") == null) {
          continue;
        }
        if (target.equals(dc.get("String_Node_Str")) && targetiqn.equals(dc.get("String_Node_Str")) && lunid.equals(dc.get("String_Node_Str"))) {
          if (checkSR(conn,sr)) {
            return sr;
          }
          throw new CloudRuntimeException("String_Node_Str" + pool.getUuid() + "String_Node_Str"+ _host.uuid);
        }
      }
      deviceConfig.put("String_Node_Str",target);
      deviceConfig.put("String_Node_Str",targetiqn);
      Host host=Host.getByUuid(conn,_host.uuid);
      Map<String,String> smConfig=new HashMap<String,String>();
      String type=SRType.LVMOISCSI.toString();
      String poolId=Long.toString(pool.getId());
      SR sr=null;
      try {
        sr=SR.create(conn,host,deviceConfig,new Long(0),pool.getUuid(),poolId,type,"String_Node_Str",true,smConfig);
      }
 catch (      XenAPIException e) {
        String errmsg=e.toString();
        if (errmsg.contains("String_Node_Str")) {
          String lun[]=errmsg.split("String_Node_Str");
          boolean found=false;
          for (int i=1; i < lun.length; i++) {
            int blunindex=lun[i].indexOf("String_Node_Str") + 7;
            int elunindex=lun[i].indexOf("String_Node_Str");
            String ilun=lun[i].substring(blunindex,elunindex);
            ilun=ilun.trim();
            if (ilun.equals(lunid)) {
              int bscsiindex=lun[i].indexOf("String_Node_Str") + 8;
              int escsiindex=lun[i].indexOf("String_Node_Str");
              scsiid=lun[i].substring(bscsiindex,escsiindex);
              scsiid=scsiid.trim();
              found=true;
              break;
            }
          }
          if (!found) {
            String msg="String_Node_Str" + lunid + "String_Node_Str"+ errmsg;
            s_logger.warn(msg);
            throw new CloudRuntimeException(msg);
          }
        }
 else {
          String msg="String_Node_Str" + deviceConfig + "String_Node_Str"+ e.toString();
          s_logger.warn(msg,e);
          throw new CloudRuntimeException(msg,e);
        }
      }
      deviceConfig.put("String_Node_Str",scsiid);
      String result=SR.probe(conn,host,deviceConfig,type,smConfig);
      String pooluuid=null;
      if (result.indexOf("String_Node_Str") != -1) {
        pooluuid=result.substring(result.indexOf("String_Node_Str") + 6,result.indexOf("String_Node_Str")).trim();
      }
      if (pooluuid == null || pooluuid.length() != 36) {
        sr=SR.create(conn,host,deviceConfig,new Long(0),pool.getUuid(),poolId,type,"String_Node_Str",true,smConfig);
      }
 else {
        sr=SR.introduce(conn,pooluuid,pool.getUuid(),poolId,type,"String_Node_Str",true,smConfig);
        PBD.Record rec=new PBD.Record();
        rec.deviceConfig=deviceConfig;
        rec.host=host;
        rec.SR=sr;
        PBD pbd=PBD.create(conn,rec);
        pbd.plug(conn);
      }
      sr.scan(conn);
      return sr;
    }
 catch (    XenAPIException e) {
      String msg="String_Node_Str" + deviceConfig + "String_Node_Str"+ e.toString();
      s_logger.warn(msg,e);
      throw new CloudRuntimeException(msg,e);
    }
catch (    Exception e) {
      String msg="String_Node_Str" + deviceConfig + "String_Node_Str"+ e.getMessage();
      s_logger.warn(msg,e);
      throw new CloudRuntimeException(msg,e);
    }
  }
}

Fixed version (ground truth):
protected SR getIscsiSR(Connection conn,StorageFilerTO pool){
synchronized (pool.getUuid().intern()) {
    Map<String,String> deviceConfig=new HashMap<String,String>();
    try {
      String target=pool.getHost();
      String path=pool.getPath();
      if (path.endsWith("String_Node_Str")) {
        path=path.substring(0,path.length() - 1);
      }
      String tmp[]=path.split("String_Node_Str");
      if (tmp.length != 3) {
        String msg="String_Node_Str" + pool.getPath() + "String_Node_Str";
        s_logger.warn(msg);
        throw new CloudRuntimeException(msg);
      }
      String targetiqn=tmp[1].trim();
      String lunid=tmp[2].trim();
      String scsiid="String_Node_Str";
      Set<SR> srs=SR.getByNameLabel(conn,pool.getUuid());
      for (      SR sr : srs) {
        if (!SRType.LVMOISCSI.equals(sr.getType(conn))) {
          continue;
        }
        Set<PBD> pbds=sr.getPBDs(conn);
        if (pbds.isEmpty()) {
          continue;
        }
        PBD pbd=pbds.iterator().next();
        Map<String,String> dc=pbd.getDeviceConfig(conn);
        if (dc == null) {
          continue;
        }
        if (dc.get("String_Node_Str") == null) {
          continue;
        }
        if (dc.get("String_Node_Str") == null) {
          continue;
        }
        if (dc.get("String_Node_Str") == null) {
          continue;
        }
        if (target.equals(dc.get("String_Node_Str")) && targetiqn.equals(dc.get("String_Node_Str")) && lunid.equals(dc.get("String_Node_Str"))) {
          throw new CloudRuntimeException("String_Node_Str" + dc.get("String_Node_Str") + "String_Node_Str"+ dc.get("String_Node_Str")+ "String_Node_Str"+ dc.get("String_Node_Str")+ "String_Node_Str"+ pool.getUuid()+ "String_Node_Str"+ _host.uuid);
        }
      }
      deviceConfig.put("String_Node_Str",target);
      deviceConfig.put("String_Node_Str",targetiqn);
      Host host=Host.getByUuid(conn,_host.uuid);
      Map<String,String> smConfig=new HashMap<String,String>();
      String type=SRType.LVMOISCSI.toString();
      String poolId=Long.toString(pool.getId());
      SR sr=null;
      try {
        sr=SR.create(conn,host,deviceConfig,new Long(0),pool.getUuid(),poolId,type,"String_Node_Str",true,smConfig);
      }
 catch (      XenAPIException e) {
        String errmsg=e.toString();
        if (errmsg.contains("String_Node_Str")) {
          String lun[]=errmsg.split("String_Node_Str");
          boolean found=false;
          for (int i=1; i < lun.length; i++) {
            int blunindex=lun[i].indexOf("String_Node_Str") + 7;
            int elunindex=lun[i].indexOf("String_Node_Str");
            String ilun=lun[i].substring(blunindex,elunindex);
            ilun=ilun.trim();
            if (ilun.equals(lunid)) {
              int bscsiindex=lun[i].indexOf("String_Node_Str") + 8;
              int escsiindex=lun[i].indexOf("String_Node_Str");
              scsiid=lun[i].substring(bscsiindex,escsiindex);
              scsiid=scsiid.trim();
              found=true;
              break;
            }
          }
          if (!found) {
            String msg="String_Node_Str" + lunid + "String_Node_Str"+ errmsg;
            s_logger.warn(msg);
            throw new CloudRuntimeException(msg);
          }
        }
 else {
          String msg="String_Node_Str" + deviceConfig + "String_Node_Str"+ e.toString();
          s_logger.warn(msg,e);
          throw new CloudRuntimeException(msg,e);
        }
      }
      deviceConfig.put("String_Node_Str",scsiid);
      String result=SR.probe(conn,host,deviceConfig,type,smConfig);
      String pooluuid=null;
      if (result.indexOf("String_Node_Str") != -1) {
        pooluuid=result.substring(result.indexOf("String_Node_Str") + 6,result.indexOf("String_Node_Str")).trim();
      }
      if (pooluuid == null || pooluuid.length() != 36) {
        sr=SR.create(conn,host,deviceConfig,new Long(0),pool.getUuid(),poolId,type,"String_Node_Str",true,smConfig);
      }
 else {
        sr=SR.introduce(conn,pooluuid,pool.getUuid(),poolId,type,"String_Node_Str",true,smConfig);
        PBD.Record rec=new PBD.Record();
        rec.deviceConfig=deviceConfig;
        rec.host=host;
        rec.SR=sr;
        PBD pbd=PBD.create(conn,rec);
        pbd.plug(conn);
      }
      sr.scan(conn);
      return sr;
    }
 catch (    XenAPIException e) {
      String msg="String_Node_Str" + deviceConfig + "String_Node_Str"+ e.toString();
      s_logger.warn(msg,e);
      throw new CloudRuntimeException(msg,e);
    }
catch (    Exception e) {
      String msg="String_Node_Str" + deviceConfig + "String_Node_Str"+ e.getMessage();
      s_logger.warn(msg,e);
      throw new CloudRuntimeException(msg,e);
    }
  }
}