Program: 105945
Project: 105945
Buggy source:
@Override public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext,long dcId,Long podId,Long clusterId,String hostInventoryPath) throws Exception {
  ManagedObjectReference mor=null;
  if (serviceContext != null) {
    mor=serviceContext.getHostMorByPath(hostInventoryPath);
  }
  String privateTrafficLabel=null;
  privateTrafficLabel=serviceContext.getStockObject("String_Node_Str");
  if (privateTrafficLabel == null) {
    privateTrafficLabel=_privateNetworkVSwitchName;
  }
  if (mor != null) {
    List<ManagedObjectReference> returnedHostList=new ArrayList<ManagedObjectReference>();
    if (mor.getType().equals("String_Node_Str")) {
      List<ManagedObjectReference> hosts=serviceContext.getVimClient().getDynamicProperty(mor,"String_Node_Str");
      assert(hosts != null && hosts.size() > 0);
      HostMO hostMo=new HostMO(serviceContext,hosts.get(0));
      prepareHost(hostMo,privateTrafficLabel);
      returnedHostList.add(hosts.get(0));
      return returnedHostList;
    }
 else     if (mor.getType().equals("String_Node_Str")) {
      List<ManagedObjectReference> hosts=serviceContext.getVimClient().getDynamicProperty(mor,"String_Node_Str");
      assert(hosts != null);
      if (hosts.size() > 0) {
        AboutInfo about=(AboutInfo)(serviceContext.getVimClient().getDynamicProperty(hosts.get(0),"String_Node_Str"));
        String version=about.getApiVersion();
        int maxHostsPerCluster=_hvCapabilitiesDao.getMaxHostsPerCluster(HypervisorType.VMware,version);
        if (hosts.size() > maxHostsPerCluster) {
          String msg="String_Node_Str" + hosts.size() + "String_Node_Str"+ maxHostsPerCluster;
          s_logger.error(msg);
          throw new DiscoveredWithErrorException(msg);
        }
      }
      for (      ManagedObjectReference morHost : hosts) {
        HostMO hostMo=new HostMO(serviceContext,morHost);
        prepareHost(hostMo,privateTrafficLabel);
        returnedHostList.add(morHost);
      }
      return returnedHostList;
    }
 else     if (mor.getType().equals("String_Node_Str")) {
      HostMO hostMo=new HostMO(serviceContext,mor);
      prepareHost(hostMo,privateTrafficLabel);
      returnedHostList.add(mor);
      return returnedHostList;
    }
 else {
      s_logger.error("String_Node_Str" + mor.getType() + "String_Node_Str"+ mor.getValue()+ "String_Node_Str"+ hostInventoryPath);
      return null;
    }
  }
  s_logger.error("String_Node_Str" + hostInventoryPath);
  return null;
}

Fixed version (ground truth):
@Override public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext,long dcId,Long podId,Long clusterId,String hostInventoryPath) throws Exception {
  if (serviceContext == null) {
    throw new CloudRuntimeException("String_Node_Str");
  }
  ManagedObjectReference mor=serviceContext.getHostMorByPath(hostInventoryPath);
  String privateTrafficLabel=null;
  privateTrafficLabel=serviceContext.getStockObject("String_Node_Str");
  if (privateTrafficLabel == null) {
    privateTrafficLabel=_privateNetworkVSwitchName;
  }
  if (mor != null) {
    List<ManagedObjectReference> returnedHostList=new ArrayList<ManagedObjectReference>();
    if (mor.getType().equals("String_Node_Str")) {
      List<ManagedObjectReference> hosts=serviceContext.getVimClient().getDynamicProperty(mor,"String_Node_Str");
      assert(hosts != null && hosts.size() > 0);
      HostMO hostMo=new HostMO(serviceContext,hosts.get(0));
      prepareHost(hostMo,privateTrafficLabel);
      returnedHostList.add(hosts.get(0));
      return returnedHostList;
    }
 else     if (mor.getType().equals("String_Node_Str")) {
      List<ManagedObjectReference> hosts=serviceContext.getVimClient().getDynamicProperty(mor,"String_Node_Str");
      assert(hosts != null);
      if (hosts.size() > 0) {
        AboutInfo about=(AboutInfo)(serviceContext.getVimClient().getDynamicProperty(hosts.get(0),"String_Node_Str"));
        String version=about.getApiVersion();
        int maxHostsPerCluster=_hvCapabilitiesDao.getMaxHostsPerCluster(HypervisorType.VMware,version);
        if (hosts.size() > maxHostsPerCluster) {
          String msg="String_Node_Str" + hosts.size() + "String_Node_Str"+ maxHostsPerCluster;
          s_logger.error(msg);
          throw new DiscoveredWithErrorException(msg);
        }
      }
      for (      ManagedObjectReference morHost : hosts) {
        HostMO hostMo=new HostMO(serviceContext,morHost);
        prepareHost(hostMo,privateTrafficLabel);
        returnedHostList.add(morHost);
      }
      return returnedHostList;
    }
 else     if (mor.getType().equals("String_Node_Str")) {
      HostMO hostMo=new HostMO(serviceContext,mor);
      prepareHost(hostMo,privateTrafficLabel);
      returnedHostList.add(mor);
      return returnedHostList;
    }
 else {
      s_logger.error("String_Node_Str" + mor.getType() + "String_Node_Str"+ mor.getValue()+ "String_Node_Str"+ hostInventoryPath);
      return null;
    }
  }
  s_logger.error("String_Node_Str" + hostInventoryPath);
  return null;
}