Program: 89201
Project: 89201
Buggy source:
@Override public Map<? extends ServerResource,Map<String,String>> find(long dcId,Long podId,Long clusterId,URI uri,String username,String password,List<String> hostTags) throws DiscoveryException {
  ClusterVO cluster=_clusterDao.findById(clusterId);
  if (cluster == null || cluster.getHypervisorType() != HypervisorType.KVM) {
    if (s_logger.isInfoEnabled())     s_logger.info("String_Node_Str");
    return null;
  }
  Map<KvmDummyResourceBase,Map<String,String>> resources=new HashMap<KvmDummyResourceBase,Map<String,String>>();
  Map<String,String> details=new HashMap<String,String>();
  if (!uri.getScheme().equals("String_Node_Str")) {
    String msg="String_Node_Str" + uri;
    s_logger.debug(msg);
    return null;
  }
  com.trilead.ssh2.Connection sshConnection=null;
  String agentIp=null;
  try {
    String hostname=uri.getHost();
    InetAddress ia=InetAddress.getByName(hostname);
    agentIp=ia.getHostAddress();
    String guid=UUID.nameUUIDFromBytes(agentIp.getBytes()).toString();
    String guidWithTail=guid + "String_Node_Str";
    if (_resourceMgr.findHostByGuid(guidWithTail) != null) {
      s_logger.debug("String_Node_Str" + agentIp + "String_Node_Str"+ guidWithTail+ "String_Node_Str");
      return null;
    }
    sshConnection=new com.trilead.ssh2.Connection(agentIp,22);
    sshConnection.connect(null,60000,60000);
    if (!sshConnection.authenticateWithPassword(username,password)) {
      s_logger.debug("String_Node_Str");
      throw new DiscoveredWithErrorException("String_Node_Str");
    }
    if (!SSHCmdHelper.sshExecuteCmd(sshConnection,"String_Node_Str",3)) {
      s_logger.debug("String_Node_Str");
      return null;
    }
    List<PhysicalNetworkSetupInfo> networks=_networkMgr.getPhysicalNetworkInfo(dcId,HypervisorType.KVM);
    if (networks.size() < 1) {
      _kvmPublicNic="String_Node_Str";
      _kvmPrivateNic="String_Node_Str";
      _kvmGuestNic="String_Node_Str";
      s_logger.debug("String_Node_Str" + dcId + "String_Node_Str");
    }
 else {
      PhysicalNetworkSetupInfo network=networks.get(0);
      _kvmPublicNic=network.getPublicNetworkName();
      if (_kvmPublicNic == null) {
        _kvmPublicNic="String_Node_Str";
      }
      _kvmPrivateNic=network.getPrivateNetworkName();
      if (_kvmPrivateNic == null) {
        _kvmPrivateNic=_kvmPublicNic;
      }
      _kvmGuestNic=network.getGuestNetworkName();
      if (_kvmGuestNic == null) {
        _kvmGuestNic=_kvmPrivateNic;
      }
    }
    String parameters="String_Node_Str" + _hostIp + "String_Node_Str"+ dcId+ "String_Node_Str"+ podId+ "String_Node_Str"+ clusterId+ "String_Node_Str"+ guid+ "String_Node_Str";
    if (_kvmPublicNic != null) {
      parameters+="String_Node_Str" + _kvmPublicNic;
    }
    if (_kvmPrivateNic != null) {
      parameters+="String_Node_Str" + _kvmPrivateNic;
    }
    if (_kvmGuestNic != null) {
      parameters+="String_Node_Str" + _kvmGuestNic;
    }
    SSHCmdHelper.sshExecuteCmd(sshConnection,"String_Node_Str" + parameters,3);
    KvmDummyResourceBase kvmResource=new KvmDummyResourceBase();
    Map<String,Object> params=new HashMap<String,Object>();
    params.put("String_Node_Str",Long.toString(dcId));
    params.put("String_Node_Str",Long.toString(podId));
    params.put("String_Node_Str",Long.toString(clusterId));
    params.put("String_Node_Str",guid);
    params.put("String_Node_Str",agentIp);
    kvmResource.configure("String_Node_Str",params);
    resources.put(kvmResource,details);
    HostVO connectedHost=waitForHostConnect(dcId,podId,clusterId,guidWithTail);
    if (connectedHost == null)     return null;
    details.put("String_Node_Str",guidWithTail);
    if (cluster.getGuid() == null) {
      cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
      _clusterDao.update(clusterId,cluster);
    }
    return resources;
  }
 catch (  DiscoveredWithErrorException e) {
    throw e;
  }
catch (  Exception e) {
    String msg="String_Node_Str" + e.toString() + "String_Node_Str"+ e.getMessage();
    s_logger.warn(msg);
  }
 finally {
    if (sshConnection != null)     sshConnection.close();
  }
  return null;
}

Fixed version (ground truth):
@Override public Map<? extends ServerResource,Map<String,String>> find(long dcId,Long podId,Long clusterId,URI uri,String username,String password,List<String> hostTags) throws DiscoveryException {
  ClusterVO cluster=_clusterDao.findById(clusterId);
  if (cluster == null || cluster.getHypervisorType() != HypervisorType.KVM) {
    if (s_logger.isInfoEnabled())     s_logger.info("String_Node_Str");
    return null;
  }
  Map<KvmDummyResourceBase,Map<String,String>> resources=new HashMap<KvmDummyResourceBase,Map<String,String>>();
  Map<String,String> details=new HashMap<String,String>();
  if (!uri.getScheme().equals("String_Node_Str")) {
    String msg="String_Node_Str" + uri;
    s_logger.debug(msg);
    return null;
  }
  com.trilead.ssh2.Connection sshConnection=null;
  String agentIp=null;
  try {
    String hostname=uri.getHost();
    InetAddress ia=InetAddress.getByName(hostname);
    agentIp=ia.getHostAddress();
    String guid=UUID.nameUUIDFromBytes(agentIp.getBytes()).toString();
    String guidWithTail=guid + "String_Node_Str";
    if (_resourceMgr.findHostByGuid(guidWithTail) != null) {
      s_logger.debug("String_Node_Str" + agentIp + "String_Node_Str"+ guidWithTail+ "String_Node_Str");
      return null;
    }
    sshConnection=new com.trilead.ssh2.Connection(agentIp,22);
    sshConnection.connect(null,60000,60000);
    if (!sshConnection.authenticateWithPassword(username,password)) {
      s_logger.debug("String_Node_Str");
      throw new DiscoveredWithErrorException("String_Node_Str");
    }
    if (!SSHCmdHelper.sshExecuteCmd(sshConnection,"String_Node_Str",3)) {
      s_logger.debug("String_Node_Str");
      return null;
    }
    List<PhysicalNetworkSetupInfo> networks=_networkMgr.getPhysicalNetworkInfo(dcId,HypervisorType.KVM);
    if (networks.size() < 1) {
      _kvmPublicNic="String_Node_Str";
      _kvmPrivateNic="String_Node_Str";
      _kvmGuestNic="String_Node_Str";
      s_logger.debug("String_Node_Str" + dcId + "String_Node_Str");
    }
 else {
      PhysicalNetworkSetupInfo network=networks.get(0);
      _kvmPublicNic=network.getPublicNetworkName();
      if (_kvmPublicNic == null) {
        _kvmPublicNic="String_Node_Str";
      }
      _kvmPrivateNic=network.getPrivateNetworkName();
      if (_kvmPrivateNic == null) {
        _kvmPrivateNic=_kvmPublicNic;
      }
      _kvmGuestNic=network.getGuestNetworkName();
      if (_kvmGuestNic == null) {
        _kvmGuestNic=_kvmPrivateNic;
      }
    }
    String parameters="String_Node_Str" + _hostIp + "String_Node_Str"+ dcId+ "String_Node_Str"+ podId+ "String_Node_Str"+ clusterId+ "String_Node_Str"+ guid+ "String_Node_Str";
    if (_kvmPublicNic != null) {
      parameters+="String_Node_Str" + _kvmPublicNic;
    }
    if (_kvmPrivateNic != null) {
      parameters+="String_Node_Str" + _kvmPrivateNic;
    }
    if (_kvmGuestNic != null) {
      parameters+="String_Node_Str" + _kvmGuestNic;
    }
    SSHCmdHelper.sshExecuteCmd(sshConnection,"String_Node_Str" + parameters,3);
    KvmDummyResourceBase kvmResource=new KvmDummyResourceBase();
    Map<String,Object> params=new HashMap<String,Object>();
    params.put("String_Node_Str",Long.toString(dcId));
    params.put("String_Node_Str",Long.toString(podId));
    params.put("String_Node_Str",Long.toString(clusterId));
    params.put("String_Node_Str",guid);
    params.put("String_Node_Str",agentIp);
    kvmResource.configure("String_Node_Str",params);
    resources.put(kvmResource,details);
    HostVO connectedHost=waitForHostConnect(dcId,podId,clusterId,guidWithTail);
    if (connectedHost == null)     return null;
    details.put("String_Node_Str",guidWithTail);
    if (cluster.getGuid() == null) {
      cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
      _clusterDao.update(clusterId,cluster);
    }
    _hostDao.loadDetails(connectedHost);
    Map<String,String> hostDetails=connectedHost.getDetails();
    hostDetails.put("String_Node_Str",password);
    hostDetails.put("String_Node_Str",username);
    _hostDao.saveDetails(connectedHost);
    return resources;
  }
 catch (  DiscoveredWithErrorException e) {
    throw e;
  }
catch (  Exception e) {
    String msg="String_Node_Str" + e.toString() + "String_Node_Str"+ e.getMessage();
    s_logger.warn(msg);
  }
 finally {
    if (sshConnection != null)     sshConnection.close();
  }
  return null;
}