Program: 48354
Project: 48354
Buggy source:
@SuppressWarnings("String_Node_Str") private void convertClusterConfig(ClusterEntity clusterEntity,ClusterCreate clusterConfig,boolean needAllocIp){
  logger.debug("String_Node_Str" + clusterEntity.getName());
  clusterConfig.setDistroVendor(clusterEntity.getDistroVendor());
  clusterConfig.setDistroVersion(clusterEntity.getDistroVersion());
  clusterConfig.setAppManager(clusterEntity.getAppManager());
  clusterConfig.setHttpProxy(httpProxy);
  clusterConfig.setNoProxy(noProxy);
  clusterConfig.setTopologyPolicy(clusterEntity.getTopologyPolicy());
  clusterConfig.setPassword(clusterEntity.getPassword());
  clusterConfig.setTemplateName(this.nodeTemplateService.getNodeTemplateNameByMoid(clusterEntity.getTemplateId()));
  Map<String,String> hostToRackMap=rackInfoMgr.exportHostRackMap();
  if ((clusterConfig.getTopologyPolicy() == TopologyType.RACK_AS_RACK || clusterConfig.getTopologyPolicy() == TopologyType.HVE) && hostToRackMap.isEmpty()) {
    logger.error("String_Node_Str");
    throw ClusterConfigException.INVALID_TOPOLOGY_POLICY(clusterConfig.getTopologyPolicy(),"String_Node_Str");
  }
  clusterConfig.setHostToRackMap(hostToRackMap);
  if (clusterEntity.getVcRpNames() != null) {
    logger.debug("String_Node_Str");
    String[] rpNames=clusterEntity.getVcRpNameList().toArray(new String[clusterEntity.getVcRpNameList().size()]);
    List<VcCluster> vcClusters=rpMgr.getVcResourcePoolByNameList(rpNames);
    clusterConfig.setVcClusters(vcClusters);
    clusterConfig.setRpNames(clusterEntity.getVcRpNameList());
  }
 else {
    clusterConfig.setVcClusters(rpMgr.getAllVcResourcePool());
    logger.debug("String_Node_Str");
  }
  if (clusterEntity.getVcDatastoreNameList() != null) {
    logger.debug("String_Node_Str");
    Set<String> sharedPattern=datastoreMgr.getSharedDatastoresByNames(clusterEntity.getVcDatastoreNameList());
    clusterConfig.setSharedDatastorePattern(sharedPattern);
    Set<String> localPattern=datastoreMgr.getLocalDatastoresByNames(clusterEntity.getVcDatastoreNameList());
    clusterConfig.setLocalDatastorePattern(localPattern);
    clusterConfig.setDsNames(clusterEntity.getVcDatastoreNameList());
  }
 else {
    clusterConfig.setSharedDatastorePattern(datastoreMgr.getAllSharedDatastores());
    clusterConfig.setLocalDatastorePattern(datastoreMgr.getAllLocalDatastores());
    logger.debug("String_Node_Str");
  }
  List<NodeGroupCreate> nodeGroups=new ArrayList<NodeGroupCreate>();
  List<NodeGroupEntity> nodeGroupEntities=clusterEntity.getNodeGroups();
  long instanceNum=0;
  for (  NodeGroupEntity ngEntity : nodeGroupEntities) {
    NodeGroupCreate group=convertNodeGroups(clusterEntity,ngEntity,clusterEntity.getName());
    nodeGroups.add(group);
    instanceNum+=group.getInstanceNum();
  }
  clusterConfig.setNodeGroups(nodeGroups.toArray(new NodeGroupCreate[nodeGroups.size()]));
  List<String> networkNames=clusterEntity.fetchNetworkNameList();
  List<NetworkAdd> networkingAdds=allocatNetworkIp(networkNames,clusterEntity,instanceNum,needAllocIp);
  clusterConfig.setNetworkings(networkingAdds);
  clusterConfig.setNetworkConfig(convertNetConfigsToNetNames(clusterEntity.getNetworkConfigInfo()));
  if (clusterEntity.getHadoopConfig() != null) {
    Map<String,Object> hadoopConfig=(new Gson()).fromJson(clusterEntity.getHadoopConfig(),Map.class);
    clusterConfig.setConfiguration(hadoopConfig);
  }
  if (!CommonUtil.isBlank(clusterEntity.getAdvancedProperties())) {
    Gson gson=new Gson();
    Map<String,String> advancedProperties=gson.fromJson(clusterEntity.getAdvancedProperties(),Map.class);
    clusterConfig.setExternalHDFS(advancedProperties.get("String_Node_Str"));
    clusterConfig.setExternalMapReduce(advancedProperties.get("String_Node_Str"));
    clusterConfig.setLocalRepoURL(advancedProperties.get("String_Node_Str"));
    clusterConfig.setClusterCloneType(advancedProperties.get("String_Node_Str"));
    clusterConfig.setExternalNamenode(advancedProperties.get("String_Node_Str"));
    clusterConfig.setExternalSecondaryNamenode(advancedProperties.get("String_Node_Str"));
    if (advancedProperties.get("String_Node_Str") != null) {
      clusterConfig.setExternalDatanodes(gson.fromJson(gson.toJson(advancedProperties.get("String_Node_Str")),HashSet.class));
    }
  }
  setDefaultClusterCloneType(clusterConfig);
  if (!CommonUtil.isBlank(clusterEntity.getInfraConfig())) {
    clusterConfig.setInfrastructure_config(InfrastructureConfigUtils.read(clusterEntity.getInfraConfig()));
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void convertClusterConfig(ClusterEntity clusterEntity,ClusterCreate clusterConfig,boolean needAllocIp){
  logger.debug("String_Node_Str" + clusterEntity.getName());
  clusterConfig.setDistroVendor(clusterEntity.getDistroVendor());
  clusterConfig.setDistroVersion(clusterEntity.getDistroVersion());
  clusterConfig.setAppManager(clusterEntity.getAppManager());
  clusterConfig.setHttpProxy(httpProxy);
  clusterConfig.setNoProxy(noProxy);
  clusterConfig.setTopologyPolicy(clusterEntity.getTopologyPolicy());
  clusterConfig.setPassword(clusterEntity.getPassword());
  clusterConfig.setTemplateName(this.nodeTemplateService.getNodeTemplateNameByMoid(clusterEntity.getTemplateId()));
  Map<String,String> hostToRackMap=rackInfoMgr.exportHostRackMap();
  if ((clusterConfig.getTopologyPolicy() == TopologyType.RACK_AS_RACK || clusterConfig.getTopologyPolicy() == TopologyType.HVE) && hostToRackMap.isEmpty()) {
    logger.error("String_Node_Str");
    throw ClusterConfigException.INVALID_TOPOLOGY_POLICY(clusterConfig.getTopologyPolicy(),"String_Node_Str");
  }
  clusterConfig.setHostToRackMap(hostToRackMap);
  if (clusterEntity.getVcRpNames() != null) {
    logger.debug("String_Node_Str");
    String[] rpNames=clusterEntity.getVcRpNameList().toArray(new String[clusterEntity.getVcRpNameList().size()]);
    List<VcCluster> vcClusters=rpMgr.getVcResourcePoolByNameList(rpNames);
    clusterConfig.setVcClusters(vcClusters);
    clusterConfig.setRpNames(clusterEntity.getVcRpNameList());
  }
 else {
    clusterConfig.setVcClusters(rpMgr.getAllVcResourcePool());
    logger.debug("String_Node_Str");
  }
  if (clusterEntity.getVcDatastoreNameList() != null) {
    logger.debug("String_Node_Str");
    Set<String> sharedPattern=datastoreMgr.getSharedDatastoresByNames(clusterEntity.getVcDatastoreNameList());
    clusterConfig.setSharedDatastorePattern(sharedPattern);
    Set<String> localPattern=datastoreMgr.getLocalDatastoresByNames(clusterEntity.getVcDatastoreNameList());
    clusterConfig.setLocalDatastorePattern(localPattern);
    clusterConfig.setDsNames(clusterEntity.getVcDatastoreNameList());
  }
 else {
    clusterConfig.setSharedDatastorePattern(datastoreMgr.getAllSharedDatastores());
    clusterConfig.setLocalDatastorePattern(datastoreMgr.getAllLocalDatastores());
    logger.debug("String_Node_Str");
  }
  List<NodeGroupCreate> nodeGroups=new ArrayList<NodeGroupCreate>();
  Set<NodeGroupEntity> nodeGroupEntities=clusterEntity.getNodeGroups();
  long instanceNum=0;
  for (  NodeGroupEntity ngEntity : nodeGroupEntities) {
    NodeGroupCreate group=convertNodeGroups(clusterEntity,ngEntity,clusterEntity.getName());
    nodeGroups.add(group);
    instanceNum+=group.getInstanceNum();
  }
  clusterConfig.setNodeGroups(nodeGroups.toArray(new NodeGroupCreate[nodeGroups.size()]));
  List<String> networkNames=clusterEntity.fetchNetworkNameList();
  List<NetworkAdd> networkingAdds=allocatNetworkIp(networkNames,clusterEntity,instanceNum,needAllocIp);
  clusterConfig.setNetworkings(networkingAdds);
  clusterConfig.setNetworkConfig(convertNetConfigsToNetNames(clusterEntity.getNetworkConfigInfo()));
  if (clusterEntity.getHadoopConfig() != null) {
    Map<String,Object> hadoopConfig=(new Gson()).fromJson(clusterEntity.getHadoopConfig(),Map.class);
    clusterConfig.setConfiguration(hadoopConfig);
  }
  if (!CommonUtil.isBlank(clusterEntity.getAdvancedProperties())) {
    Gson gson=new Gson();
    Map<String,String> advancedProperties=gson.fromJson(clusterEntity.getAdvancedProperties(),Map.class);
    clusterConfig.setExternalHDFS(advancedProperties.get("String_Node_Str"));
    clusterConfig.setExternalMapReduce(advancedProperties.get("String_Node_Str"));
    clusterConfig.setLocalRepoURL(advancedProperties.get("String_Node_Str"));
    clusterConfig.setClusterCloneType(advancedProperties.get("String_Node_Str"));
    clusterConfig.setExternalNamenode(advancedProperties.get("String_Node_Str"));
    clusterConfig.setExternalSecondaryNamenode(advancedProperties.get("String_Node_Str"));
    if (advancedProperties.get("String_Node_Str") != null) {
      clusterConfig.setExternalDatanodes(gson.fromJson(gson.toJson(advancedProperties.get("String_Node_Str")),HashSet.class));
    }
  }
  setDefaultClusterCloneType(clusterConfig);
  if (!CommonUtil.isBlank(clusterEntity.getInfraConfig())) {
    clusterConfig.setInfrastructure_config(InfrastructureConfigUtils.read(clusterEntity.getInfraConfig()));
  }
}