@Test public void testHandleServiceEnvWithEmptyMap() { Service service = createServiceWithEmptyEnvVars(); org.apache.hadoop.conf.Configuration yarnConfig = mock(org.apache.hadoop.conf.Configuration.class); EnvironmentUtilities.handleServiceEnvs(service, yarnConfig, null); Map<String, String> resultEnvs = service.getConfiguration().getEnv(); assertEquals(1, resultEnvs.size()); validateDefaultEnvVars(resultEnvs); }
public static void handleServiceEnvs(Service service, Configuration yarnConfig, List<String> envVars) { if (envVars != null) { for (String envVarPair : envVars) { String key, value; if (envVarPair.contains(ENV_SEPARATOR)) { int idx = envVarPair.indexOf(ENV_SEPARATOR); key = envVarPair.substring(0, idx); value = envVarPair.substring(idx + 1); } else { LOG.warn("Found environment variable with unusual format: '{}'", envVarPair); key = envVarPair; value = ""; } appendToEnv(service, key, value, ENV_VAR_DELIM); } } appendOtherConfigs(service, yarnConfig); }
EnvironmentUtilities { public static void handleServiceEnvs(Service service, Configuration yarnConfig, List<String> envVars) { if (envVars != null) { for (String envVarPair : envVars) { String key, value; if (envVarPair.contains(ENV_SEPARATOR)) { int idx = envVarPair.indexOf(ENV_SEPARATOR); key = envVarPair.substring(0, idx); value = envVarPair.substring(idx + 1); } else { LOG.warn("Found environment variable with unusual format: '{}'", envVarPair); key = envVarPair; value = ""; } appendToEnv(service, key, value, ENV_VAR_DELIM); } } appendOtherConfigs(service, yarnConfig); } }
EnvironmentUtilities { public static void handleServiceEnvs(Service service, Configuration yarnConfig, List<String> envVars) { if (envVars != null) { for (String envVarPair : envVars) { String key, value; if (envVarPair.contains(ENV_SEPARATOR)) { int idx = envVarPair.indexOf(ENV_SEPARATOR); key = envVarPair.substring(0, idx); value = envVarPair.substring(idx + 1); } else { LOG.warn("Found environment variable with unusual format: '{}'", envVarPair); key = envVarPair; value = ""; } appendToEnv(service, key, value, ENV_VAR_DELIM); } } appendOtherConfigs(service, yarnConfig); } private  EnvironmentUtilities(); }
EnvironmentUtilities { public static void handleServiceEnvs(Service service, Configuration yarnConfig, List<String> envVars) { if (envVars != null) { for (String envVarPair : envVars) { String key, value; if (envVarPair.contains(ENV_SEPARATOR)) { int idx = envVarPair.indexOf(ENV_SEPARATOR); key = envVarPair.substring(0, idx); value = envVarPair.substring(idx + 1); } else { LOG.warn("Found environment variable with unusual format: '{}'", envVarPair); key = envVarPair; value = ""; } appendToEnv(service, key, value, ENV_VAR_DELIM); } } appendOtherConfigs(service, yarnConfig); } private  EnvironmentUtilities(); static String getValueOfEnvironment(String envVar); static void handleServiceEnvs(Service service,
      Configuration yarnConfig, List<String> envVars); }
EnvironmentUtilities { public static void handleServiceEnvs(Service service, Configuration yarnConfig, List<String> envVars) { if (envVars != null) { for (String envVarPair : envVars) { String key, value; if (envVarPair.contains(ENV_SEPARATOR)) { int idx = envVarPair.indexOf(ENV_SEPARATOR); key = envVarPair.substring(0, idx); value = envVarPair.substring(idx + 1); } else { LOG.warn("Found environment variable with unusual format: '{}'", envVarPair); key = envVarPair; value = ""; } appendToEnv(service, key, value, ENV_VAR_DELIM); } } appendOtherConfigs(service, yarnConfig); } private  EnvironmentUtilities(); static String getValueOfEnvironment(String envVar); static void handleServiceEnvs(Service service,
      Configuration yarnConfig, List<String> envVars);  }