private void trimPropertyValue(Configuration clusterConfig, Stack stack, String configType, Map<String, String> properties, String propertyName) {
    if (propertyName != null && properties.get(propertyName) != null) {

      TrimmingStrategy trimmingStrategy =
        PropertyValueTrimmingStrategyDefiner.defineTrimmingStrategy(stack, propertyName, configType);
      String oldValue = properties.get(propertyName);
      String newValue = trimmingStrategy.trim(oldValue);

      if (!newValue.equals(oldValue)){
        LOG.debug("Changing value for config {} property {} from [{}] to [{}]", configType, propertyName, oldValue, newValue);
        clusterConfig.setProperty(configType, propertyName, newValue);
      }
    }
  }
Encapsulates commonly repeated tasks around updating a configuration value during cluster creation.
@param configType the configuration type (e.g. hdfs-site)
@param propertyName the name of the property (e.g. dfs.namenode.name.dir)
@param oldValue the old value of the property
@param updater the property updater to use
@param allProps other properties to be considered by the updater
@param configuration configuration to update (cluster global config or hostgroup config)
@param configTypesUpdated set of updated config types (configType param will be added if updater changes the
                          value of the property)
@param alwaysUpdateConfig boolean to indicate whether the {@link Configuration} received as parameter should always
                          (except when new value is {@code null}) be updated or only in case the new value differs
                          from the original. (TODO: what is the reason for always updating the configuration?)
@return the updated value
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java