Program: 4580
Project: 4580
Buggy source:
/** 
 * Updates the given   {@link ProgramOptions} and return a new instance.It copies the  {@link ProgramOptions}. Then it adds all entries returned by   {@link #getExtraProgramOptions()}followed by adding the   {@link RunId} to the system arguments.Also scope resolution will be performed on the user arguments on the application and program.
 * @param programId the program id
 * @param options The {@link ProgramOptions} in which the RunId to be included
 * @param runId   The RunId to be included
 * @return the copy of the program options with RunId included in them
 */
private ProgramOptions updateProgramOptions(ArtifactId artifactId,ProgramId programId,ProgramOptions options,RunId runId){
  ImmutableMap.Builder<String,String> builder=ImmutableMap.builder();
  builder.putAll(options.getArguments().asMap());
  builder.putAll(getExtraProgramOptions());
  builder.put(ProgramOptionConstants.RUN_ID,runId.getId());
  builder.put(ProgramOptionConstants.ARTIFACT_ID,Joiner.on(':').join(artifactId.toIdParts()));
  String clusterName=options.getArguments().getOption(Constants.CLUSTER_NAME);
  Map<String,String> userArguments=options.getUserArguments().asMap();
  if (!Strings.isNullOrEmpty(clusterName)) {
    userArguments=RuntimeArguments.extractScope(CLUSTER_SCOPE,clusterName,userArguments);
  }
  userArguments=RuntimeArguments.extractScope(APPLICATION_SCOPE,programId.getApplication(),userArguments);
  userArguments=RuntimeArguments.extractScope(programId.getType().getScope(),programId.getProgram(),userArguments);
  return new SimpleProgramOptions(options.getProgramId(),new BasicArguments(builder.build()),new BasicArguments(userArguments),options.isDebug());
}

Fixed version (ground truth):
/** 
 * Updates the given   {@link ProgramOptions} and return a new instance.It copies the  {@link ProgramOptions}. Then it adds all entries returned by   {@link #getExtraProgramOptions()}followed by adding the   {@link RunId} to the system arguments.Also scope resolution will be performed on the user arguments on the application and program.
 * @param programId the program id
 * @param options The {@link ProgramOptions} in which the RunId to be included
 * @param runId   The RunId to be included
 * @return the copy of the program options with RunId included in them
 */
private ProgramOptions updateProgramOptions(ArtifactId artifactId,ProgramId programId,ProgramOptions options,RunId runId){
  Map<String,String> systemArguments=new HashMap<>();
  systemArguments.putAll(options.getArguments().asMap());
  for (  Map.Entry<String,String> extraOption : getExtraProgramOptions().entrySet()) {
    systemArguments.putIfAbsent(extraOption.getKey(),extraOption.getValue());
  }
  systemArguments.putIfAbsent(ProgramOptionConstants.RUN_ID,runId.getId());
  systemArguments.putIfAbsent(ProgramOptionConstants.ARTIFACT_ID,Joiner.on(':').join(artifactId.toIdParts()));
  String clusterName=options.getArguments().getOption(Constants.CLUSTER_NAME);
  Map<String,String> userArguments=options.getUserArguments().asMap();
  if (!Strings.isNullOrEmpty(clusterName)) {
    userArguments=RuntimeArguments.extractScope(CLUSTER_SCOPE,clusterName,userArguments);
  }
  userArguments=RuntimeArguments.extractScope(APPLICATION_SCOPE,programId.getApplication(),userArguments);
  userArguments=RuntimeArguments.extractScope(programId.getType().getScope(),programId.getProgram(),userArguments);
  return new SimpleProgramOptions(options.getProgramId(),new BasicArguments(systemArguments),new BasicArguments(userArguments),options.isDebug());
}