Program: 110774
Project: 110774
Buggy source:
/** 
 * Expand a single policy. If the policy is not about an expansion flag, this will simply return a list with a single element, oneself. If the policy is for an expansion flag, the policy will get split into multiple policies applying to each flag the original flag expands to. <p>None of the flagPolicies returned should be on expansion flags.
 */
private static List<FlagPolicy> expandPolicy(FlagPolicy originalPolicy,OptionsParser parser) throws OptionsParsingException {
  List<FlagPolicy> expandedPolicy=new ArrayList<>();
  OptionDescription desc=parser.getOptionDescription(originalPolicy.getFlagName());
  if (desc == null) {
    return expandedPolicy;
  }
  ImmutableList.Builder<OptionValueDescription> subflagBuilder=new ImmutableList.Builder<>();
  ImmutableList<OptionValueDescription> subflags=subflagBuilder.addAll(desc.getImplicitRequirements()).addAll(desc.getExpansions()).build();
  boolean isExpansion=!desc.getExpansions().isEmpty();
  if (!subflags.isEmpty() && log.isLoggable(Level.FINE)) {
    List<String> subflagNames=new ArrayList<>(subflags.size());
    for (    OptionValueDescription subflag : subflags) {
      subflagNames.add("String_Node_Str" + subflag.getName());
    }
    log.logp(Level.FINE,"String_Node_Str","String_Node_Str",String.format("String_Node_Str",originalPolicy.getOperationCase(),originalPolicy.getFlagName(),isExpansion ? "String_Node_Str" : "String_Node_Str",Joiner.on("String_Node_Str").join(subflagNames)));
  }
  for (  OptionValueDescription currentSubflag : subflags) {
    FlagPolicy subflagAsPolicy=null;
switch (originalPolicy.getOperationCase()) {
case SET_VALUE:
      SetValue setValueExpansion=SetValue.newBuilder().addFlagValue(currentSubflag.getOriginalValueString()).setOverridable(originalPolicy.getSetValue().getOverridable()).build();
    subflagAsPolicy=FlagPolicy.newBuilder().addAllCommands(originalPolicy.getCommandsList()).setFlagName(currentSubflag.getName()).setSetValue(setValueExpansion).build();
  break;
case USE_DEFAULT:
subflagAsPolicy=FlagPolicy.newBuilder().addAllCommands(originalPolicy.getCommandsList()).setFlagName(currentSubflag.getName()).setUseDefault(UseDefault.getDefaultInstance()).build();
break;
case ALLOW_VALUES:
if (isExpansion) {
throw new OptionsParsingException(String.format("String_Node_Str",originalPolicy.getFlagName()));
}
break;
case DISALLOW_VALUES:
if (isExpansion) {
throw new OptionsParsingException(String.format("String_Node_Str",originalPolicy.getFlagName()));
}
break;
case OPERATION_NOT_SET:
throw new PolicyOperationNotSetException(originalPolicy.getFlagName());
default :
expandedPolicy.add(originalPolicy);
return expandedPolicy;
}
expandedPolicy.addAll(expandPolicy(subflagAsPolicy,parser));
}
if (!isExpansion) {
expandedPolicy.add(originalPolicy);
}
return expandedPolicy;
}

Fixed version (ground truth):
/** 
 * Expand a single policy. If the policy is not about an expansion flag, this will simply return a list with a single element, oneself. If the policy is for an expansion flag, the policy will get split into multiple policies applying to each flag the original flag expands to. <p>None of the flagPolicies returned should be on expansion flags.
 */
private static List<FlagPolicy> expandPolicy(FlagPolicy originalPolicy,OptionsParser parser) throws OptionsParsingException {
  List<FlagPolicy> expandedPolicy=new ArrayList<>();
  OptionDescription originalDesc=parser.getOptionDescription(originalPolicy.getFlagName());
  if (originalDesc == null) {
    return expandedPolicy;
  }
  ImmutableList.Builder<OptionValueDescription> subflagBuilder=new ImmutableList.Builder<>();
  ImmutableList<OptionValueDescription> subflags=subflagBuilder.addAll(originalDesc.getImplicitRequirements()).addAll(originalDesc.getExpansions()).build();
  boolean isExpansion=!originalDesc.getExpansions().isEmpty();
  if (!subflags.isEmpty() && log.isLoggable(Level.FINE)) {
    List<String> subflagNames=new ArrayList<>(subflags.size());
    for (    OptionValueDescription subflag : subflags) {
      subflagNames.add("String_Node_Str" + subflag.getName());
    }
    log.logp(Level.FINE,"String_Node_Str","String_Node_Str",String.format("String_Node_Str",originalPolicy.getOperationCase(),originalPolicy.getFlagName(),isExpansion ? "String_Node_Str" : "String_Node_Str",Joiner.on("String_Node_Str").join(subflagNames)));
  }
  Multimap<String,OptionValueDescription> repeatableSubflagsInSetValues=ArrayListMultimap.create();
  for (  OptionValueDescription currentSubflag : subflags) {
    if (currentSubflag.getAllowMultiple() && originalPolicy.getOperationCase().equals(OperationCase.SET_VALUE)) {
      repeatableSubflagsInSetValues.put(currentSubflag.getName(),currentSubflag);
    }
 else {
      FlagPolicy subflagAsPolicy=getSubflagAsPolicy(currentSubflag,originalPolicy,originalDesc);
      expandedPolicy.addAll(expandPolicy(subflagAsPolicy,parser));
    }
  }
  for (  String repeatableFlag : repeatableSubflagsInSetValues.keySet()) {
    int numValues=repeatableSubflagsInSetValues.get(repeatableFlag).size();
    ArrayList<String> newValues=new ArrayList<>(numValues);
    for (    OptionValueDescription setValue : repeatableSubflagsInSetValues.get(repeatableFlag)) {
      newValues.add(setValue.getOriginalValueString());
    }
    expandedPolicy.add(getSetValueSubflagAsPolicy(repeatableFlag,newValues,true,originalPolicy));
  }
  if (!isExpansion) {
    expandedPolicy.add(originalPolicy);
  }
  return expandedPolicy;
}