Program: 48396
Project: 48396
Buggy source:
private void updateConfigGroup(ApiConfigGroupInfo apiConfigGroupInfo,String clusterName,ApiHostGroup apiHostGroupFromClusterSpec){
  try {
    boolean needUpdate=false;
    ApiConfigGroup newApiConfigGroup=new ApiConfigGroup();
    ApiConfigGroupInfo newApiConfigGroupInfo=new ApiConfigGroupInfo();
    newApiConfigGroupInfo.setId(apiConfigGroupInfo.getId());
    newApiConfigGroupInfo.setClusterName(apiConfigGroupInfo.getClusterName());
    newApiConfigGroupInfo.setGroupName(apiConfigGroupInfo.getGroupName());
    newApiConfigGroupInfo.setTag(apiConfigGroupInfo.getTag());
    newApiConfigGroupInfo.setDescription(apiConfigGroupInfo.getDescription());
    List<ApiHostInfo> hosts=new ArrayList<ApiHostInfo>();
    for (    ApiHostInfo apiHostInfo : apiConfigGroupInfo.getHosts()) {
      ApiHostInfo newApiHostInfo=new ApiHostInfo();
      newApiHostInfo.setHostName(apiHostInfo.getHostName());
      hosts.add(newApiHostInfo);
    }
    newApiConfigGroupInfo.setHosts(hosts);
    List<ApiConfigGroupConfiguration> desiredConfigs=new ArrayList<ApiConfigGroupConfiguration>();
    logger.info("String_Node_Str" + ApiUtils.objectToJson(apiConfigGroupInfo.getDesiredConfigs()));
    logger.info("String_Node_Str" + ApiUtils.objectToJson(apiHostGroupFromClusterSpec));
    String tag="String_Node_Str" + Calendar.getInstance().getTimeInMillis();
    for (    ApiConfigGroupConfiguration apiConfigGroupConfiguration : apiConfigGroupInfo.getDesiredConfigs()) {
      ApiConfigGroupConfiguration desiredConfig=new ApiConfigGroupConfiguration();
      desiredConfig.setType(apiConfigGroupConfiguration.getType());
      desiredConfig.setTag(tag);
      Map<String,String> properties=new HashMap<String,String>();
      ApiClusterConfigurations apiClusterConfigurations=apiManager.getClusterConfigurationsWithTypeAndTag(clusterName,apiConfigGroupConfiguration.getType(),apiConfigGroupConfiguration.getTag());
      logger.info("String_Node_Str" + ApiUtils.objectToJson(apiClusterConfigurations));
      for (      ApiClusterConfigurationInfo apiClusterConfigurationInfo : apiClusterConfigurations.getConfigurations()) {
        Map<String,String> propertiesFromClusterSpec=new HashMap<String,String>();
        for (        Map<String,Object> configurationFromClusterSpec : apiHostGroupFromClusterSpec.getConfigurations()) {
          propertiesFromClusterSpec=(Map<String,String>)configurationFromClusterSpec.get(apiClusterConfigurationInfo.getType());
          if (propertiesFromClusterSpec != null) {
            break;
          }
        }
        logger.info("String_Node_Str" + ApiUtils.objectToJson(propertiesFromClusterSpec));
        if (propertiesFromClusterSpec.isEmpty()) {
          continue;
        }
        Map<String,String> propertiesFromAmbariServer=apiClusterConfigurationInfo.getProperties();
        for (        String propertyKey : propertiesFromAmbariServer.keySet()) {
          String valueOfPropertyFromClusterSpec=propertiesFromClusterSpec.get(propertyKey);
          String valueOfPropertyFromAmbariServer=propertiesFromAmbariServer.get(propertyKey);
          logger.info("String_Node_Str" + valueOfPropertyFromClusterSpec);
          logger.info("String_Node_Str" + valueOfPropertyFromAmbariServer);
          if (valueOfPropertyFromClusterSpec == null) {
            continue;
          }
          if (valueOfPropertyFromClusterSpec.contains("String_Node_Str")) {
            properties.put(propertyKey,valueOfPropertyFromClusterSpec);
            needUpdate=true;
          }
 else {
            properties.put(propertyKey,valueOfPropertyFromAmbariServer);
          }
        }
      }
      desiredConfig.setProperties(properties);
      desiredConfigs.add(desiredConfig);
    }
    newApiConfigGroupInfo.setDesiredConfigs(desiredConfigs);
    newApiConfigGroup.setApiConfigGroupInfo(newApiConfigGroupInfo);
    logger.info("String_Node_Str" + ApiUtils.objectToJson(newApiConfigGroup));
    if (needUpdate) {
      apiManager.updateConfigGroup(clusterName,apiConfigGroupInfo.getId(),newApiConfigGroup);
    }
  }
 catch (  Exception e) {
    String errMsg="String_Node_Str" + apiConfigGroupInfo.getId() + ((e.getMessage() == null) ? "String_Node_Str" : ("String_Node_Str" + e.getMessage()));
    logger.error(errMsg);
    throw SoftwareManagementPluginException.CONFIGURE_SERVICE_FAILED(e);
  }
}

Fixed version (ground truth):
private void updateConfigGroup(ApiConfigGroupInfo apiConfigGroupInfo,String clusterName,ApiHostGroup apiHostGroupFromClusterSpec){
  try {
    boolean needUpdate=false;
    ApiConfigGroup newApiConfigGroup=new ApiConfigGroup();
    ApiConfigGroupInfo newApiConfigGroupInfo=new ApiConfigGroupInfo();
    newApiConfigGroupInfo.setId(apiConfigGroupInfo.getId());
    newApiConfigGroupInfo.setClusterName(apiConfigGroupInfo.getClusterName());
    newApiConfigGroupInfo.setGroupName(apiConfigGroupInfo.getGroupName());
    newApiConfigGroupInfo.setTag(apiConfigGroupInfo.getTag());
    newApiConfigGroupInfo.setDescription(apiConfigGroupInfo.getDescription());
    List<ApiHostInfo> hosts=new ArrayList<ApiHostInfo>();
    for (    ApiHostInfo apiHostInfo : apiConfigGroupInfo.getHosts()) {
      ApiHostInfo newApiHostInfo=new ApiHostInfo();
      newApiHostInfo.setHostName(apiHostInfo.getHostName());
      hosts.add(newApiHostInfo);
    }
    newApiConfigGroupInfo.setHosts(hosts);
    List<ApiConfigGroupConfiguration> desiredConfigs=new ArrayList<ApiConfigGroupConfiguration>();
    logger.info("String_Node_Str" + ApiUtils.objectToJson(apiConfigGroupInfo.getDesiredConfigs()));
    logger.info("String_Node_Str" + ApiUtils.objectToJson(apiHostGroupFromClusterSpec));
    String tag="String_Node_Str" + Calendar.getInstance().getTimeInMillis();
    for (    ApiConfigGroupConfiguration apiConfigGroupConfiguration : apiConfigGroupInfo.getDesiredConfigs()) {
      ApiConfigGroupConfiguration desiredConfig=new ApiConfigGroupConfiguration();
      desiredConfig.setType(apiConfigGroupConfiguration.getType());
      desiredConfig.setTag(tag);
      Map<String,String> properties=new HashMap<String,String>();
      ApiClusterConfigurations apiClusterConfigurations=apiManager.getClusterConfigurationsWithTypeAndTag(clusterName,apiConfigGroupConfiguration.getType(),apiConfigGroupConfiguration.getTag());
      logger.info("String_Node_Str" + ApiUtils.objectToJson(apiClusterConfigurations));
      for (      ApiClusterConfigurationInfo apiClusterConfigurationInfo : apiClusterConfigurations.getConfigurations()) {
        Map<String,String> propertiesFromClusterSpec=new HashMap<String,String>();
        for (        Map<String,Object> configurationFromClusterSpec : apiHostGroupFromClusterSpec.getConfigurations()) {
          propertiesFromClusterSpec=(Map<String,String>)configurationFromClusterSpec.get(apiClusterConfigurationInfo.getType());
          if (propertiesFromClusterSpec != null) {
            break;
          }
        }
        logger.info("String_Node_Str" + ApiUtils.objectToJson(propertiesFromClusterSpec));
        Map<String,String> propertiesFromAmbariServer=apiClusterConfigurationInfo.getProperties();
        for (        String propertyKey : propertiesFromAmbariServer.keySet()) {
          String valueOfPropertyFromClusterSpec=null;
          if (propertiesFromClusterSpec != null) {
            valueOfPropertyFromClusterSpec=propertiesFromClusterSpec.get(propertyKey);
          }
          String valueOfPropertyFromAmbariServer=propertiesFromAmbariServer.get(propertyKey);
          logger.info("String_Node_Str" + valueOfPropertyFromClusterSpec);
          logger.info("String_Node_Str" + valueOfPropertyFromAmbariServer);
          if (valueOfPropertyFromClusterSpec != null && valueOfPropertyFromClusterSpec.contains("String_Node_Str")) {
            properties.put(propertyKey,valueOfPropertyFromClusterSpec);
            needUpdate=true;
          }
 else {
            properties.put(propertyKey,valueOfPropertyFromAmbariServer);
          }
        }
      }
      desiredConfig.setProperties(properties);
      desiredConfigs.add(desiredConfig);
    }
    newApiConfigGroupInfo.setDesiredConfigs(desiredConfigs);
    newApiConfigGroup.setApiConfigGroupInfo(newApiConfigGroupInfo);
    logger.info("String_Node_Str" + ApiUtils.objectToJson(newApiConfigGroup));
    if (needUpdate) {
      apiManager.updateConfigGroup(clusterName,apiConfigGroupInfo.getId(),newApiConfigGroup);
    }
  }
 catch (  Exception e) {
    String errMsg="String_Node_Str" + apiConfigGroupInfo.getId() + ((e.getMessage() == null) ? "String_Node_Str" : ("String_Node_Str" + e.getMessage()));
    logger.error(errMsg);
    throw SoftwareManagementPluginException.CONFIGURE_SERVICE_FAILED(e);
  }
}