Program: 110650
Project: 110650
Buggy source:
private static Artifact createShuffleJarActions(RuleContext ruleContext,boolean makeDexArchives,@Nullable Artifact proguardedJar,ImmutableList<Artifact> shards,AndroidCommon common,@Nullable Artifact inclusionFilterJar,List<String> dexopts,AndroidSemantics semantics,JavaTargetAttributes attributes,Function<Artifact,Artifact> derivedJarFunction,@Nullable Artifact mainDexList) throws InterruptedException, RuleErrorException {
  checkArgument(!shards.isEmpty());
  checkArgument(mainDexList == null || shards.size() > 1);
  checkArgument(proguardedJar == null || inclusionFilterJar == null);
  Artifact javaResourceJar=ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.JAVA_RESOURCES_JAR);
  ImmutableList<Artifact> shuffleOutputs;
  if (makeDexArchives && proguardedJar != null) {
    checkArgument(shards.size() > 1);
    shuffleOutputs=makeShardArtifacts(ruleContext,shards.size(),"String_Node_Str");
  }
 else {
    shuffleOutputs=shards;
  }
  SpawnAction.Builder shardAction=new SpawnAction.Builder().useDefaultShellEnvironment().setMnemonic("String_Node_Str").setProgressMessage("String_Node_Str",ruleContext.getLabel()).setExecutable(ruleContext.getExecutablePrerequisite("String_Node_Str",Mode.HOST)).addOutputs(shuffleOutputs).addOutput(javaResourceJar);
  CustomCommandLine.Builder shardCommandLine=CustomCommandLine.builder().addExecPaths(VectorArg.addBefore("String_Node_Str").each(shuffleOutputs)).addExecPath("String_Node_Str",javaResourceJar);
  if (mainDexList != null) {
    shardCommandLine.addExecPath("String_Node_Str",mainDexList);
    shardAction.addInput(mainDexList);
  }
  if (proguardedJar != null) {
    shardCommandLine.addExecPath("String_Node_Str",proguardedJar);
    shardAction.addInput(proguardedJar);
  }
 else {
    ImmutableList<Artifact> classpath=collectRuntimeJars(common,attributes);
    if (makeDexArchives) {
      Map<Artifact,Artifact> dexArchives=collectDexArchives(ruleContext,common,dexopts,semantics,derivedJarFunction);
      classpath=toDexedClasspath(ruleContext,classpath,dexArchives);
      shardCommandLine.add("String_Node_Str");
    }
 else {
      classpath=classpath.stream().map(derivedJarFunction).collect(toImmutableList());
    }
    shardCommandLine.addExecPaths(VectorArg.addBefore("String_Node_Str").each(classpath));
    shardAction.addInputs(classpath);
    if (inclusionFilterJar != null) {
      shardCommandLine.addExecPath("String_Node_Str",inclusionFilterJar);
      shardAction.addInput(inclusionFilterJar);
    }
  }
  shardAction.addCommandLine(shardCommandLine.build());
  ruleContext.registerAction(shardAction.build(ruleContext));
  if (makeDexArchives && proguardedJar != null) {
    for (int i=0; i < shards.size(); ++i) {
      checkState(shuffleOutputs.get(i) != shards.get(i));
      DexArchiveAspect.createDexArchiveAction(ruleContext,shuffleOutputs.get(i),DexArchiveAspect.topLevelDexbuilderDexopts(ruleContext,dexopts),shards.get(i));
    }
  }
  return javaResourceJar;
}

Fixed version (ground truth):
private static Artifact createShuffleJarActions(RuleContext ruleContext,boolean makeDexArchives,@Nullable Artifact proguardedJar,ImmutableList<Artifact> shards,AndroidCommon common,@Nullable Artifact inclusionFilterJar,List<String> dexopts,AndroidSemantics semantics,JavaTargetAttributes attributes,Function<Artifact,Artifact> derivedJarFunction,@Nullable Artifact mainDexList) throws InterruptedException, RuleErrorException {
  checkArgument(!shards.isEmpty());
  checkArgument(mainDexList == null || shards.size() > 1);
  checkArgument(proguardedJar == null || inclusionFilterJar == null);
  Artifact javaResourceJar=ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.JAVA_RESOURCES_JAR);
  ImmutableList<Artifact> shuffleOutputs;
  if (makeDexArchives && proguardedJar != null) {
    checkArgument(shards.size() > 1);
    shuffleOutputs=makeShardArtifacts(ruleContext,shards.size(),"String_Node_Str");
  }
 else {
    shuffleOutputs=shards;
  }
  SpawnAction.Builder shardAction=new SpawnAction.Builder().useDefaultShellEnvironment().setMnemonic("String_Node_Str").setProgressMessage("String_Node_Str",ruleContext.getLabel()).setExecutable(ruleContext.getExecutablePrerequisite("String_Node_Str",Mode.HOST)).addOutputs(shuffleOutputs).addOutput(javaResourceJar);
  CustomCommandLine.Builder shardCommandLine=CustomCommandLine.builder().addExecPaths(VectorArg.addBefore("String_Node_Str").each(shuffleOutputs)).addExecPath("String_Node_Str",javaResourceJar);
  if (mainDexList != null) {
    shardCommandLine.addExecPath("String_Node_Str",mainDexList);
    shardAction.addInput(mainDexList);
  }
  if (proguardedJar != null) {
    shardCommandLine.addExecPath("String_Node_Str",proguardedJar);
    shardAction.addInput(proguardedJar);
  }
 else {
    ImmutableList<Artifact> classpath=collectRuntimeJars(common,attributes);
    if (makeDexArchives) {
      Map<Artifact,Artifact> dexArchives=collectDexArchives(ruleContext,common,dexopts,semantics,derivedJarFunction);
      classpath=toDexedClasspath(ruleContext,classpath,dexArchives);
      shardCommandLine.add("String_Node_Str");
    }
 else {
      classpath=classpath.stream().map(derivedJarFunction).collect(toImmutableList());
    }
    shardCommandLine.addExecPaths(VectorArg.addBefore("String_Node_Str").each(classpath));
    shardAction.addInputs(classpath);
    if (inclusionFilterJar != null) {
      shardCommandLine.addExecPath("String_Node_Str",inclusionFilterJar);
      shardAction.addInput(inclusionFilterJar);
    }
  }
  shardAction.addCommandLine(shardCommandLine.build());
  ruleContext.registerAction(shardAction.build(ruleContext));
  if (makeDexArchives && proguardedJar != null) {
    for (int i=0; i < shards.size(); ++i) {
      checkState(!shuffleOutputs.get(i).equals(shards.get(i)));
      DexArchiveAspect.createDexArchiveAction(ruleContext,shuffleOutputs.get(i),DexArchiveAspect.topLevelDexbuilderDexopts(ruleContext,dexopts),shards.get(i));
    }
  }
  return javaResourceJar;
}