public static void setEnvFromInputProperty(Map<String, String> env,
      String propName, String defaultPropValue, Configuration conf,
      String classPathSeparator) {

    String envString = conf.get(propName, defaultPropValue);

    // Get k,v pairs from string into a tmp env. Note that we don't want
    // to expand the env var values, because we will do that below -
    // don't want to do it twice.
    Map<String, String> tmpEnv = new HashMap<String, String>();
    Apps.setEnvFromInputStringNoExpand(tmpEnv, envString, classPathSeparator);

    // Get map of props with prefix propName.
    // (e.g., map.reduce.env.ENV_VAR_NAME=value)
    Map<String, String> inputMap = conf.getPropsWithPrefix(propName + ".");

    // Entries from map should override entries from input string.
    tmpEnv.putAll(inputMap);

    // Add them to the environment
    setEnvFromInputStringMap(env, tmpEnv, classPathSeparator);
  }
@Test
  void testSetEnvFromInputProperty() {
    Configuration conf = new Configuration(false);
    Map<String, String> env = new HashMap<>();
    String propName = "mapreduce.map.env";
    String defaultPropName = "mapreduce.child.env";
    // Setup environment input properties
    conf.set(propName, "env1=env1_val,env2=env2_val,env3=env3_val");
    conf.set(propName + ".env4", "env4_val");
    conf.set(propName + ".env2", "new_env2_val");
    // Setup some default values - we shouldn't see these values
    conf.set(defaultPropName, "env1=def1_val,env2=def2_val,env3=def3_val");
    String defaultPropValue = conf.get(defaultPropName);
    // These should never be referenced.
    conf.set(defaultPropName + ".env4", "def4_val");
    conf.set(defaultPropName + ".env2", "new_def2_val");
    Apps.setEnvFromInputProperty(env, propName, defaultPropValue, conf,
        File.pathSeparator);
    // Check values from string
    assertEquals("env1_val", env.get("env1"));
    assertEquals("env3_val", env.get("env3"));
    // Check individual value
    assertEquals("env4_val", env.get("env4"));
    // Check individual value that eclipses one in string
    assertEquals("new_env2_val", env.get("env2"));
  }