nus-yam/ex-repair huggingface dataset:
Program: 110791
Project: 110791
Buggy source:
private boolean runForConfigAndReturnLastIsIncremental(BuildGroupResult.Builder buildGroupResultBuilder,BuildCase buildCase,Path buildBinary,BuildEnvConfig envConfig,ImmutableList<BuildTargetConfig> buildTargetConfigs,int versionIndex,int envIndex,int targetIndex,boolean lastIsIncremental,boolean removeFirstResult) throws IOException, CommandException {
  BuildTargetConfig targetConfig=buildTargetConfigs.get(targetIndex);
  System.out.println(targetConfig.getDescription());
  if (lastIsIncremental && !envConfig.getIncremental()) {
    buildCase.prepareGeneratedCode(workspace.resolve(GENERATED_CODE_FOR_COPY_DIR),workspace.resolve(GENERATED_CODE_DIR));
  }
  if (!lastIsIncremental && envConfig.getIncremental()) {
    JavaCodeGenerator.modifyExistingProject(workspace.resolve(GENERATED_CODE_DIR).toString(),true,true,true,true);
  }
  lastIsIncremental=envConfig.getIncremental();
  if (removeFirstResult) {
    buildTargetAndGetElapsedTime(buildBinary,envConfig,targetConfig);
  }
  double elapsedTime=buildTargetAndGetElapsedTime(buildBinary,envConfig,targetConfig);
  buildGroupResultBuilder.getBuildTargetResultsBuilder(targetIndex).getBuildEnvResultsBuilder(envIndex).getResultsBuilder(versionIndex).addResults(elapsedTime);
  return lastIsIncremental;
}

Fixed version (ground truth):
private boolean runForConfigAndReturnLastIsIncremental(BuildGroupResult.Builder buildGroupResultBuilder,BuildCase buildCase,Path buildBinary,BuildEnvConfig envConfig,ImmutableList<BuildTargetConfig> buildTargetConfigs,int versionIndex,int envIndex,int targetIndex,boolean lastIsIncremental,boolean removeFirstResult) throws IOException, CommandException {
  BuildTargetConfig targetConfig=buildTargetConfigs.get(targetIndex);
  System.out.println(targetConfig.getDescription());
  if (lastIsIncremental && !envConfig.getIncremental()) {
    buildCase.prepareGeneratedCode(workspace.resolve(GENERATED_CODE_FOR_COPY_DIR),workspace.resolve(GENERATED_CODE_DIR));
  }
  if (!lastIsIncremental && envConfig.getIncremental()) {
    JavaCodeGenerator.modifyExistingProject(workspace.resolve(GENERATED_CODE_DIR).toString(),true,true,true,true);
  }
  lastIsIncremental=envConfig.getIncremental();
  if (targetIndex == 0 && envConfig.getCleanBeforeBuild()) {
    builder.clean();
  }
  if (removeFirstResult) {
    buildTargetAndGetElapsedTime(buildBinary,envConfig,targetConfig);
  }
  double elapsedTime=buildTargetAndGetElapsedTime(buildBinary,envConfig,targetConfig);
  buildGroupResultBuilder.getBuildTargetResultsBuilder(targetIndex).getBuildEnvResultsBuilder(envIndex).getResultsBuilder(versionIndex).addResults(elapsedTime);
  return lastIsIncremental;
}
Program: 110792
Project: 110792
Buggy source:
private double buildTargetAndGetElapsedTime(Path buildBinary,BuildEnvConfig envConfig,BuildTargetConfig targetConfig) throws CommandException {
  if (envConfig.getCleanBeforeBuild()) {
    builder.clean();
  }
  double elapsedTime=builder.buildAndGetElapsedTime(buildBinary,builder.getCommandFromConfig(targetConfig,envConfig));
  System.out.println(elapsedTime);
  return elapsedTime;
}

Fixed version (ground truth):
private double buildTargetAndGetElapsedTime(Path buildBinary,BuildEnvConfig envConfig,BuildTargetConfig targetConfig) throws CommandException {
  double elapsedTime=builder.buildAndGetElapsedTime(buildBinary,builder.getCommandFromConfig(targetConfig,envConfig));
  System.out.println(elapsedTime);
  return elapsedTime;
}
Program: 110793
Project: 110793
Buggy source:
@Override public Uniquifier<Target> createUniquifier(){
  return new AbstractUniquifier<Target,Label>(){
    @Override protected Label extractKey(    Target target){
      return target.getLabel();
    }
  }
;
}

Fixed version (ground truth):
@Override public Uniquifier<Target> createUniquifier(){
  return new UniquifierImpl<>(TargetKeyExtractor.INSTANCE);
}
Program: 110795
Project: 110795
Buggy source:
@ThreadSafe ThreadSafeUniquifier<SkyKey> createSkyKeyUniquifier(){
  return new ThreadSafeSkyKeyUniquifier(DEFAULT_THREAD_COUNT);
}

Fixed version (ground truth):
@ThreadSafe ThreadSafeUniquifier<SkyKey> createSkyKeyUniquifier(){
  return new ThreadSafeUniquifierImpl<>(SkyKeyKeyExtractor.INSTANCE,DEFAULT_THREAD_COUNT);
}
Program: 110796
Project: 110796
Buggy source:
private BatchAllRdepsCallback(Uniquifier<Target> uniquifier,Predicate<Target> universe,Callback<Target> callback,int depth,int batchSize){
  this.uniquifier=uniquifier;
  this.universe=universe;
  this.callback=callback;
  this.depth=depth;
  this.batchSize=batchSize;
}

Fixed version (ground truth):
private BatchAllRdepsCallback(MinDepthUniquifier<Target> minDepthUniquifier,Predicate<Target> universe,Callback<Target> callback,int depth,int batchSize){
  this.minDepthUniquifier=minDepthUniquifier;
  this.universe=universe;
  this.callback=callback;
  this.depth=depth;
  this.batchSize=batchSize;
}
Program: 110797
Project: 110797
Buggy source:
/** 
 * Computes and applies the callback to the reverse dependencies of the expression. <p>Batch size is used to only populate at most N targets at one time, because some individual nodes are directly depended on by a large number of other nodes.
 */
@VisibleForTesting protected void getAllRdeps(QueryExpression expression,Predicate<Target> universe,VariableContext<Target> context,Callback<Target> callback,int depth,int batchSize) throws QueryException, InterruptedException {
  Uniquifier<Target> uniquifier=createUniquifier();
  eval(expression,context,new BatchAllRdepsCallback(uniquifier,universe,callback,depth,batchSize));
}

Fixed version (ground truth):
/** 
 * Computes and applies the callback to the reverse dependencies of the expression. <p>Batch size is used to only populate at most N targets at one time, because some individual nodes are directly depended on by a large number of other nodes.
 */
@VisibleForTesting protected void getAllRdeps(QueryExpression expression,Predicate<Target> universe,VariableContext<Target> context,Callback<Target> callback,int depth,int batchSize) throws QueryException, InterruptedException {
  MinDepthUniquifier<Target> minDepthUniquifier=createMinDepthUniquifier();
  eval(expression,context,new BatchAllRdepsCallback(minDepthUniquifier,universe,callback,depth,batchSize));
}
Program: 110798
Project: 110798
Buggy source:
@ThreadSafe ThreadSafeUniquifier<Pair<SkyKey,SkyKey>> createReverseDepSkyKeyUniquifier(){
  return new ThreadSafeReverseDepSkyKeyUniquifier(DEFAULT_THREAD_COUNT);
}

Fixed version (ground truth):
@ThreadSafe ThreadSafeUniquifier<Pair<SkyKey,SkyKey>> createReverseDepSkyKeyUniquifier(){
  return new ThreadSafeUniquifierImpl<>(ReverseDepSkyKeyKeyExtractor.INSTANCE,DEFAULT_THREAD_COUNT);
}
Program: 110799
Project: 110799
Buggy source:
@Override protected SkyKey extractKey(Pair<SkyKey,SkyKey> element){
  return element.second;
}

Fixed version (ground truth):
@Override public SkyKey extractKey(Pair<SkyKey,SkyKey> element){
  return element.second;
}
Program: 110800
Project: 110800
Buggy source:
@ThreadSafe ThreadSafeUniquifier<Target> createTargetUniquifier(){
  return new ThreadSafeTargetUniquifier(DEFAULT_THREAD_COUNT);
}

Fixed version (ground truth):
@ThreadSafe ThreadSafeUniquifier<Target> createTargetUniquifier(){
  return new ThreadSafeUniquifierImpl<>(TargetKeyExtractor.INSTANCE,DEFAULT_THREAD_COUNT);
}
Program: 110802
Project: 110802
Buggy source:
/** 
 * Populates   {@link Target}s from reverse dep mappings of   {@link SkyKey}s, empties the pending list and add next level reverse dep mappings of   {@link SkyKey}s to the queue.
 */
private void processReverseDepsMap(Uniquifier<Target> uniquifier,Map<SkyKey,Iterable<SkyKey>> reverseDepsMap,Callback<Target> callback,Queue<Map.Entry<SkyKey,Iterable<SkyKey>>> reverseDepsQueue) throws QueryException, InterruptedException {
  Collection<Target> children=processRawReverseDeps(targetifyValues(reverseDepsMap));
  Iterable<Target> currentInUniverse=Iterables.filter(children,universe);
  ImmutableList<Target> uniqueChildren=uniquifier.unique(currentInUniverse);
  reverseDepsMap.clear();
  if (!uniqueChildren.isEmpty()) {
    callback.process(uniqueChildren);
    reverseDepsQueue.addAll(graph.getReverseDeps(makeTransitiveTraversalKeys(uniqueChildren)).entrySet());
  }
}

Fixed version (ground truth):
/** 
 * Populates   {@link Target}s from reverse dep mappings of   {@link SkyKey}s, empties the pending list and add next level reverse dep mappings of   {@link SkyKey}s to the queue.
 */
private void processReverseDepsMap(MinDepthUniquifier<Target> minDepthUniquifier,Map<SkyKey,Iterable<SkyKey>> reverseDepsMap,Callback<Target> callback,Queue<Map.Entry<SkyKey,Iterable<SkyKey>>> reverseDepsQueue,int depth) throws QueryException, InterruptedException {
  Collection<Target> children=processRawReverseDeps(targetifyValues(reverseDepsMap));
  Iterable<Target> currentInUniverse=Iterables.filter(children,universe);
  ImmutableList<Target> uniqueChildren=minDepthUniquifier.uniqueAtDepthLessThanOrEqualTo(currentInUniverse,depth);
  reverseDepsMap.clear();
  if (!uniqueChildren.isEmpty()) {
    callback.process(uniqueChildren);
    reverseDepsQueue.addAll(graph.getReverseDeps(makeTransitiveTraversalKeys(uniqueChildren)).entrySet());
  }
}
Program: 110803
Project: 110803
Buggy source:
@Override public void process(Iterable<T> partialResult) throws QueryException, InterruptedException {
  Iterable<T> current=partialResult;
  for (int i=0; i <= depth; i++) {
    List<T> next=new ArrayList<>();
    Iterable<T> currentInUniverse=Iterables.filter(current,universe);
    next.addAll(env.getReverseDeps(uniquifier.unique(currentInUniverse)));
    callback.process(currentInUniverse);
    if (next.isEmpty()) {
      break;
    }
    current=next;
  }
}

Fixed version (ground truth):
@Override public void process(Iterable<T> partialResult) throws QueryException, InterruptedException {
  Iterable<T> current=partialResult;
  for (int i=0; i <= depth; i++) {
    List<T> next=new ArrayList<>();
    Iterable<T> currentInUniverse=Iterables.filter(current,universe);
    next.addAll(env.getReverseDeps(minDepthUniquifier.uniqueAtDepthLessThanOrEqualTo(currentInUniverse,i)));
    callback.process(currentInUniverse);
    if (next.isEmpty()) {
      break;
    }
    current=next;
  }
}
Program: 110804
Project: 110804
Buggy source:
protected <T>void eval(final QueryEnvironment<T> env,VariableContext<T> context,final List<Argument> args,final Callback<T> callback,final Predicate<T> universe) throws QueryException, InterruptedException {
  final int depth=args.size() > 1 ? args.get(1).getInteger() : Integer.MAX_VALUE;
  if (env instanceof StreamableQueryEnvironment<?>) {
    ((StreamableQueryEnvironment<T>)env).getAllRdeps(args.get(0).getExpression(),universe,context,callback,depth);
  }
 else {
    final Uniquifier<T> uniquifier=env.createUniquifier();
    env.eval(args.get(0).getExpression(),context,new Callback<T>(){
      @Override public void process(      Iterable<T> partialResult) throws QueryException, InterruptedException {
        Iterable<T> current=partialResult;
        for (int i=0; i <= depth; i++) {
          List<T> next=new ArrayList<>();
          Iterable<T> currentInUniverse=Iterables.filter(current,universe);
          next.addAll(env.getReverseDeps(uniquifier.unique(currentInUniverse)));
          callback.process(currentInUniverse);
          if (next.isEmpty()) {
            break;
          }
          current=next;
        }
      }
    }
);
  }
}

Fixed version (ground truth):
protected <T>void eval(final QueryEnvironment<T> env,VariableContext<T> context,final List<Argument> args,final Callback<T> callback,final Predicate<T> universe) throws QueryException, InterruptedException {
  final int depth=args.size() > 1 ? args.get(1).getInteger() : Integer.MAX_VALUE;
  if (env instanceof StreamableQueryEnvironment<?>) {
    ((StreamableQueryEnvironment<T>)env).getAllRdeps(args.get(0).getExpression(),universe,context,callback,depth);
  }
 else {
    final MinDepthUniquifier<T> minDepthUniquifier=env.createMinDepthUniquifier();
    env.eval(args.get(0).getExpression(),context,new Callback<T>(){
      @Override public void process(      Iterable<T> partialResult) throws QueryException, InterruptedException {
        Iterable<T> current=partialResult;
        for (int i=0; i <= depth; i++) {
          List<T> next=new ArrayList<>();
          Iterable<T> currentInUniverse=Iterables.filter(current,universe);
          next.addAll(env.getReverseDeps(minDepthUniquifier.uniqueAtDepthLessThanOrEqualTo(currentInUniverse,i)));
          callback.process(currentInUniverse);
          if (next.isEmpty()) {
            break;
          }
          current=next;
        }
      }
    }
);
  }
}
Program: 110805
Project: 110805
Buggy source:
@Override public void process(Iterable<T> partialResult) throws QueryException, InterruptedException {
  Collection<T> current=Sets.newHashSet(partialResult);
  env.buildTransitiveClosure(expression,(Set<T>)current,depthBound);
  for (int i=0; i <= depthBound; i++) {
    ImmutableList<T> toProcess=uniquifier.unique(current);
    callback.process(toProcess);
    current=ImmutableList.copyOf(env.getFwdDeps(toProcess));
    if (current.isEmpty()) {
      break;
    }
  }
}

Fixed version (ground truth):
@Override public void process(Iterable<T> partialResult) throws QueryException, InterruptedException {
  Collection<T> current=Sets.newHashSet(partialResult);
  env.buildTransitiveClosure(expression,(Set<T>)current,depthBound);
  for (int i=0; i <= depthBound; i++) {
    ImmutableList<T> toProcess=minDepthUniquifier.uniqueAtDepthLessThanOrEqualTo(current,i);
    callback.process(toProcess);
    current=ImmutableList.copyOf(env.getFwdDeps(toProcess));
    if (current.isEmpty()) {
      break;
    }
  }
}
Program: 110806
Project: 110806
Buggy source:
/** 
 * Breadth-first search from the arguments.
 */
@Override public <T>void eval(final QueryEnvironment<T> env,VariableContext<T> context,final QueryExpression expression,List<Argument> args,final Callback<T> callback) throws QueryException, InterruptedException {
  final int depthBound=args.size() > 1 ? args.get(1).getInteger() : Integer.MAX_VALUE;
  final Uniquifier<T> uniquifier=env.createUniquifier();
  env.eval(args.get(0).getExpression(),context,new Callback<T>(){
    @Override public void process(    Iterable<T> partialResult) throws QueryException, InterruptedException {
      Collection<T> current=Sets.newHashSet(partialResult);
      env.buildTransitiveClosure(expression,(Set<T>)current,depthBound);
      for (int i=0; i <= depthBound; i++) {
        ImmutableList<T> toProcess=uniquifier.unique(current);
        callback.process(toProcess);
        current=ImmutableList.copyOf(env.getFwdDeps(toProcess));
        if (current.isEmpty()) {
          break;
        }
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Breadth-first search from the arguments.
 */
@Override public <T>void eval(final QueryEnvironment<T> env,VariableContext<T> context,final QueryExpression expression,List<Argument> args,final Callback<T> callback) throws QueryException, InterruptedException {
  final int depthBound=args.size() > 1 ? args.get(1).getInteger() : Integer.MAX_VALUE;
  final MinDepthUniquifier<T> minDepthUniquifier=env.createMinDepthUniquifier();
  env.eval(args.get(0).getExpression(),context,new Callback<T>(){
    @Override public void process(    Iterable<T> partialResult) throws QueryException, InterruptedException {
      Collection<T> current=Sets.newHashSet(partialResult);
      env.buildTransitiveClosure(expression,(Set<T>)current,depthBound);
      for (int i=0; i <= depthBound; i++) {
        ImmutableList<T> toProcess=minDepthUniquifier.uniqueAtDepthLessThanOrEqualTo(current,i);
        callback.process(toProcess);
        current=ImmutableList.copyOf(env.getFwdDeps(toProcess));
        if (current.isEmpty()) {
          break;
        }
      }
    }
  }
);
}
Program: 110807
Project: 110807
Buggy source:
private static SpawnInfo getExtraActionInfo(Spawn spawn){
  SpawnInfo.Builder info=SpawnInfo.newBuilder();
  info.addAllArgument(spawn.getArguments());
  for (  Map.Entry<String,String> variable : spawn.getEnvironment().entrySet()) {
    info.addVariable(EnvironmentVariable.newBuilder().setName(variable.getKey()).setValue(variable.getValue()).build());
  }
  for (  ActionInput input : spawn.getInputFiles()) {
    if (!(input instanceof Artifact) || !((Artifact)input).isMiddlemanArtifact()) {
      info.addInputFile(input.getExecPathString());
    }
  }
  info.addAllOutputFile(ActionInputHelper.toExecPaths(spawn.getOutputFiles()));
  return info.build();
}

Fixed version (ground truth):
@Override public ExtraActionInfo.Builder getExtraActionInfo(){
  ExtraActionInfo.Builder builder=super.getExtraActionInfo();
  if (extraActionInfoSupplier == null) {
    SpawnInfo spawnInfo=getExtraActionSpawnInfo();
    return builder.setExtension(SpawnInfo.spawnInfo,spawnInfo);
  }
 else {
    extraActionInfoSupplier.extend(builder);
    return builder;
  }
}
Program: 110808
Project: 110808
Buggy source:
@Override public void process(Iterable<T> partialResult) throws QueryException, InterruptedException {
  Set<T> result=CompactHashSet.create();
  Iterables.addAll(result,partialResult);
  callback.process(env.getBuildFiles(expression,result,true,true,true));
}

Fixed version (ground truth):
@Override public void process(Iterable<T> partialResult) throws QueryException, InterruptedException {
  Set<T> result=CompactHashSet.create();
  Iterables.addAll(result,partialResult);
  callback.process(uniquifier.unique(env.getBuildFiles(expression,result,true,true,true)));
}
Program: 110809
Project: 110809
Buggy source:
@Override public <T>void eval(final QueryEnvironment<T> env,VariableContext<T> context,final QueryExpression expression,List<Argument> args,final Callback<T> callback) throws QueryException, InterruptedException {
  env.eval(args.get(0).getExpression(),context,new ThreadSafeCallback<T>(){
    @Override public void process(    Iterable<T> partialResult) throws QueryException, InterruptedException {
      Set<T> result=CompactHashSet.create();
      Iterables.addAll(result,partialResult);
      callback.process(env.getBuildFiles(expression,result,true,true,true));
    }
  }
);
}

Fixed version (ground truth):
@Override public <T>void eval(final QueryEnvironment<T> env,VariableContext<T> context,final QueryExpression expression,List<Argument> args,final Callback<T> callback) throws QueryException, InterruptedException {
  final Uniquifier<T> uniquifier=env.createUniquifier();
  env.eval(args.get(0).getExpression(),context,new ThreadSafeCallback<T>(){
    @Override public void process(    Iterable<T> partialResult) throws QueryException, InterruptedException {
      Set<T> result=CompactHashSet.create();
      Iterables.addAll(result,partialResult);
      callback.process(uniquifier.unique(env.getBuildFiles(expression,result,true,true,true)));
    }
  }
);
}
Program: 110810
Project: 110810
Buggy source:
@Override public void process(Iterable<T> partialResult) throws QueryException, InterruptedException {
  Set<T> result=CompactHashSet.create();
  Iterables.addAll(result,partialResult);
  callback.process(env.getBuildFiles(expression,result,false,false,true));
}

Fixed version (ground truth):
@Override public void process(Iterable<T> partialResult) throws QueryException, InterruptedException {
  Set<T> result=CompactHashSet.create();
  Iterables.addAll(result,partialResult);
  callback.process(uniquifier.unique(env.getBuildFiles(expression,result,false,false,true)));
}
Program: 110811
Project: 110811
Buggy source:
@Override public <T>void eval(final QueryEnvironment<T> env,VariableContext<T> context,final QueryExpression expression,List<QueryEnvironment.Argument> args,final Callback<T> callback) throws QueryException, InterruptedException {
  env.eval(args.get(0).getExpression(),context,new Callback<T>(){
    @Override public void process(    Iterable<T> partialResult) throws QueryException, InterruptedException {
      Set<T> result=CompactHashSet.create();
      Iterables.addAll(result,partialResult);
      callback.process(env.getBuildFiles(expression,result,false,false,true));
    }
  }
);
}

Fixed version (ground truth):
@Override public <T>void eval(final QueryEnvironment<T> env,VariableContext<T> context,final QueryExpression expression,List<QueryEnvironment.Argument> args,final Callback<T> callback) throws QueryException, InterruptedException {
  final Uniquifier<T> uniquifier=env.createUniquifier();
  env.eval(args.get(0).getExpression(),context,new Callback<T>(){
    @Override public void process(    Iterable<T> partialResult) throws QueryException, InterruptedException {
      Set<T> result=CompactHashSet.create();
      Iterables.addAll(result,partialResult);
      callback.process(uniquifier.unique(env.getBuildFiles(expression,result,false,false,true)));
    }
  }
);
}
Program: 110812
Project: 110812
Buggy source:
@VisibleForTesting public static SequencedSkyframeExecutor create(PackageFactory pkgFactory,BlazeDirectories directories,BinTools binTools,WorkspaceStatusAction.Factory workspaceStatusActionFactory,ImmutableList<BuildInfoFactory> buildInfoFactories,Iterable<? extends DiffAwareness.Factory> diffAwarenessFactories,PathFragment blacklistedPackagePrefixesFile,String productName){
  return create(pkgFactory,directories,binTools,workspaceStatusActionFactory,buildInfoFactories,diffAwarenessFactories,Predicates.<PathFragment>alwaysFalse(),Preprocessor.Factory.Supplier.NullSupplier.INSTANCE,ImmutableMap.<SkyFunctionName,SkyFunction>of(),ImmutableList.<PrecomputedValue.Injected>of(),ImmutableList.<SkyValueDirtinessChecker>of(),blacklistedPackagePrefixesFile,productName,CrossRepositoryLabelViolationStrategy.ERROR,ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL,BuildFileName.BUILD));
}

Fixed version (ground truth):
@VisibleForTesting public static SequencedSkyframeExecutor create(PackageFactory pkgFactory,BlazeDirectories directories,BinTools binTools,WorkspaceStatusAction.Factory workspaceStatusActionFactory,ImmutableList<BuildInfoFactory> buildInfoFactories,Iterable<? extends DiffAwareness.Factory> diffAwarenessFactories,PathFragment blacklistedPackagePrefixesFile,String productName,Preprocessor.Factory.Supplier preprocessorFactorySupplier){
  return create(pkgFactory,directories,binTools,workspaceStatusActionFactory,buildInfoFactories,diffAwarenessFactories,Predicates.<PathFragment>alwaysFalse(),preprocessorFactorySupplier,ImmutableMap.<SkyFunctionName,SkyFunction>of(),ImmutableList.<PrecomputedValue.Injected>of(),ImmutableList.<SkyValueDirtinessChecker>of(),blacklistedPackagePrefixesFile,productName,CrossRepositoryLabelViolationStrategy.ERROR,ImmutableList.of(BuildFileName.BUILD_DOT_BAZEL,BuildFileName.BUILD));
}
Program: 110813
Project: 110813
Buggy source:
/** 
 * Reads a .afdo.imports file and stores the imports information.
 */
private static ImmutableMultimap<PathFragment,PathFragment> readAutoFdoImports(Path importsFile) throws IOException, FdoException {
  ImmutableMultimap.Builder<PathFragment,PathFragment> importBuilder=ImmutableMultimap.builder();
  for (  String line : FileSystemUtils.iterateLinesAsLatin1(importsFile)) {
    if (!line.isEmpty()) {
      PathFragment key=new PathFragment(line.substring(0,line.indexOf(':')));
      if (key.isAbsolute()) {
        throw new FdoException("String_Node_Str" + importsFile + "String_Node_Str"+ key);
      }
      for (      String auxFile : line.substring(line.indexOf(':') + 1).split("String_Node_Str")) {
        if (auxFile.length() == 0) {
          continue;
        }
        importBuilder.put(key,new PathFragment(auxFile));
      }
    }
  }
  return importBuilder.build();
}

Fixed version (ground truth):
/** 
 * Reads a .afdo.imports file and stores the imports information.
 */
private static ImmutableMultimap<PathFragment,PathFragment> readAutoFdoImports(Path importsFile) throws IOException, FdoException {
  ImmutableMultimap.Builder<PathFragment,PathFragment> importBuilder=ImmutableMultimap.builder();
  for (  String line : FileSystemUtils.iterateLinesAsLatin1(importsFile)) {
    line=line.trim();
    if (line.isEmpty()) {
      continue;
    }
    int colonIndex=line.indexOf(':');
    if (colonIndex < 0) {
      continue;
    }
    PathFragment key=new PathFragment(line.substring(0,colonIndex));
    if (key.isAbsolute()) {
      throw new FdoException("String_Node_Str" + importsFile + "String_Node_Str"+ key);
    }
    for (    String auxFile : line.substring(colonIndex + 1).split("String_Node_Str")) {
      if (auxFile.length() == 0) {
        continue;
      }
      importBuilder.put(key,new PathFragment(auxFile));
    }
  }
  return importBuilder.build();
}
Program: 110816
Project: 110816
Buggy source:
public WorkspaceASTFunctionException(Exception e,Transience transience){
  super(e,transience);
}

Fixed version (ground truth):
WorkspaceASTFunctionException(IOException e,Transience transience){
  super(e,transience);
}
Program: 110818
Project: 110818
Buggy source:
public WorkspaceFileFunctionException(NameConflictException e,Transience transience){
  super(e,transience);
}

Fixed version (ground truth):
WorkspaceFileFunctionException(IOException e,Transience transience){
  super(e,transience);
}
Program: 110819
Project: 110819
Buggy source:
/** 
 * Marks the provided dependency as a direct/explicit dependency. Additionally, if strict_java_deps is enabled, it emits a [strict] compiler warning/error (behavior to be soon replaced by the more complete Blaze implementation).
 */
private void collectExplicitDependency(String jarName,JCTree node,Symbol.TypeSymbol sym){
  if (strictJavaDepsMode.isEnabled() && !isStrictDepsExempt) {
    JarOwner owner=indirectJarsToTargets.get(jarName);
    if (owner != null && seenTargets.add(owner)) {
      String canonicalTargetName=canonicalizeTarget(owner.label());
      missingTargets.add(owner);
      String toolInfo=owner.aspect() == null ? canonicalTargetName : String.format("String_Node_Str",canonicalTargetName,owner.aspect());
      if (strictJavaDepsMode == ERROR) {
        log.error(node.pos,"String_Node_Str",MessageFormat.format(TRANSITIVE_DEP_MESSAGE,sym,toolInfo));
      }
 else {
        log.warning(node.pos,"String_Node_Str",MessageFormat.format(TRANSITIVE_DEP_MESSAGE,sym,toolInfo));
      }
    }
  }
  if (!directDependenciesMap.containsKey(jarName)) {
    Dependency dep=Dependency.newBuilder().setPath(jarName).setKind(Dependency.Kind.EXPLICIT).build();
    directDependenciesMap.put(jarName,dep);
  }
}

Fixed version (ground truth):
/** 
 * Marks the provided dependency as a direct/explicit dependency. Additionally, if strict_java_deps is enabled, it emits a [strict] compiler warning/error (behavior to be soon replaced by the more complete Blaze implementation).
 */
private void collectExplicitDependency(String jarName,JCTree node,Symbol.TypeSymbol sym){
  if (strictJavaDepsMode.isEnabled() && !isStrictDepsExempt) {
    JarOwner owner=indirectJarsToTargets.get(jarName);
    if (owner != null && seenTargets.add(owner)) {
      String canonicalTargetName=canonicalizeTarget(remapTarget(owner.label()));
      missingTargets.add(owner);
      String toolInfo=owner.aspect() == null ? canonicalTargetName : String.format("String_Node_Str",canonicalTargetName,owner.aspect());
      if (strictJavaDepsMode == ERROR) {
        log.error(node.pos,"String_Node_Str",MessageFormat.format(TRANSITIVE_DEP_MESSAGE,sym,toolInfo));
      }
 else {
        log.warning(node.pos,"String_Node_Str",MessageFormat.format(TRANSITIVE_DEP_MESSAGE,sym,toolInfo));
      }
    }
  }
  if (!directDependenciesMap.containsKey(jarName)) {
    Dependency dep=Dependency.newBuilder().setPath(jarName).setKind(Dependency.Kind.EXPLICIT).build();
    directDependenciesMap.put(jarName,dep);
  }
}
Program: 110820
Project: 110820
Buggy source:
/** 
 * Returns the canonical version of the target name. Package private for testing. 
 */
static String canonicalizeTarget(String target){
  String replacement=targetMap.getProperty(target);
  if (replacement != null) {
    return replacement;
  }
  int atIndex=target.indexOf('@');
  if (atIndex != -1) {
    target=target.substring(1);
  }
  int colonIndex=target.indexOf(':');
  if (colonIndex == -1) {
    return target;
  }
  int lastSlash=target.lastIndexOf('/',colonIndex);
  if (lastSlash == -1) {
    return target;
  }
  String packageName=target.substring(lastSlash + 1,colonIndex);
  String suffix=target.substring(colonIndex + 1);
  if (packageName.equals(suffix)) {
    return target.substring(0,colonIndex);
  }
  return target;
}

Fixed version (ground truth):
/** 
 * Returns the canonical version of the target name. Package private for testing. 
 */
static String canonicalizeTarget(String target){
  int atIndex=target.indexOf('@');
  if (atIndex != -1) {
    target=target.substring(1);
  }
  int colonIndex=target.indexOf(':');
  if (colonIndex == -1) {
    return target;
  }
  int lastSlash=target.lastIndexOf('/',colonIndex);
  if (lastSlash == -1) {
    return target;
  }
  String packageName=target.substring(lastSlash + 1,colonIndex);
  String suffix=target.substring(colonIndex + 1);
  if (packageName.equals(suffix)) {
    return target.substring(0,colonIndex);
  }
  return target;
}
Program: 110821
Project: 110821
Buggy source:
@Override public void finish(){
  implicitDependencyExtractor.accumulate(context,checkingTreeScanner.getSeenClasses());
  if (!missingTargets.isEmpty()) {
    String canonicalizedLabel=dependencyModule.getTargetLabel() == null ? null : canonicalizeTarget(dependencyModule.getTargetLabel());
    List<JarOwner> canonicalizedMissing=new ArrayList<>();
    for (    JarOwner owner : Ordering.natural().onResultOf(JarOwner.LABEL).immutableSortedCopy(missingTargets)) {
      canonicalizedMissing.add(JarOwner.create(canonicalizeTarget(owner.label()),owner.aspect()));
    }
    errWriter.print(dependencyModule.getFixMessage().get(canonicalizedMissing,canonicalizedLabel,USE_COLOR));
  }
}

Fixed version (ground truth):
@Override public void finish(){
  implicitDependencyExtractor.accumulate(context,checkingTreeScanner.getSeenClasses());
  if (!missingTargets.isEmpty()) {
    String canonicalizedLabel=dependencyModule.getTargetLabel() == null ? null : canonicalizeTarget(dependencyModule.getTargetLabel());
    List<JarOwner> canonicalizedMissing=new ArrayList<>();
    for (    JarOwner owner : Ordering.natural().onResultOf(JarOwner.LABEL).immutableSortedCopy(missingTargets)) {
      String actualTarget=canonicalizeTarget(remapTarget(owner.label()));
      canonicalizedMissing.add(JarOwner.create(actualTarget,owner.aspect()));
    }
    errWriter.print(dependencyModule.getFixMessage().get(canonicalizedMissing,canonicalizedLabel,USE_COLOR));
  }
}
Program: 110823
Project: 110823
Buggy source:
private void beforeEvaluateQuery() throws InterruptedException {
  boolean resolverNeedsRecreation=false;
  if (graph == null || !graphFactory.isUpToDate(universeKey)) {
    EvaluationResult<SkyValue> result;
    try (AutoProfiler p=AutoProfiler.logged("String_Node_Str",LOG)){
      result=graphFactory.prepareAndGet(universeKey,loadingPhaseThreads,eventHandler);
    }
     checkEvaluationResult(result);
    packageSemaphore=makeFreshPackageMultisetSemaphore();
    graph=result.getWalkableGraph();
    blacklistPatternsSupplier=InterruptibleSupplier.Memoize.of(new BlacklistSupplier(graph));
    graphBackedRecursivePackageProvider=new GraphBackedRecursivePackageProvider(graph,universeTargetPatternKeys,pkgPath);
    resolverNeedsRecreation=true;
  }
  if (forkJoinPool == null) {
    forkJoinPool=NamedForkJoinPool.newNamedPool("String_Node_Str",queryEvaluationParallelismLevel);
    resolverNeedsRecreation=true;
  }
  if (resolverNeedsRecreation) {
    resolver=new RecursivePackageProviderBackedTargetPatternResolver(graphBackedRecursivePackageProvider,eventHandler,TargetPatternEvaluator.DEFAULT_FILTERING_POLICY,packageSemaphore);
  }
}

Fixed version (ground truth):
private void beforeEvaluateQuery() throws InterruptedException {
  if (graph == null || !graphFactory.isUpToDate(universeKey)) {
    EvaluationResult<SkyValue> result;
    try (AutoProfiler p=AutoProfiler.logged("String_Node_Str",LOG)){
      result=graphFactory.prepareAndGet(universeKey,loadingPhaseThreads,eventHandler);
    }
     checkEvaluationResult(result);
    packageSemaphore=makeFreshPackageMultisetSemaphore();
    graph=result.getWalkableGraph();
    blacklistPatternsSupplier=InterruptibleSupplier.Memoize.of(new BlacklistSupplier(graph));
    graphBackedRecursivePackageProvider=new GraphBackedRecursivePackageProvider(graph,universeTargetPatternKeys,pkgPath);
  }
  if (forkJoinPool == null) {
    forkJoinPool=NamedForkJoinPool.newNamedPool("String_Node_Str",queryEvaluationParallelismLevel);
  }
  resolver=new RecursivePackageProviderBackedTargetPatternResolver(graphBackedRecursivePackageProvider,eventHandler,TargetPatternEvaluator.DEFAULT_FILTERING_POLICY,packageSemaphore);
}
Program: 110824
Project: 110824
Buggy source:
@Override public boolean isCycle(SkyKey key) throws InterruptedException {
  NodeEntry entry=getEntryForValue(key);
  if (entry == null) {
    return false;
  }
  ErrorInfo errorInfo=entry.getErrorInfo();
  return errorInfo != null && errorInfo.getCycleInfo() != null;
}

Fixed version (ground truth):
@Override public boolean isCycle(SkyKey key) throws InterruptedException {
  NodeEntry entry=getEntryForValue(key);
  if (entry == null) {
    return false;
  }
  ErrorInfo errorInfo=entry.getErrorInfo();
  return errorInfo != null && !Iterables.isEmpty(errorInfo.getCycleInfo());
}
Program: 110829
Project: 110829
Buggy source:
@Test public void testCompilesTestSourcesIntoDynamicLibrary() throws Exception {
  if (OS.getCurrent() == OS.WINDOWS) {
    return;
  }
  scratch.file("String_Node_Str","String_Node_Str");
  scratch.file("String_Node_Str","String_Node_Str");
  useConfiguration("String_Node_Str");
  ConfiguredTarget configuredTarget=getConfiguredTarget("String_Node_Str");
  CppLinkAction linkAction=(CppLinkAction)getGeneratingAction(configuredTarget,"String_Node_Str" + OsUtils.executableExtension());
  assertThat(artifactsToStrings(linkAction.getInputs())).contains("String_Node_Str" + CrosstoolConfigurationHelper.defaultCpu() + "String_Node_Str");
  assertThat(linkAction.getArguments()).contains(getBinArtifactWithNoOwner("String_Node_Str" + CrosstoolConfigurationHelper.defaultCpu() + "String_Node_Str").getExecPathString());
  RunfilesProvider runfilesProvider=configuredTarget.getProvider(RunfilesProvider.class);
  assertThat(artifactsToStrings(runfilesProvider.getDefaultRunfiles().getArtifacts())).contains("String_Node_Str" + CrosstoolConfigurationHelper.defaultCpu() + "String_Node_Str");
}

Fixed version (ground truth):
@Test public void testCompilesTestSourcesIntoDynamicLibrary() throws Exception {
  if (OS.getCurrent() == OS.WINDOWS) {
    return;
  }
  scratch.file("String_Node_Str","String_Node_Str","String_Node_Str");
  scratch.file("String_Node_Str","String_Node_Str");
  useConfiguration("String_Node_Str","String_Node_Str");
  ConfiguredTarget configuredTarget=getConfiguredTarget("String_Node_Str");
  String cpu=CrosstoolConfigurationHelper.defaultCpu();
  String extension=OsUtils.executableExtension();
  CppLinkAction linkAction=(CppLinkAction)getGeneratingAction(configuredTarget,"String_Node_Str" + extension);
  assertThat(artifactsToStrings(linkAction.getInputs())).contains("String_Node_Str" + cpu + "String_Node_Str");
  assertThat(linkAction.getArguments()).contains(getBinArtifactWithNoOwner("String_Node_Str" + cpu + "String_Node_Str").getExecPathString());
  RunfilesProvider runfilesProvider=configuredTarget.getProvider(RunfilesProvider.class);
  assertThat(artifactsToStrings(runfilesProvider.getDefaultRunfiles().getArtifacts())).contains("String_Node_Str" + cpu + "String_Node_Str");
  configuredTarget=getConfiguredTarget("String_Node_Str");
  linkAction=(CppLinkAction)getGeneratingAction(configuredTarget,"String_Node_Str" + extension);
  assertThat(artifactsToStrings(linkAction.getInputs())).contains("String_Node_Str");
  runfilesProvider=configuredTarget.getProvider(RunfilesProvider.class);
  assertThat(artifactsToStrings(runfilesProvider.getDefaultRunfiles().getArtifacts())).containsExactly("String_Node_Str");
}
Program: 110831
Project: 110831
Buggy source:
private static void checkCompositeSkylarkObjectSafe(Object object){
  if (object instanceof SkylarkApiProvider) {
    return;
  }
 else   if (object instanceof SkylarkList) {
    SkylarkList list=(SkylarkList)object;
    if (list.isEmpty()) {
      return;
    }
    for (    Object listItem : list) {
      checkSkylarkObjectSafe(listItem);
    }
    return;
  }
 else   if (object instanceof SkylarkNestedSet) {
    Class<?> contentType=((SkylarkNestedSet)object).getContentType().getType();
    if (!contentType.equals(Object.class) && !isSimpleSkylarkObjectSafe(contentType)) {
      throw new IllegalArgumentException(EvalUtils.getDataTypeName(contentType));
    }
    return;
  }
 else   if (object instanceof Map<?,?>) {
    for (    Map.Entry<?,?> entry : ((Map<?,?>)object).entrySet()) {
      checkSkylarkObjectSafe(entry.getKey());
      checkSkylarkObjectSafe(entry.getValue());
    }
    return;
  }
 else   if (object instanceof ClassObject) {
    ClassObject struct=(ClassObject)object;
    for (    String key : struct.getKeys()) {
      checkSkylarkObjectSafe(struct.getValue(key));
    }
    return;
  }
  throw new IllegalArgumentException(EvalUtils.getDataTypeName(object));
}

Fixed version (ground truth):
private static void checkCompositeSkylarkObjectSafe(Object object){
  if (object instanceof SkylarkApiProvider) {
    return;
  }
 else   if (object instanceof SkylarkList) {
    SkylarkList list=(SkylarkList)object;
    if (list.isEmpty()) {
      return;
    }
    for (    Object listItem : list) {
      checkSkylarkObjectSafe(listItem);
    }
    return;
  }
 else   if (object instanceof SkylarkNestedSet) {
    Class<?> contentType=((SkylarkNestedSet)object).getContentType().getType();
    if (!contentType.equals(Object.class) && !isSimpleSkylarkObjectSafe(contentType)) {
      throw new IllegalArgumentException(EvalUtils.getDataTypeNameFromClass(contentType));
    }
    return;
  }
 else   if (object instanceof Map<?,?>) {
    for (    Map.Entry<?,?> entry : ((Map<?,?>)object).entrySet()) {
      checkSkylarkObjectSafe(entry.getKey());
      checkSkylarkObjectSafe(entry.getValue());
    }
    return;
  }
 else   if (object instanceof ClassObject) {
    ClassObject struct=(ClassObject)object;
    for (    String key : struct.getKeys()) {
      checkSkylarkObjectSafe(struct.getValue(key));
    }
    return;
  }
  throw new IllegalArgumentException(EvalUtils.getDataTypeName(object));
}
Program: 110832
Project: 110832
Buggy source:
/** 
 * Evaluates an expression of the form "e1 + e2 + ... + eK" by evaluating all the subexpressions in parallel.
 */
private static <T>void parEvalPlus(ImmutableList<QueryExpression> operands,final QueryEnvironment<T> env,final VariableContext<T> context,final ThreadSafeCallback<T> callback,ForkJoinPool forkJoinPool) throws QueryException, InterruptedException {
  ArrayList<ForkJoinTask<Void>> tasks=new ArrayList<>(operands.size());
  for (  final QueryExpression operand : operands) {
    tasks.add(ForkJoinTask.adapt(new Callable<Void>(){
      @Override public Void call() throws QueryException, InterruptedException {
        env.eval(operand,context,callback);
        return null;
      }
    }
));
  }
  for (  ForkJoinTask<?> task : tasks) {
    forkJoinPool.submit(task);
  }
  try {
    MoreFutures.waitForAllInterruptiblyFailFast(tasks);
  }
 catch (  ExecutionException e) {
    Throwables.propagateIfPossible(e.getCause(),QueryException.class,InterruptedException.class);
    throw new IllegalStateException(e);
  }
}

Fixed version (ground truth):
/** 
 * Evaluates an expression of the form "e1 + e2 + ... + eK" by evaluating all the subexpressions in parallel.
 */
private static <T>void parEvalPlus(ImmutableList<QueryExpression> operands,final QueryEnvironment<T> env,final VariableContext<T> context,final ThreadSafeCallback<T> callback,ForkJoinPool forkJoinPool) throws QueryException, InterruptedException {
  ArrayList<QueryTask> queryTasks=new ArrayList<>(operands.size());
  for (  final QueryExpression operand : operands) {
    queryTasks.add(new QueryTask(){
      @Override public void execute() throws QueryException, InterruptedException {
        env.eval(operand,context,callback);
      }
    }
);
  }
  ParallelQueryUtils.executeQueryTasksAndWaitInterruptibly(queryTasks,forkJoinPool);
}
Program: 110833
Project: 110833
Buggy source:
/** 
 * Returns whether dynamic configurations should trim their fragments to only those needed by targets and their transitive dependencies.
 */
private static boolean useUntrimmedDynamicConfigs(BuildOptions options){
  return options.get(BuildConfiguration.Options.class).useDynamicConfigurations == BuildConfiguration.Options.DynamicConfigsMode.NOTRIM;
}

Fixed version (ground truth):
/** 
 * Returns whether dynamic configurations should trim their fragments to only those needed by targets and their transitive dependencies.
 */
private static boolean useUntrimmedDynamicConfigs(BuildOptions options){
  BuildConfiguration.Options.DynamicConfigsMode mode=options.get(BuildConfiguration.Options.class).useDynamicConfigurations;
  return mode == BuildConfiguration.Options.DynamicConfigsMode.NOTRIM || mode == BuildConfiguration.Options.DynamicConfigsMode.NOTRIM_PARTIAL;
}
Program: 110836
Project: 110836
Buggy source:
@Test public void bigDataWithInvalidChecksum_throwsIOExceptionAfterCreateOnEof() throws Exception {
  byte[] bigData=new byte[HttpStream.PRECHECK_BYTES + 70001];
  randoCalrissian.nextBytes(bigData);
  when(connection.getInputStream()).thenReturn(new ByteArrayInputStream(bigData));
  try (HttpStream stream=streamFactory.create(connection,AURL,BAD_CHECKSUM,reconnector)){
    thrown.expect(IOException.class);
    thrown.expectMessage("String_Node_Str");
    toByteArray(stream);
    fail("String_Node_Str");
  }
 }

Fixed version (ground truth):
@Test public void bigDataWithInvalidChecksum_throwsIOExceptionAfterCreateOnEof() throws Exception {
  byte[] bigData=new byte[HttpStream.PRECHECK_BYTES + 70001];
  randoCalrissian.nextBytes(bigData);
  when(connection.getInputStream()).thenReturn(new ByteArrayInputStream(bigData));
  try (HttpStream stream=streamFactory.create(connection,AURL,BAD_CHECKSUM,reconnector)){
    thrown.expect(IOException.class);
    thrown.expectMessage("String_Node_Str");
    ByteStreams.exhaust(stream);
    fail("String_Node_Str");
  }
 }
Program: 110837
Project: 110837
Buggy source:
/** 
 * Strips the C++-contributed prefix out of an output path when tests are run with dynamic configurations. e.g. turns "bazel-out/gcc-X-glibc-Y-k8-fastbuild/ to "bazel-out/fastbuild/". <p>This should be used for targets use configurations with C++ fragments.
 */
protected String stripCppPrefixForDynamicConfigs(String outputPath){
  return targetConfig.useDynamicConfigurations() ? AnalysisTestUtil.OUTPUT_PATH_CPP_PREFIX_PATTERN.matcher(outputPath).replaceFirst("String_Node_Str") : outputPath;
}

Fixed version (ground truth):
/** 
 * Strips the C++-contributed prefix out of an output path when tests are run with dynamic configurations. e.g. turns "bazel-out/gcc-X-glibc-Y-k8-fastbuild/ to "bazel-out/fastbuild/". <p>This should be used for targets use configurations with C++ fragments.
 */
protected String stripCppPrefixForDynamicConfigs(String outputPath){
  return targetConfig.trimConfigurations() ? AnalysisTestUtil.OUTPUT_PATH_CPP_PREFIX_PATTERN.matcher(outputPath).replaceFirst("String_Node_Str") : outputPath;
}
Program: 110838
Project: 110838
Buggy source:
@Override public void visitBlock(JCBlock tree){
  JCIdent ident=make.at(tree).Ident(names.fromString("String_Node_Str"));
  JCThrow throwsTree=make.Throw(make.NewClass(null,List.nil(),ident,List.nil(),null));
  tree.stats=List.of(throwsTree);
}

Fixed version (ground truth):
@Override public void visitBlock(JCBlock tree){
  tree.stats=List.nil();
}
Program: 110839
Project: 110839
Buggy source:
PruningVisitor(Context context){
  this.make=TreeMaker.instance(context);
  this.names=Names.instance(context);
}

Fixed version (ground truth):
PruningVisitor(Context context){
  this.make=TreeMaker.instance(context);
  this.symtab=Symtab.instance(context);
}
Program: 110840
Project: 110840
Buggy source:
@Test public void initalizerBlocks(){
  String[] lines={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  JCCompilationUnit tree=parseLines(lines);
  TreePruner.prune(context,tree);
  String[] expected={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  assertThat(prettyPrint(tree)).isEqualTo(Joiner.on('\n').join(expected));
}

Fixed version (ground truth):
@Test public void initalizerBlocks(){
  String[] lines={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  JCCompilationUnit tree=parseLines(lines);
  TreePruner.prune(context,tree);
  String[] expected={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  assertThat(prettyPrint(tree)).isEqualTo(Joiner.on('\n').join(expected));
}
Program: 110841
Project: 110841
Buggy source:
@Override Object doEval(Environment env) throws EvalException, InterruptedException {
  Object objValue=obj.eval(env);
  Object keyValue=key.eval(env);
  Location loc=getLocation();
  if (objValue instanceof SkylarkIndexable) {
    Object result=((SkylarkIndexable)objValue).getIndex(keyValue,loc);
    return SkylarkType.convertToSkylark(result,env);
  }
 else   if (objValue instanceof String) {
    String string=(String)objValue;
    int index=MethodLibrary.getListIndex(keyValue,string.length(),loc);
    return string.substring(index,index + 1);
  }
  throw new EvalException(loc,Printer.format("String_Node_Str",EvalUtils.getDataTypeName(objValue),EvalUtils.getDataTypeName(keyValue)));
}

Fixed version (ground truth):
@Override Object doEval(Environment env) throws EvalException, InterruptedException {
  Object objValue=obj.eval(env);
  Object keyValue=key.eval(env);
  Location loc=getLocation();
  if (objValue instanceof SkylarkIndexable) {
    Object result=((SkylarkIndexable)objValue).getIndex(keyValue,loc);
    return SkylarkType.convertToSkylark(result,env);
  }
 else   if (objValue instanceof String) {
    String string=(String)objValue;
    int index=EvalUtils.getSequenceIndex(keyValue,string.length(),loc);
    return string.substring(index,index + 1);
  }
  throw new EvalException(loc,Printer.format("String_Node_Str",EvalUtils.getDataTypeName(objValue),EvalUtils.getDataTypeName(keyValue)));
}
Program: 110842
Project: 110842
Buggy source:
/** 
 * Common implementation for find, rfind, index, rindex.
 * @param forward true if we want to return the last matching index.
 */
private static int stringFind(boolean forward,String self,String sub,int start,Object end,String msg) throws ConversionException {
  String substr=pythonSubstring(self,start,end,msg);
  int subpos=forward ? substr.indexOf(sub) : substr.lastIndexOf(sub);
  start=clampIndex(start,self.length());
  return subpos < 0 ? subpos : subpos + start;
}

Fixed version (ground truth):
/** 
 * Common implementation for find, rfind, index, rindex.
 * @param forward true if we want to return the last matching index.
 */
private static int stringFind(boolean forward,String self,String sub,int start,Object end,String msg) throws ConversionException {
  String substr=pythonSubstring(self,start,end,msg);
  int subpos=forward ? substr.indexOf(sub) : substr.lastIndexOf(sub);
  start=EvalUtils.clampRangeEndpoint(start,self.length());
  return subpos < 0 ? subpos : subpos + start;
}