Program: 34431
Project: 34431
Buggy source:
private ContainerLaunchContext setupContainerLaunchContext(TaskStatus taskStatus) throws Exception {
  String taskRoleName=taskStatus.getTaskRoleName();
  Integer taskIndex=taskStatus.getTaskIndex();
  Integer serviceVersion=getServiceVersion(taskRoleName);
  UserDescriptor user=requestManager.getUser();
  Boolean generateContainerIpList=requestManager.getPlatParams().getGenerateContainerIpList();
  List<String> sourceLocations=requestManager.getTaskServices().get(taskRoleName).getSourceLocations();
  String entryPoint=requestManager.getTaskServices().get(taskRoleName).getEntryPoint();
  Map<String,Ports> portDefinitions=requestManager.getTaskResources().get(taskRoleName).getPortDefinitions();
  List<ValueRange> portRanges=taskStatus.getContainerPorts();
  Map<String,LocalResource> localResources=new HashMap<>();
  try {
    for (    String location : sourceLocations) {
      HadoopUtils.addToLocalResources(localResources,location);
    }
  }
 catch (  Exception e) {
    handleException(e);
  }
  if (generateContainerIpList) {
    String location=hdfsStore.getHdfsStruct().getContainerIpListFilePath(conf.getFrameworkName());
    HadoopUtils.addToLocalResources(localResources,location);
  }
  Map<String,String> localEnvs=new HashMap<>();
  localEnvs.put(GlobalConstants.ENV_VAR_HADOOP_USER_NAME,user.getName());
  localEnvs.put(GlobalConstants.ENV_VAR_FRAMEWORK_NAME,conf.getFrameworkName());
  localEnvs.put(GlobalConstants.ENV_VAR_FRAMEWORK_VERSION,conf.getFrameworkVersion().toString());
  localEnvs.put(GlobalConstants.ENV_VAR_TASK_ROLE_NAME,taskRoleName);
  localEnvs.put(GlobalConstants.ENV_VAR_TASK_INDEX,taskIndex.toString());
  localEnvs.put(GlobalConstants.ENV_VAR_SERVICE_VERSION,serviceVersion.toString());
  localEnvs.put(GlobalConstants.ENV_VAR_ZK_CONNECT_STRING,conf.getZkConnectString());
  localEnvs.put(GlobalConstants.ENV_VAR_ZK_ROOT_DIR,conf.getZkRootDir());
  localEnvs.put(GlobalConstants.ENV_VAR_ZK_COMPRESSION_ENABLE,conf.getZkCompressionEnable().toString());
  localEnvs.put(GlobalConstants.ENV_VAR_AM_VERSION,conf.getAmVersion().toString());
  localEnvs.put(GlobalConstants.ENV_VAR_APP_ID,conf.getApplicationId());
  localEnvs.put(GlobalConstants.ENV_VAR_ATTEMPT_ID,conf.getAttemptId());
  localEnvs.put(GlobalConstants.ENV_VAR_CONTAINER_GPUS,taskStatus.getContainerGpus().toString());
  String containerPortsString=ValueRangeUtils.toEnviromentVariableString(portRanges,portDefinitions);
  localEnvs.put(GlobalConstants.ENV_VAR_CONTAINER_PORTS,containerPortsString);
  if (generateContainerIpList) {
    localEnvs.put(GlobalConstants.ENV_VAR_CONTAINER_IP,taskStatus.getContainerIp());
  }
  String command=String.format("String_Node_Str",entryPoint,ApplicationConstants.LOG_DIR_EXPANSION_VAR + File.separator);
  ContainerLaunchContext launchContext=Records.newRecord(ContainerLaunchContext.class);
  launchContext.setLocalResources(localResources);
  launchContext.setCommands(Collections.singletonList(command));
  launchContext.setServiceData(new HashMap<>());
  launchContext.setEnvironment(localEnvs);
  return launchContext;
}

Fixed version (ground truth):
private ContainerLaunchContext setupContainerLaunchContext(TaskStatus taskStatus) throws Exception {
  String taskRoleName=taskStatus.getTaskRoleName();
  Integer taskIndex=taskStatus.getTaskIndex();
  Integer serviceVersion=getServiceVersion(taskRoleName);
  UserDescriptor user=requestManager.getUser();
  Boolean generateContainerIpList=requestManager.getPlatParams().getGenerateContainerIpList();
  List<String> sourceLocations=requestManager.getTaskServices().get(taskRoleName).getSourceLocations();
  String entryPoint=requestManager.getTaskServices().get(taskRoleName).getEntryPoint();
  Map<String,Ports> portDefinitions=requestManager.getTaskResources().get(taskRoleName).getPortDefinitions();
  List<ValueRange> portRanges=taskStatus.getContainerPorts();
  Map<String,LocalResource> localResources=new HashMap<>();
  try {
    for (    String location : sourceLocations) {
      HadoopUtils.addToLocalResources(localResources,location);
    }
  }
 catch (  Exception e) {
    handleException(e);
  }
  if (generateContainerIpList) {
    String location=hdfsStore.getHdfsStruct().getContainerIpListFilePath(conf.getFrameworkName());
    HadoopUtils.addToLocalResources(localResources,location);
  }
  Map<String,String> localEnvs=new HashMap<>();
  localEnvs.put(GlobalConstants.ENV_VAR_HADOOP_USER_NAME,user.getName());
  localEnvs.put(GlobalConstants.ENV_VAR_FRAMEWORK_NAME,conf.getFrameworkName());
  localEnvs.put(GlobalConstants.ENV_VAR_FRAMEWORK_VERSION,conf.getFrameworkVersion().toString());
  localEnvs.put(GlobalConstants.ENV_VAR_TASK_ROLE_NAME,taskRoleName);
  localEnvs.put(GlobalConstants.ENV_VAR_TASK_INDEX,taskIndex.toString());
  localEnvs.put(GlobalConstants.ENV_VAR_SERVICE_VERSION,serviceVersion.toString());
  localEnvs.put(GlobalConstants.ENV_VAR_ZK_CONNECT_STRING,conf.getZkConnectString());
  localEnvs.put(GlobalConstants.ENV_VAR_ZK_ROOT_DIR,conf.getZkRootDir());
  localEnvs.put(GlobalConstants.ENV_VAR_ZK_COMPRESSION_ENABLE,conf.getZkCompressionEnable().toString());
  localEnvs.put(GlobalConstants.ENV_VAR_AM_VERSION,conf.getAmVersion().toString());
  localEnvs.put(GlobalConstants.ENV_VAR_APP_ID,conf.getApplicationId());
  localEnvs.put(GlobalConstants.ENV_VAR_ATTEMPT_ID,conf.getAttemptId());
  localEnvs.put(GlobalConstants.ENV_VAR_CONTAINER_GPUS,taskStatus.getContainerGpus().toString());
  String containerPortsString=ValueRangeUtils.toEnviromentVariableString(portRanges,portDefinitions);
  if (portDefinitions != null && !portDefinitions.isEmpty()) {
    if (containerPortsString.split("String_Node_Str").length == portDefinitions.size()) {
      localEnvs.put(GlobalConstants.ENV_VAR_CONTAINER_PORTS,containerPortsString);
    }
 else {
      LOGGER.logError("String_Node_Str" + containerPortsString + "String_Node_Str");
    }
  }
  if (generateContainerIpList) {
    localEnvs.put(GlobalConstants.ENV_VAR_CONTAINER_IP,taskStatus.getContainerIp());
  }
  String command=String.format("String_Node_Str",entryPoint,ApplicationConstants.LOG_DIR_EXPANSION_VAR + File.separator);
  ContainerLaunchContext launchContext=Records.newRecord(ContainerLaunchContext.class);
  launchContext.setLocalResources(localResources);
  launchContext.setCommands(Collections.singletonList(command));
  launchContext.setServiceData(new HashMap<>());
  launchContext.setEnvironment(localEnvs);
  return launchContext;
}