Program: 110987
Project: 110987
Buggy source:
/** 
 * Creates a new SkylarkRuleContext using ruleContext.
 * @throws InterruptedException 
 */
public SkylarkRuleContext(RuleContext ruleContext) throws EvalException, InterruptedException {
  this.ruleContext=Preconditions.checkNotNull(ruleContext);
  fragments=new FragmentCollection(ruleContext,ConfigurationTransition.NONE);
  hostFragments=new FragmentCollection(ruleContext,ConfigurationTransition.HOST);
  HashMap<String,Object> outputsBuilder=new HashMap<>();
  if (ruleContext.getRule().getRuleClassObject().outputsDefaultExecutable()) {
    addOutput(outputsBuilder,"String_Node_Str",ruleContext.createOutputArtifact());
  }
  ImplicitOutputsFunction implicitOutputsFunction=ruleContext.getRule().getRuleClassObject().getImplicitOutputsFunction();
  if (implicitOutputsFunction instanceof SkylarkImplicitOutputsFunction) {
    SkylarkImplicitOutputsFunction func=(SkylarkImplicitOutputsFunction)ruleContext.getRule().getRuleClassObject().getImplicitOutputsFunction();
    for (    Map.Entry<String,String> entry : func.calculateOutputs(RawAttributeMapper.of(ruleContext.getRule())).entrySet()) {
      addOutput(outputsBuilder,entry.getKey(),ruleContext.getImplicitOutputArtifact(entry.getValue()));
    }
  }
  ImmutableMap.Builder<Artifact,Label> artifactLabelMapBuilder=ImmutableMap.builder();
  for (  Attribute a : ruleContext.getRule().getAttributes()) {
    String attrName=a.getName();
    Type<?> type=a.getType();
    if (type != BuildType.OUTPUT && type != BuildType.OUTPUT_LIST) {
      continue;
    }
    ImmutableList.Builder<Artifact> artifactsBuilder=ImmutableList.builder();
    for (    OutputFile outputFile : ruleContext.getRule().getOutputFileMap().get(attrName)) {
      Artifact artifact=ruleContext.createOutputArtifact(outputFile);
      artifactsBuilder.add(artifact);
      artifactLabelMapBuilder.put(artifact,outputFile.getLabel());
    }
    ImmutableList<Artifact> artifacts=artifactsBuilder.build();
    if (type == BuildType.OUTPUT) {
      if (artifacts.size() == 1) {
        addOutput(outputsBuilder,attrName,Iterables.getOnlyElement(artifacts));
      }
 else {
        addOutput(outputsBuilder,attrName,Runtime.NONE);
      }
    }
 else     if (type == BuildType.OUTPUT_LIST) {
      addOutput(outputsBuilder,attrName,new MutableList(artifacts));
    }
 else {
      throw new IllegalArgumentException("String_Node_Str" + attrName + "String_Node_Str"+ type+ "String_Node_Str");
    }
  }
  artifactLabelMap=artifactLabelMapBuilder.build();
  outputsObject=new SkylarkClassObject(outputsBuilder,"String_Node_Str");
  ImmutableMap.Builder<String,Object> attrBuilder=new ImmutableMap.Builder<>();
  ImmutableMap.Builder<String,Object> executableBuilder=new ImmutableMap.Builder<>();
  ImmutableMap.Builder<Artifact,FilesToRunProvider> executableRunfilesbuilder=new ImmutableMap.Builder<>();
  ImmutableMap.Builder<String,Object> fileBuilder=new ImmutableMap.Builder<>();
  ImmutableMap.Builder<String,Object> filesBuilder=new ImmutableMap.Builder<>();
  for (  Attribute a : ruleContext.getRule().getAttributes()) {
    Type<?> type=a.getType();
    Object val=ruleContext.attributes().get(a.getName(),type);
    if (type != BuildType.LABEL && type != BuildType.LABEL_LIST) {
      attrBuilder.put(a.getPublicName(),val == null ? Runtime.NONE : SkylarkType.convertToSkylark(val,null));
      continue;
    }
    String skyname=a.getPublicName();
    Mode mode=getMode(a.getName());
    if (a.isExecutable()) {
      FilesToRunProvider provider=ruleContext.getExecutablePrerequisite(a.getName(),mode);
      if (provider != null && provider.getExecutable() != null) {
        Artifact executable=provider.getExecutable();
        executableBuilder.put(skyname,executable);
        executableRunfilesbuilder.put(executable,provider);
      }
 else {
        executableBuilder.put(skyname,Runtime.NONE);
      }
    }
    if (a.isSingleArtifact()) {
      Artifact artifact=ruleContext.getPrerequisiteArtifact(a.getName(),mode);
      if (artifact != null) {
        fileBuilder.put(skyname,artifact);
      }
 else {
        fileBuilder.put(skyname,Runtime.NONE);
      }
    }
    filesBuilder.put(skyname,ruleContext.getPrerequisiteArtifacts(a.getName(),mode).list());
    List<?> allPrereq=ruleContext.getPrerequisites(a.getName(),mode);
    if (type == BuildType.LABEL) {
      Object prereq=ruleContext.getPrerequisite(a.getName(),mode);
      if (prereq == null) {
        prereq=Runtime.NONE;
      }
      attrBuilder.put(skyname,prereq);
    }
 else {
      attrBuilder.put(skyname,new MutableList(allPrereq));
    }
  }
  attrObject=new SkylarkClassObject(attrBuilder.build(),"String_Node_Str");
  executableObject=new SkylarkClassObject(executableBuilder.build(),"String_Node_Str" + "String_Node_Str");
  fileObject=new SkylarkClassObject(fileBuilder.build(),"String_Node_Str" + "String_Node_Str");
  filesObject=new SkylarkClassObject(filesBuilder.build(),"String_Node_Str" + "String_Node_Str");
  executableRunfilesMap=executableRunfilesbuilder.build();
  makeVariables=ruleContext.getConfigurationMakeVariableContext().collectMakeVariables();
}

Fixed version (ground truth):
/** 
 * Creates a new SkylarkRuleContext using ruleContext.
 * @throws InterruptedException 
 */
public SkylarkRuleContext(RuleContext ruleContext) throws EvalException, InterruptedException {
  this.ruleContext=Preconditions.checkNotNull(ruleContext);
  fragments=new FragmentCollection(ruleContext,ConfigurationTransition.NONE);
  hostFragments=new FragmentCollection(ruleContext,ConfigurationTransition.HOST);
  HashMap<String,Object> outputsBuilder=new HashMap<>();
  if (ruleContext.getRule().getRuleClassObject().outputsDefaultExecutable()) {
    addOutput(outputsBuilder,"String_Node_Str",ruleContext.createOutputArtifact());
  }
  ImplicitOutputsFunction implicitOutputsFunction=ruleContext.getRule().getRuleClassObject().getImplicitOutputsFunction();
  if (implicitOutputsFunction instanceof SkylarkImplicitOutputsFunction) {
    SkylarkImplicitOutputsFunction func=(SkylarkImplicitOutputsFunction)ruleContext.getRule().getRuleClassObject().getImplicitOutputsFunction();
    for (    Map.Entry<String,String> entry : func.calculateOutputs(RawAttributeMapper.of(ruleContext.getRule())).entrySet()) {
      addOutput(outputsBuilder,entry.getKey(),ruleContext.getImplicitOutputArtifact(entry.getValue()));
    }
  }
  ImmutableMap.Builder<Artifact,Label> artifactLabelMapBuilder=ImmutableMap.builder();
  for (  Attribute a : ruleContext.getRule().getAttributes()) {
    String attrName=a.getName();
    Type<?> type=a.getType();
    if (type != BuildType.OUTPUT && type != BuildType.OUTPUT_LIST) {
      continue;
    }
    ImmutableList.Builder<Artifact> artifactsBuilder=ImmutableList.builder();
    for (    OutputFile outputFile : ruleContext.getRule().getOutputFileMap().get(attrName)) {
      Artifact artifact=ruleContext.createOutputArtifact(outputFile);
      artifactsBuilder.add(artifact);
      artifactLabelMapBuilder.put(artifact,outputFile.getLabel());
    }
    ImmutableList<Artifact> artifacts=artifactsBuilder.build();
    if (type == BuildType.OUTPUT) {
      if (artifacts.size() == 1) {
        addOutput(outputsBuilder,attrName,Iterables.getOnlyElement(artifacts));
      }
 else {
        addOutput(outputsBuilder,attrName,Runtime.NONE);
      }
    }
 else     if (type == BuildType.OUTPUT_LIST) {
      addOutput(outputsBuilder,attrName,new MutableList(artifacts));
    }
 else {
      throw new IllegalArgumentException("String_Node_Str" + attrName + "String_Node_Str"+ type+ "String_Node_Str");
    }
  }
  artifactLabelMap=artifactLabelMapBuilder.build();
  outputsObject=new SkylarkClassObject(outputsBuilder,"String_Node_Str");
  ImmutableMap.Builder<String,Object> attrBuilder=new ImmutableMap.Builder<>();
  ImmutableMap.Builder<String,Object> executableBuilder=new ImmutableMap.Builder<>();
  ImmutableMap.Builder<Artifact,FilesToRunProvider> executableRunfilesbuilder=new ImmutableMap.Builder<>();
  ImmutableMap.Builder<String,Object> fileBuilder=new ImmutableMap.Builder<>();
  ImmutableMap.Builder<String,Object> filesBuilder=new ImmutableMap.Builder<>();
  for (  Attribute a : ruleContext.getRule().getAttributes()) {
    Type<?> type=a.getType();
    Object val=ruleContext.attributes().get(a.getName(),type);
    if (type != BuildType.LABEL && type != BuildType.LABEL_LIST) {
      attrBuilder.put(a.getPublicName(),val == null ? Runtime.NONE : SkylarkType.convertToSkylark(val,null));
      continue;
    }
    String skyname=a.getPublicName();
    if (a.isExecutable()) {
      FilesToRunProvider provider=ruleContext.getExecutablePrerequisite(a.getName(),Mode.DONT_CHECK);
      if (provider != null && provider.getExecutable() != null) {
        Artifact executable=provider.getExecutable();
        executableBuilder.put(skyname,executable);
        executableRunfilesbuilder.put(executable,provider);
      }
 else {
        executableBuilder.put(skyname,Runtime.NONE);
      }
    }
    if (a.isSingleArtifact()) {
      Artifact artifact=ruleContext.getPrerequisiteArtifact(a.getName(),Mode.DONT_CHECK);
      if (artifact != null) {
        fileBuilder.put(skyname,artifact);
      }
 else {
        fileBuilder.put(skyname,Runtime.NONE);
      }
    }
    filesBuilder.put(skyname,ruleContext.getPrerequisiteArtifacts(a.getName(),Mode.DONT_CHECK).list());
    List<?> allPrereq=ruleContext.getPrerequisites(a.getName(),Mode.DONT_CHECK);
    if (type == BuildType.LABEL) {
      Object prereq=ruleContext.getPrerequisite(a.getName(),Mode.DONT_CHECK);
      if (prereq == null) {
        prereq=Runtime.NONE;
      }
      attrBuilder.put(skyname,prereq);
    }
 else {
      attrBuilder.put(skyname,new MutableList(allPrereq));
    }
  }
  attrObject=new SkylarkClassObject(attrBuilder.build(),"String_Node_Str");
  executableObject=new SkylarkClassObject(executableBuilder.build(),"String_Node_Str" + "String_Node_Str");
  fileObject=new SkylarkClassObject(fileBuilder.build(),"String_Node_Str" + "String_Node_Str");
  filesObject=new SkylarkClassObject(filesBuilder.build(),"String_Node_Str" + "String_Node_Str");
  executableRunfilesMap=executableRunfilesbuilder.build();
  makeVariables=ruleContext.getConfigurationMakeVariableContext().collectMakeVariables();
}