nus-yam/ex-repair huggingface dataset:
Program: 110843
Project: 110843
Buggy source:
private static String pythonSubstring(String str,int start,Object end,String msg) throws ConversionException {
  if (start == 0 && EvalUtils.isNullOrNone(end)) {
    return str;
  }
  start=clampIndex(start,str.length());
  int stop;
  if (EvalUtils.isNullOrNone(end)) {
    stop=str.length();
  }
 else {
    stop=clampIndex(Type.INTEGER.convert(end,msg),str.length());
  }
  if (start >= stop) {
    return "String_Node_Str";
  }
  return str.substring(start,stop);
}

Fixed version (ground truth):
private static String pythonSubstring(String str,int start,Object end,String msg) throws ConversionException {
  if (start == 0 && EvalUtils.isNullOrNone(end)) {
    return str;
  }
  start=EvalUtils.clampRangeEndpoint(start,str.length());
  int stop;
  if (EvalUtils.isNullOrNone(end)) {
    stop=str.length();
  }
 else {
    stop=EvalUtils.clampRangeEndpoint(Type.INTEGER.convert(end,msg),str.length());
  }
  if (start >= stop) {
    return "String_Node_Str";
  }
  return str.substring(start,stop);
}
Program: 110844
Project: 110844
Buggy source:
/** 
 * Retrieve an entry from a SkylarkList.
 * @param key the index
 * @param loc a {@link Location} in case of error
 * @throws EvalException if the key is invalid
 */
@Override public final E getIndex(Object key,Location loc) throws EvalException {
  List<E> list=getContentsUnsafe();
  int index=MethodLibrary.getListIndex(key,list.size(),loc);
  return list.get(index);
}

Fixed version (ground truth):
/** 
 * Retrieve an entry from a SkylarkList.
 * @param key the index
 * @param loc a {@link Location} in case of error
 * @throws EvalException if the key is invalid
 */
@Override public final E getIndex(Object key,Location loc) throws EvalException {
  List<E> list=getContentsUnsafe();
  int index=EvalUtils.getSequenceIndex(key,list.size(),loc);
  return list.get(index);
}
Program: 110845
Project: 110845
Buggy source:
/** 
 * Put an entry into a SkylarkList.
 * @param key the index
 * @param value the associated value
 * @param loc a {@link Location} in case of error
 * @param env an {@link Environment}, to check Mutability
 * @throws EvalException if the key is invalid
 */
public void set(Object key,E value,Location loc,Environment env) throws EvalException {
  checkMutable(loc,env);
  List list=getContentsUnsafe();
  int index=MethodLibrary.getListIndex(key,list.size(),loc);
  list.set(index,value);
}

Fixed version (ground truth):
/** 
 * Put an entry into a SkylarkList.
 * @param key the index
 * @param value the associated value
 * @param loc a {@link Location} in case of error
 * @param env an {@link Environment}, to check Mutability
 * @throws EvalException if the key is invalid
 */
public void set(Object key,E value,Location loc,Environment env) throws EvalException {
  checkMutable(loc,env);
  List list=getContentsUnsafe();
  int index=EvalUtils.getSequenceIndex(key,list.size(),loc);
  list.set(index,value);
}
Program: 110846
Project: 110846
Buggy source:
@Override Object doEval(Environment env) throws EvalException, InterruptedException {
  Object objValue=obj.eval(env);
  Object startValue=start.eval(env);
  Object endValue=end.eval(env);
  Object stepValue=step.eval(env);
  Location loc=getLocation();
  if (objValue instanceof SkylarkList) {
    SkylarkList<Object> list=(SkylarkList<Object>)objValue;
    Object slice=list.getSlice(startValue,endValue,stepValue,loc);
    return SkylarkType.convertToSkylark(slice,env);
  }
 else   if (objValue instanceof String) {
    String string=(String)objValue;
    List<Integer> indices=MethodLibrary.getSliceIndices(startValue,endValue,stepValue,string.length(),loc);
    char[] result=new char[indices.size()];
    char[] original=((String)objValue).toCharArray();
    int resultIndex=0;
    for (    int originalIndex : indices) {
      result[resultIndex]=original[originalIndex];
      ++resultIndex;
    }
    return new String(result);
  }
  throw new EvalException(loc,Printer.format("String_Node_Str",EvalUtils.getDataTypeName(objValue),EvalUtils.getDataTypeName(startValue),EvalUtils.getDataTypeName(endValue),EvalUtils.getDataTypeName(stepValue)));
}

Fixed version (ground truth):
@Override Object doEval(Environment env) throws EvalException, InterruptedException {
  Object objValue=obj.eval(env);
  Object startValue=start.eval(env);
  Object endValue=end.eval(env);
  Object stepValue=step.eval(env);
  Location loc=getLocation();
  if (objValue instanceof SkylarkList) {
    SkylarkList<Object> list=(SkylarkList<Object>)objValue;
    Object slice=list.getSlice(startValue,endValue,stepValue,loc);
    return SkylarkType.convertToSkylark(slice,env);
  }
 else   if (objValue instanceof String) {
    String string=(String)objValue;
    List<Integer> indices=EvalUtils.getSliceIndices(startValue,endValue,stepValue,string.length(),loc);
    char[] result=new char[indices.size()];
    char[] original=((String)objValue).toCharArray();
    int resultIndex=0;
    for (    int originalIndex : indices) {
      result[resultIndex]=original[originalIndex];
      ++resultIndex;
    }
    return new String(result);
  }
  throw new EvalException(loc,Printer.format("String_Node_Str",EvalUtils.getDataTypeName(objValue),EvalUtils.getDataTypeName(startValue),EvalUtils.getDataTypeName(endValue),EvalUtils.getDataTypeName(stepValue)));
}
Program: 110847
Project: 110847
Buggy source:
public String toConflictMessage(){
  return String.format(CONFLICT_MESSAGE,dataKey.toPrettyString(),first.source(),second.source());
}

Fixed version (ground truth):
public String toConflictMessage(){
  return String.format(CONFLICT_MESSAGE,dataKey.toPrettyString(),first.source().getPath(),second.source().getPath());
}
Program: 110850
Project: 110850
Buggy source:
@Override public Package getPackage(EventHandler eventHandler,PackageIdentifier packageName) throws NoSuchPackageException, InterruptedException {
  SkyKey pkgKey=PackageValue.key(packageName);
  PackageValue pkgValue;
  if (graph.exists(pkgKey)) {
    pkgValue=(PackageValue)graph.getValue(pkgKey);
    if (pkgValue == null) {
      throw (NoSuchPackageException)Preconditions.checkNotNull(graph.getException(pkgKey),pkgKey);
    }
  }
 else {
    throw new BuildFileNotFoundException(packageName,"String_Node_Str");
  }
  return pkgValue.getPackage();
}

Fixed version (ground truth):
@Override public Package getPackage(EventHandler eventHandler,PackageIdentifier packageName) throws NoSuchPackageException, InterruptedException {
  SkyKey pkgKey=PackageValue.key(packageName);
  PackageValue pkgValue;
  if (graph.exists(pkgKey)) {
    pkgValue=(PackageValue)graph.getValue(pkgKey);
    if (pkgValue == null) {
      NoSuchPackageException nspe=(NoSuchPackageException)graph.getException(pkgKey);
      if (nspe != null) {
        throw nspe;
      }
      throw new NoSuchPackageException(packageName,"String_Node_Str");
    }
  }
 else {
    throw new BuildFileNotFoundException(packageName,"String_Node_Str");
  }
  return pkgValue.getPackage();
}
Program: 110851
Project: 110851
Buggy source:
/** 
 * Remove the lock for a given   {@link Freezable} that is associated with the given
 * @{link Location}. It is an error if {@code object} does not belong to this mutability,or has no lock corresponding to  {@code loc}.
 */
public void unlock(Freezable object,Location loc){
  if (!object.mutability().equals(this)) {
    throw new AssertionError("String_Node_Str");
  }
  if (!isMutable) {
    return;
  }
  Integer hash=System.identityHashCode(object);
  if (!lockedItems.containsKey(hash)) {
    throw new AssertionError("String_Node_Str");
  }
  boolean changed=lockedItems.remove(hash,loc);
  if (!changed) {
    throw new AssertionError(Printer.format("String_Node_Str" + "String_Node_Str",loc));
  }
}

Fixed version (ground truth):
/** 
 * Remove the lock for a given   {@link Freezable} that is associated with the given
 * @{link Location}. It is an error if {@code object} does not belong to this mutability,or has no lock corresponding to  {@code loc}.
 */
public void unlock(Freezable object,Location loc){
  if (!object.mutability().equals(this)) {
    throw new AssertionError("String_Node_Str");
  }
  if (!isMutable) {
    return;
  }
  if (!lockedItems.containsKey(object)) {
    throw new AssertionError("String_Node_Str");
  }
  List<Location> locList=lockedItems.get(object);
  boolean changed=locList.remove(loc);
  if (!changed) {
    throw new AssertionError(Printer.format("String_Node_Str" + "String_Node_Str",loc));
  }
  if (locList.isEmpty()) {
    lockedItems.remove(object);
  }
}
Program: 110852
Project: 110852
Buggy source:
/** 
 * Creates a Mutability.
 * @param annotation an Object used for error reporting,describing to the user the context in which this Mutability was active.
 */
private Mutability(String annotation){
  this.isMutable=true;
  this.lockedItems=ArrayListMultimap.create();
  this.annotation=Preconditions.checkNotNull(annotation);
}

Fixed version (ground truth):
/** 
 * Creates a Mutability.
 * @param annotation an Object used for error reporting,describing to the user the context in which this Mutability was active.
 */
private Mutability(String annotation){
  this.isMutable=true;
  this.lockedItems=new IdentityHashMap<>(10);
  this.annotation=Preconditions.checkNotNull(annotation);
}
Program: 110853
Project: 110853
Buggy source:
/** 
 * Return whether a   {@link Freezable} belonging to this Mutability is currently locked.Frozen objects are not considered locked, though they are of course immutable nonetheless.
 */
public boolean isLocked(Freezable object){
  if (!object.mutability().equals(this)) {
    throw new AssertionError("String_Node_Str");
  }
  if (!isMutable) {
    return false;
  }
  Integer hash=System.identityHashCode(object);
  return lockedItems.containsKey(hash);
}

Fixed version (ground truth):
/** 
 * Return whether a   {@link Freezable} belonging to this Mutability is currently locked.Frozen objects are not considered locked, though they are of course immutable nonetheless.
 */
public boolean isLocked(Freezable object){
  if (!object.mutability().equals(this)) {
    throw new AssertionError("String_Node_Str");
  }
  if (!isMutable) {
    return false;
  }
  return lockedItems.containsKey(object);
}
Program: 110854
Project: 110854
Buggy source:
/** 
 * Add a lock on a   {@link Freezable} belonging to this Mutability. The object cannot bemutated until all locks on it are gone. For error reporting purposes each lock is associated with its originating  {@link Location}.
 */
public void lock(Freezable object,Location loc){
  if (!object.mutability().equals(this)) {
    throw new AssertionError("String_Node_Str");
  }
  if (!isMutable) {
    return;
  }
  Integer hash=System.identityHashCode(object);
  lockedItems.put(hash,loc);
}

Fixed version (ground truth):
/** 
 * Add a lock on a   {@link Freezable} belonging to this Mutability. The object cannot bemutated until all locks on it are gone. For error reporting purposes each lock is associated with its originating  {@link Location}.
 */
public void lock(Freezable object,Location loc){
  if (!object.mutability().equals(this)) {
    throw new AssertionError("String_Node_Str");
  }
  if (!isMutable) {
    return;
  }
  List<Location> locList;
  if (!lockedItems.containsKey(object)) {
    locList=new ArrayList<>();
    lockedItems.put(object,locList);
  }
 else {
    locList=lockedItems.get(object);
  }
  locList.add(loc);
}
Program: 110855
Project: 110855
Buggy source:
/** 
 * For a locked   {@link Freezable} that belongs to this Mutability, return a List of the{@link Locations} corresponding to its current locks.
 */
public List<Location> getLockLocations(Freezable object){
  if (!isLocked(object)) {
    throw new AssertionError("String_Node_Str");
  }
  Integer hash=System.identityHashCode(object);
  return lockedItems.get(hash);
}

Fixed version (ground truth):
/** 
 * For a locked   {@link Freezable} that belongs to this Mutability, return a List of the{@link Locations} corresponding to its current locks.
 */
public List<Location> getLockLocations(Freezable object){
  if (!isLocked(object)) {
    throw new AssertionError("String_Node_Str");
  }
  return lockedItems.get(object);
}
Program: 110856
Project: 110856
Buggy source:
static void lazyCleanup(ExecutorService backgroundWorkers,final SandboxRunner runner){
  backgroundWorkers.execute(new Runnable(){
    @Override public void run(){
      try {
        while (!Thread.currentThread().isInterrupted()) {
          try {
            runner.cleanup();
            return;
          }
 catch (          IOException e2) {
            Thread.sleep(250);
          }
        }
      }
 catch (      InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }
  }
);
}

Fixed version (ground truth):
static void lazyCleanup(ExecutorService backgroundWorkers,final EventHandler eventHandler,final SandboxRunner runner){
  backgroundWorkers.execute(new Runnable(){
    @Override public void run(){
      try {
        runner.cleanup();
      }
 catch (      IOException e) {
        eventHandler.handle(Event.warn(String.format("String_Node_Str",runner.getSandboxPath(),e)));
      }
    }
  }
);
}
Program: 110857
Project: 110857
Buggy source:
@Override public void run(){
  try {
    while (!Thread.currentThread().isInterrupted()) {
      try {
        runner.cleanup();
        return;
      }
 catch (      IOException e2) {
        Thread.sleep(250);
      }
    }
  }
 catch (  InterruptedException e) {
    Thread.currentThread().interrupt();
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    runner.cleanup();
  }
 catch (  IOException e) {
    eventHandler.handle(Event.warn(String.format("String_Node_Str",runner.getSandboxPath(),e)));
  }
}
Program: 110858
Project: 110858
Buggy source:
@Override public void afterCommand(){
  env=null;
  buildRequest=null;
  ExecutorUtil.interruptibleShutdown(backgroundWorkers);
}

Fixed version (ground truth):
@Override public void afterCommand(){
  backgroundWorkers.shutdownNow();
  if (sandboxOptions != null && !sandboxOptions.sandboxDebug) {
    Path sandboxRoot=env.getDirectories().getOutputBase().getRelative(env.getRuntime().getProductName() + "String_Node_Str");
    if (sandboxRoot.exists()) {
      try {
        for (        Path child : sandboxRoot.getDirectoryEntries()) {
          try {
            FileSystemUtils.deleteTree(child);
          }
 catch (          IOException e) {
            env.getReporter().handle(Event.warn(String.format("String_Node_Str",child.getPathString(),e)));
          }
        }
        sandboxRoot.delete();
      }
 catch (      IOException e) {
        env.getReporter().handle(Event.warn(String.format("String_Node_Str",sandboxRoot.getBaseName(),e)));
      }
    }
  }
  env=null;
  buildRequest=null;
  backgroundWorkers=null;
  sandboxOptions=null;
}
Program: 110859
Project: 110859
Buggy source:
@Override public Iterable<ActionContextProvider> getActionContextProviders(){
  Preconditions.checkNotNull(env);
  Preconditions.checkNotNull(buildRequest);
  Preconditions.checkNotNull(backgroundWorkers);
  try {
    return ImmutableList.<ActionContextProvider>of(SandboxActionContextProvider.create(env,buildRequest,backgroundWorkers));
  }
 catch (  IOException e) {
    throw new IllegalStateException(e);
  }
}

Fixed version (ground truth):
@Override public Iterable<ActionContextProvider> getActionContextProviders(){
  Preconditions.checkNotNull(env);
  Preconditions.checkNotNull(buildRequest);
  Preconditions.checkNotNull(backgroundWorkers);
  sandboxOptions=buildRequest.getOptions(SandboxOptions.class);
  try {
    return ImmutableList.<ActionContextProvider>of(SandboxActionContextProvider.create(env,buildRequest,backgroundWorkers));
  }
 catch (  IOException e) {
    throw new IllegalStateException(e);
  }
}
Program: 110860
Project: 110860
Buggy source:
protected void runSpawn(Spawn spawn,ActionExecutionContext actionExecutionContext,Map<String,String> spawnEnvironment,SandboxExecRoot sandboxExecRoot,Set<PathFragment> outputs,SandboxRunner runner,AtomicReference<Class<? extends SpawnActionContext>> writeOutputFiles) throws ExecException, InterruptedException {
  try {
    runner.run(spawn.getArguments(),spawnEnvironment,actionExecutionContext.getFileOutErr(),Spawns.getTimeoutSeconds(spawn),SandboxHelpers.shouldAllowNetwork(buildRequest,spawn));
  }
  finally {
    if (writeOutputFiles != null && !writeOutputFiles.compareAndSet(null,SandboxStrategy.class)) {
      Thread.currentThread().interrupt();
    }
 else {
      try {
        sandboxExecRoot.copyOutputs(execRoot,outputs);
      }
 catch (      IOException e) {
        actionExecutionContext.getExecutor().getEventHandler().handle(Event.error("String_Node_Str" + e));
      }
    }
    if (!sandboxOptions.sandboxDebug) {
      SandboxHelpers.lazyCleanup(backgroundWorkers,runner);
    }
  }
  if (Thread.interrupted()) {
    throw new InterruptedException();
  }
}

Fixed version (ground truth):
protected void runSpawn(Spawn spawn,ActionExecutionContext actionExecutionContext,Map<String,String> spawnEnvironment,SandboxExecRoot sandboxExecRoot,Set<PathFragment> outputs,SandboxRunner runner,AtomicReference<Class<? extends SpawnActionContext>> writeOutputFiles) throws ExecException, InterruptedException {
  EventHandler eventHandler=actionExecutionContext.getExecutor().getEventHandler();
  try {
    runner.run(spawn.getArguments(),spawnEnvironment,actionExecutionContext.getFileOutErr(),Spawns.getTimeoutSeconds(spawn),SandboxHelpers.shouldAllowNetwork(buildRequest,spawn));
  }
  finally {
    if (writeOutputFiles != null && !writeOutputFiles.compareAndSet(null,SandboxStrategy.class)) {
      Thread.currentThread().interrupt();
    }
 else {
      try {
        sandboxExecRoot.copyOutputs(execRoot,outputs);
      }
 catch (      IOException e) {
        eventHandler.handle(Event.error("String_Node_Str" + e));
      }
    }
    if (!sandboxOptions.sandboxDebug) {
      SandboxHelpers.lazyCleanup(backgroundWorkers,eventHandler,runner);
    }
  }
  if (Thread.interrupted()) {
    throw new InterruptedException();
  }
}
Program: 110861
Project: 110861
Buggy source:
private DarwinSandboxedStrategy(BuildRequest buildRequest,Map<String,String> clientEnv,BlazeDirectories blazeDirs,ExecutorService backgroundWorkers,boolean verboseFailures,String productName,ImmutableList<Path> confPaths,SpawnHelpers spawnHelpers){
  super(blazeDirs,verboseFailures,buildRequest.getOptions(SandboxOptions.class));
  this.buildRequest=buildRequest;
  this.clientEnv=ImmutableMap.copyOf(clientEnv);
  this.blazeDirs=blazeDirs;
  this.execRoot=blazeDirs.getExecRoot();
  this.backgroundWorkers=Preconditions.checkNotNull(backgroundWorkers);
  this.sandboxDebug=buildRequest.getOptions(SandboxOptions.class).sandboxDebug;
  this.verboseFailures=verboseFailures;
  this.productName=productName;
  this.confPaths=confPaths;
  this.spawnHelpers=spawnHelpers;
}

Fixed version (ground truth):
private DarwinSandboxedStrategy(BuildRequest buildRequest,Map<String,String> clientEnv,BlazeDirectories blazeDirs,ExecutorService backgroundWorkers,boolean verboseFailures,String productName,ImmutableList<Path> confPaths,SpawnHelpers spawnHelpers){
  super(buildRequest,blazeDirs,backgroundWorkers,verboseFailures,buildRequest.getOptions(SandboxOptions.class));
  this.clientEnv=ImmutableMap.copyOf(clientEnv);
  this.blazeDirs=blazeDirs;
  this.execRoot=blazeDirs.getExecRoot();
  this.sandboxDebug=buildRequest.getOptions(SandboxOptions.class).sandboxDebug;
  this.verboseFailures=verboseFailures;
  this.productName=productName;
  this.confPaths=confPaths;
  this.spawnHelpers=spawnHelpers;
}
Program: 110863
Project: 110863
Buggy source:
LinuxSandboxedStrategy(BuildRequest buildRequest,BlazeDirectories blazeDirs,ExecutorService backgroundWorkers,boolean verboseFailures,String productName,boolean fullySupported){
  super(blazeDirs,verboseFailures,buildRequest.getOptions(SandboxOptions.class));
  this.buildRequest=buildRequest;
  this.sandboxOptions=buildRequest.getOptions(SandboxOptions.class);
  this.blazeDirs=blazeDirs;
  this.execRoot=blazeDirs.getExecRoot();
  this.backgroundWorkers=Preconditions.checkNotNull(backgroundWorkers);
  this.verboseFailures=verboseFailures;
  this.productName=productName;
  this.fullySupported=fullySupported;
}

Fixed version (ground truth):
LinuxSandboxedStrategy(BuildRequest buildRequest,BlazeDirectories blazeDirs,ExecutorService backgroundWorkers,boolean verboseFailures,String productName,boolean fullySupported){
  super(buildRequest,blazeDirs,backgroundWorkers,verboseFailures,buildRequest.getOptions(SandboxOptions.class));
  this.sandboxOptions=buildRequest.getOptions(SandboxOptions.class);
  this.blazeDirs=blazeDirs;
  this.execRoot=blazeDirs.getExecRoot();
  this.verboseFailures=verboseFailures;
  this.productName=productName;
  this.fullySupported=fullySupported;
}
Program: 110865
Project: 110865
Buggy source:
/** 
 * Runs the command specified via   {@code arguments} and {@code env} inside the sandbox.
 * @param arguments - arguments of spawn to run inside the sandbox.
 * @param environment - environment variables to pass to the spawn.
 * @param outErr - error output to capture sandbox's and command's stderr
 * @param timeout - after how many seconds should the process be killed
 * @param allowNetwork - whether networking should be allowed for the process
 */
void run(List<String> arguments,Map<String,String> environment,OutErr outErr,int timeout,boolean allowNetwork) throws IOException, ExecException {
  Command cmd=getCommand(arguments,environment,timeout,allowNetwork);
  try {
    cmd.execute(new byte[]{},getCommandObserver(timeout),outErr.getOutputStream(),outErr.getErrorStream(),true);
  }
 catch (  CommandException e) {
    boolean timedOut=false;
    if (e instanceof AbnormalTerminationException) {
      TerminationStatus status=((AbnormalTerminationException)e).getResult().getTerminationStatus();
      timedOut=!status.exited() && (status.getTerminatingSignal() == getSignalOnTimeout());
    }
    String message=CommandFailureUtils.describeCommandFailure(verboseFailures,Arrays.asList(cmd.getCommandLineElements()),environment,sandboxExecRoot.getPathString());
    throw new UserExecException(message,e,timedOut);
  }
}

Fixed version (ground truth):
/** 
 * Runs the command specified via   {@code arguments} and {@code env} inside the sandbox.
 * @param arguments - arguments of spawn to run inside the sandbox.
 * @param environment - environment variables to pass to the spawn.
 * @param outErr - error output to capture sandbox's and command's stderr
 * @param timeout - after how many seconds should the process be killed
 * @param allowNetwork - whether networking should be allowed for the process
 */
void run(List<String> arguments,Map<String,String> environment,OutErr outErr,int timeout,boolean allowNetwork) throws ExecException {
  Command cmd;
  try {
    cmd=getCommand(arguments,environment,timeout,allowNetwork);
  }
 catch (  IOException e) {
    throw new UserExecException("String_Node_Str",e);
  }
  try {
    cmd.execute(new byte[]{},getCommandObserver(timeout),outErr.getOutputStream(),outErr.getErrorStream(),true);
  }
 catch (  CommandException e) {
    boolean timedOut=false;
    if (e instanceof AbnormalTerminationException) {
      TerminationStatus status=((AbnormalTerminationException)e).getResult().getTerminationStatus();
      timedOut=!status.exited() && (status.getTerminatingSignal() == getSignalOnTimeout());
    }
    String message=CommandFailureUtils.describeCommandFailure(verboseFailures,Arrays.asList(cmd.getCommandLineElements()),environment,sandboxExecRoot.getPathString());
    throw new UserExecException(message,e,timedOut);
  }
}
Program: 110866
Project: 110866
Buggy source:
public SandboxStrategy(BlazeDirectories blazeDirs,boolean verboseFailures,SandboxOptions sandboxOptions){
  this.blazeDirs=blazeDirs;
  this.verboseFailures=verboseFailures;
  this.sandboxOptions=sandboxOptions;
  this.spawnHelpers=new SpawnHelpers(blazeDirs.getExecRoot());
}

Fixed version (ground truth):
public SandboxStrategy(BuildRequest buildRequest,BlazeDirectories blazeDirs,ExecutorService backgroundWorkers,boolean verboseFailures,SandboxOptions sandboxOptions){
  this.buildRequest=buildRequest;
  this.blazeDirs=blazeDirs;
  this.execRoot=blazeDirs.getExecRoot();
  this.backgroundWorkers=Preconditions.checkNotNull(backgroundWorkers);
  this.verboseFailures=verboseFailures;
  this.sandboxOptions=sandboxOptions;
  this.spawnHelpers=new SpawnHelpers(blazeDirs.getExecRoot());
}
Program: 110870
Project: 110870
Buggy source:
private static NestedSet<Artifact> collectHiddenTopLevelArtifacts(RuleContext ruleContext,CcCompilationOutputs ccCompilationOutputs){
  NestedSetBuilder<Artifact> artifactsToForceBuilder=NestedSetBuilder.stableOrder();
  boolean isLipoCollector=ruleContext.getFragment(CppConfiguration.class).isLipoContextCollector();
  boolean processHeadersInDependencies=ruleContext.getFragment(CppConfiguration.class).processHeadersInDependencies();
  boolean usePic=CppHelper.usePic(ruleContext,false);
  artifactsToForceBuilder.addTransitive(ccCompilationOutputs.getFilesToCompile(isLipoCollector,processHeadersInDependencies,usePic));
  for (  OutputGroupProvider dep : ruleContext.getPrerequisites("String_Node_Str",Mode.TARGET,OutputGroupProvider.class)) {
    artifactsToForceBuilder.addTransitive(dep.getOutputGroup(OutputGroupProvider.HIDDEN_TOP_LEVEL));
  }
  return artifactsToForceBuilder.build();
}

Fixed version (ground truth):
private static NestedSet<Artifact> collectHiddenTopLevelArtifacts(RuleContext ruleContext,CcCompilationOutputs ccCompilationOutputs){
  NestedSetBuilder<Artifact> artifactsToForceBuilder=NestedSetBuilder.stableOrder();
  CppConfiguration cppConfiguration=ruleContext.getFragment(CppConfiguration.class);
  boolean isLipoCollector=cppConfiguration.isLipoContextCollector();
  boolean processHeadersInDependencies=cppConfiguration.processHeadersInDependencies();
  boolean usePic=CppHelper.usePic(ruleContext,false);
  artifactsToForceBuilder.addTransitive(ccCompilationOutputs.getFilesToCompile(isLipoCollector,processHeadersInDependencies,usePic));
  for (  OutputGroupProvider dep : ruleContext.getPrerequisites("String_Node_Str",Mode.TARGET,OutputGroupProvider.class)) {
    artifactsToForceBuilder.addTransitive(dep.getOutputGroup(OutputGroupProvider.HIDDEN_TOP_LEVEL));
  }
  return artifactsToForceBuilder.build();
}
Program: 110873
Project: 110873
Buggy source:
@Test public void testProcessHeadersInDependenciesOfBinaries() throws Exception {
  AnalysisMock.get().ccSupport().setupCrosstool(mockToolsConfig,MockCcSupport.HEADER_PROCESSING_FEATURE_CONFIGURATION);
  useConfiguration("String_Node_Str","String_Node_Str");
  ConfiguredTarget x=scratchConfiguredTarget("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  assertThat(ActionsTestUtil.baseArtifactNames(getOutputGroup(x,OutputGroupProvider.HIDDEN_TOP_LEVEL))).contains("String_Node_Str");
}

Fixed version (ground truth):
@Test public void testProcessHeadersInDependenciesOfBinaries() throws Exception {
  AnalysisMock.get().ccSupport().setupCrosstool(mockToolsConfig,MockCcSupport.HEADER_PROCESSING_FEATURE_CONFIGURATION);
  useConfiguration("String_Node_Str","String_Node_Str");
  ConfiguredTarget x=scratchConfiguredTarget("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  String hiddenTopLevel=ActionsTestUtil.baseNamesOf(getOutputGroup(x,OutputGroupProvider.HIDDEN_TOP_LEVEL));
  assertThat(hiddenTopLevel).contains("String_Node_Str");
  assertThat(hiddenTopLevel).doesNotContain("String_Node_Str");
}
Program: 110874
Project: 110874
Buggy source:
/** 
 * Converts an environment map to the format expected in lpEnvironment by CreateProcess().
 */
private byte[] convertEnvToNative(Map<String,String> env) throws IOException {
  Map<String,String> realEnv=new TreeMap<>();
  realEnv.putAll(env == null ? System.getenv() : env);
  if (getSystemRoot(realEnv) == null) {
    String systemRoot=getSystemRoot(System.getenv());
    if (systemRoot != null) {
      realEnv.put("String_Node_Str",systemRoot);
    }
  }
  if (realEnv.isEmpty()) {
    return new byte[]{0,0};
  }
  StringBuilder result=new StringBuilder();
  for (  Map.Entry<String,String> entry : realEnv.entrySet()) {
    if (entry.getKey().contains("String_Node_Str")) {
      throw new IOException("String_Node_Str");
    }
    result.append(entry.getKey() + "String_Node_Str" + entry.getValue()+ "String_Node_Str");
  }
  result.append("String_Node_Str");
  return result.toString().getBytes(Charsets.UTF_8);
}

Fixed version (ground truth):
/** 
 * Converts an environment map to the format expected in lpEnvironment by CreateProcess().
 */
private byte[] convertEnvToNative(Map<String,String> env) throws IOException {
  Map<String,String> realEnv=new TreeMap<>();
  realEnv.putAll(env == null ? System.getenv() : env);
  if (getSystemRoot(realEnv) == null) {
    String systemRoot=getSystemRoot(System.getenv());
    if (systemRoot != null) {
      realEnv.put("String_Node_Str",systemRoot);
    }
  }
  if (realEnv.isEmpty()) {
    return new byte[]{0,0};
  }
  StringBuilder result=new StringBuilder();
  for (  Map.Entry<String,String> entry : realEnv.entrySet()) {
    if (entry.getKey().contains("String_Node_Str")) {
      continue;
    }
    result.append(entry.getKey() + "String_Node_Str" + entry.getValue()+ "String_Node_Str");
  }
  result.append("String_Node_Str");
  return result.toString().getBytes(Charsets.UTF_8);
}
Program: 110876
Project: 110876
Buggy source:
/** 
 * Compare Paths of the same file system using their PathFragments. <p>Paths from different filesystems will be compared using the identity hash code of their respective filesystems.
 */
@Override public int compareTo(Path o){
  if (equals(o)) {
    return 0;
  }
  FileSystem otherFs=o.getFileSystem();
  if (!fileSystem.equals(otherFs)) {
    int thisFileSystemHash=System.identityHashCode(fileSystem);
    int otherFileSystemHash=System.identityHashCode(otherFs);
    if (thisFileSystemHash < otherFileSystemHash) {
      return -1;
    }
 else     if (thisFileSystemHash > otherFileSystemHash) {
      return 1;
    }
 else {
      return 0;
    }
  }
  Path a=this, b=o;
  int maxDepth=Math.min(a.depth,b.depth);
  while (a.depth > maxDepth) {
    a=a.getParentDirectory();
  }
  while (b.depth > maxDepth) {
    b=b.getParentDirectory();
  }
  if (a.equals(b)) {
    return equals(a) ? -1 : 1;
  }
  Path previousa, previousb;
  do {
    previousa=a;
    previousb=b;
    a=a.getParentDirectory();
    b=b.getParentDirectory();
  }
 while (!a.equals(b));
  return previousa.name.compareTo(previousb.name);
}

Fixed version (ground truth):
/** 
 * Compare Paths of the same file system using their PathFragments. <p>Paths from different filesystems will be compared using the identity hash code of their respective filesystems.
 */
@Override public int compareTo(Path o){
  if (equals(o)) {
    return 0;
  }
  FileSystem otherFs=o.getFileSystem();
  if (!fileSystem.equals(otherFs)) {
    int thisFileSystemHash=System.identityHashCode(fileSystem);
    int otherFileSystemHash=System.identityHashCode(otherFs);
    if (thisFileSystemHash < otherFileSystemHash) {
      return -1;
    }
 else     if (thisFileSystemHash > otherFileSystemHash) {
      return 1;
    }
 else {
      return 0;
    }
  }
  Path a=this;
  Path b=o;
  int maxDepth=Math.min(a.depth,b.depth);
  while (a.depth > maxDepth) {
    a=a.getParentDirectory();
  }
  while (b.depth > maxDepth) {
    b=b.getParentDirectory();
  }
  if (a.equals(b)) {
    return equals(a) ? -1 : 1;
  }
  Path previousa;
  Path previousb;
  do {
    previousa=a;
    previousb=b;
    a=a.getParentDirectory();
    b=b.getParentDirectory();
  }
 while (!a.equals(b));
  return previousa.name.compareTo(previousb.name);
}
Program: 110878
Project: 110878
Buggy source:
/** 
 * The new capacity when growing the array to contain at least newSize many elements. Uses a growth factor of 1.5.
 */
private int growCapacity(int newSize){
  return newSize + newSize >> 1;
}

Fixed version (ground truth):
/** 
 * The new capacity when growing the array to contain at least newSize many elements. Uses a growth factor of 1.5.
 */
private int growCapacity(int newSize){
  return newSize + (newSize >> 1);
}
Program: 110880
Project: 110880
Buggy source:
/** 
 * Invokes obj.func() and returns the result.
 */
private Object invokeObjectMethod(Environment env) throws EvalException, InterruptedException {
  Object objValue=obj.eval(env);
  ImmutableList.Builder<Object> posargs=new ImmutableList.Builder<>();
  posargs.add(objValue);
  Map<String,Object> kwargs=new HashMap<>();
  evalArguments(posargs,kwargs,env);
  return invokeObjectMethod(func.getName(),posargs.build(),ImmutableMap.<String,Object>copyOf(kwargs),this,env);
}

Fixed version (ground truth):
/** 
 * Invokes obj.func() and returns the result.
 */
private Object invokeObjectMethod(Environment env) throws EvalException, InterruptedException {
  Object objValue=obj.eval(env);
  ImmutableList.Builder<Object> posargs=new ImmutableList.Builder<>();
  posargs.add(objValue);
  Map<String,Object> kwargs=new LinkedHashMap<>();
  evalArguments(posargs,kwargs,env);
  return invokeObjectMethod(func.getName(),posargs.build(),ImmutableMap.<String,Object>copyOf(kwargs),this,env);
}
Program: 110881
Project: 110881
Buggy source:
@Test public void testJavaCallWithPositionalAndKwargs() throws Exception {
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testLookup("String_Node_Str","String_Node_Str");
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testIfExactError("String_Node_Str","String_Node_Str");
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testIfExactError("String_Node_Str","String_Node_Str");
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testLookup("String_Node_Str","String_Node_Str");
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testLookup("String_Node_Str","String_Node_Str");
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testLookup("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Test public void testJavaCallWithPositionalAndKwargs() throws Exception {
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testLookup("String_Node_Str","String_Node_Str");
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testIfExactError("String_Node_Str","String_Node_Str");
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testIfExactError("String_Node_Str","String_Node_Str");
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testLookup("String_Node_Str","String_Node_Str");
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testLookup("String_Node_Str","String_Node_Str");
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testLookup("String_Node_Str","String_Node_Str");
  new SkylarkTest().update("String_Node_Str",new Mock()).setUp("String_Node_Str").testIfExactError("String_Node_Str","String_Node_Str");
}
Program: 110883
Project: 110883
Buggy source:
@Override public FragmentOptions getHost(boolean fallback){
  Options host=(Options)getDefault();
  host.outputDirectoryName="String_Node_Str";
  host.compilationMode=CompilationMode.OPT;
  host.isHost=true;
  host.useDynamicConfigurations=useDynamicConfigurations;
  if (fallback) {
    host.cpu=host.hostCpu;
  }
 else {
    host.cpu=hostCpu;
  }
  host.buildRunfiles=true;
  host.stampBinaries=false;
  host.checkVisibility=checkVisibility;
  host.checkLicenses=checkLicenses;
  host.skyframeNativeFileset=skyframeNativeFileset;
  host.allowRuntimeDepsOnNeverLink=allowRuntimeDepsOnNeverLink;
  host.defaultFeatures=ImmutableList.copyOf(defaultFeatures);
  return host;
}

Fixed version (ground truth):
@Override public FragmentOptions getHost(boolean fallback){
  Options host=(Options)getDefault();
  host.outputDirectoryName="String_Node_Str";
  host.compilationMode=CompilationMode.OPT;
  host.isHost=true;
  host.useDynamicConfigurations=useDynamicConfigurations;
  host.enforceConstraints=enforceConstraints;
  if (fallback) {
    host.cpu=host.hostCpu;
  }
 else {
    host.cpu=hostCpu;
  }
  host.buildRunfiles=true;
  host.stampBinaries=false;
  host.checkVisibility=checkVisibility;
  host.checkLicenses=checkLicenses;
  host.skyframeNativeFileset=skyframeNativeFileset;
  host.allowRuntimeDepsOnNeverLink=allowRuntimeDepsOnNeverLink;
  host.defaultFeatures=ImmutableList.copyOf(defaultFeatures);
  return host;
}
Program: 110884
Project: 110884
Buggy source:
private Label(PackageIdentifier packageIdentifier,String name) throws LabelSyntaxException {
  Preconditions.checkNotNull(packageIdentifier);
  Preconditions.checkNotNull(name);
  this.packageIdentifier=packageIdentifier;
  try {
    this.name=canonicalizeTargetName(name);
  }
 catch (  LabelSyntaxException e) {
    if (packageIdentifier.getPackageFragment().getPathString().endsWith("String_Node_Str" + name)) {
      throw new LabelSyntaxException(e.getMessage() + "String_Node_Str" + name+ "String_Node_Str");
    }
    throw e;
  }
  this.hashCode=Objects.hash(this.name,this.packageIdentifier);
}

Fixed version (ground truth):
private Label(PackageIdentifier packageIdentifier,String name) throws LabelSyntaxException {
  Preconditions.checkNotNull(packageIdentifier);
  Preconditions.checkNotNull(name);
  this.packageIdentifier=packageIdentifier;
  try {
    this.name=canonicalizeTargetName(name);
  }
 catch (  LabelSyntaxException e) {
    if (packageIdentifier.getPackageFragment().getPathString().endsWith("String_Node_Str" + name)) {
      throw new LabelSyntaxException(e.getMessage() + "String_Node_Str" + name+ "String_Node_Str");
    }
    throw e;
  }
  this.hashCode=hashCode(this.name,this.packageIdentifier);
}
Program: 110887
Project: 110887
Buggy source:
/** 
 * Collects all attribute labels from the specified aspectDefinition.
 */
public static void addAllAttributesOfAspect(Rule from,Multimap<Attribute,Label> labelBuilder,Aspect aspect,DependencyFilter dependencyFilter){
  ImmutableMap<String,Attribute> attributes=aspect.getDefinition().getAttributes();
  for (  Attribute aspectAttribute : attributes.values()) {
    if (!dependencyFilter.apply(aspect,aspectAttribute)) {
      continue;
    }
    if (aspectAttribute.getType() == BuildType.LABEL) {
      Label label=from.getLabel().resolveRepositoryRelative(BuildType.LABEL.cast(aspectAttribute.getDefaultValue(from)));
      if (label != null) {
        labelBuilder.put(aspectAttribute,label);
      }
    }
 else     if (aspectAttribute.getType() == BuildType.LABEL_LIST) {
      for (      Label label : BuildType.LABEL_LIST.cast(aspectAttribute.getDefaultValue(from))) {
        labelBuilder.put(aspectAttribute,from.getLabel().resolveRepositoryRelative(label));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Collects all attribute labels from the specified aspectDefinition.
 */
public static void addAllAttributesOfAspect(Rule from,Multimap<Attribute,Label> labelBuilder,Aspect aspect,DependencyFilter dependencyFilter){
  ImmutableMap<String,Attribute> attributes=aspect.getDefinition().getAttributes();
  for (  Attribute aspectAttribute : attributes.values()) {
    if (!dependencyFilter.apply(aspect,aspectAttribute)) {
      continue;
    }
    if (aspectAttribute.getType() == BuildType.LABEL) {
      Label label=maybeGetRepositoryRelativeLabel(from,BuildType.LABEL.cast(aspectAttribute.getDefaultValue(from)));
      if (label != null) {
        labelBuilder.put(aspectAttribute,label);
      }
    }
 else     if (aspectAttribute.getType() == BuildType.LABEL_LIST) {
      List<Label> defaultLabels=BuildType.LABEL_LIST.cast(aspectAttribute.getDefaultValue(from));
      if (defaultLabels != null) {
        for (        Label defaultLabel : defaultLabels) {
          Label label=maybeGetRepositoryRelativeLabel(from,defaultLabel);
          if (label != null) {
            labelBuilder.put(aspectAttribute,label);
          }
        }
      }
    }
  }
}
Program: 110890
Project: 110890
Buggy source:
/** 
 * Computes the build options needed for the given key, accounting for transitions possibly specified in the key.
 */
private BuildOptions getDynamicConfigOptions(Dependency key,BuildOptions fromOptions){
  if (key.hasStaticConfiguration()) {
    return key.getConfiguration().getOptions();
  }
 else   if (key.getTransition() == Attribute.ConfigurationTransition.NONE) {
    return fromOptions;
  }
 else {
    return ((PatchTransition)key.getTransition()).apply(fromOptions);
  }
}

Fixed version (ground truth):
/** 
 * Computes the build options needed for the given key, accounting for transitions possibly specified in the key.
 */
private BuildOptions getDynamicConfigOptions(Dependency key,BuildOptions fromOptions,Iterable<Class<? extends BuildConfiguration.Fragment>> requiredFragments){
  if (key.hasStaticConfiguration()) {
    return key.getConfiguration().getOptions();
  }
  BuildOptions toOptions;
  if (key.getTransition() == Attribute.ConfigurationTransition.NONE) {
    toOptions=fromOptions;
  }
 else {
    toOptions=((PatchTransition)key.getTransition()).apply(fromOptions);
  }
  return toOptions.trim(BuildConfiguration.getOptionsClasses(requiredFragments,ruleClassProvider));
}
Program: 110892
Project: 110892
Buggy source:
/** 
 * Registers actions required for compiling the proto files.
 * @return this proto support
 */
public ProtoSupport registerActions(){
  if (!Iterables.isEmpty(getProtoSources())) {
    registerProtoInputListFileAction();
    registerGenerateProtoFilesAction();
  }
  return this;
}

Fixed version (ground truth):
/** 
 * Registers actions required for compiling the proto files.
 * @return this proto support
 */
public ProtoSupport registerActions(){
  if (!Iterables.isEmpty(getFilteredProtoSources())) {
    registerProtoInputListFileAction();
    registerGenerateProtoFilesAction();
  }
  return this;
}
Program: 110893
Project: 110893
Buggy source:
private NestedSet<Artifact> getGenerateActionInputs(){
  NestedSetBuilder<Artifact> inputsBuilder=NestedSetBuilder.<Artifact>stableOrder().add(attributes.getProtoCompiler()).addAll(getProtoSources()).add(getProtoInputListFile()).addAll(attributes.getProtoCompilerSupport()).addAll(getPortableProtoFilters());
  Artifact optionsFile=attributes.getOptionsFile();
  if (optionsFile != null) {
    inputsBuilder.add(optionsFile);
  }
  return inputsBuilder.build();
}

Fixed version (ground truth):
private NestedSet<Artifact> getGenerateActionInputs(){
  NestedSetBuilder<Artifact> inputsBuilder=NestedSetBuilder.<Artifact>stableOrder().add(attributes.getProtoCompiler()).addAll(getAllProtoSources()).add(getProtoInputListFile()).addAll(attributes.getProtoCompilerSupport()).addAll(getPortableProtoFilters());
  Artifact optionsFile=attributes.getOptionsFile();
  if (optionsFile != null) {
    inputsBuilder.add(optionsFile);
  }
  return inputsBuilder.build();
}
Program: 110894
Project: 110894
Buggy source:
private ImmutableList<Artifact> generatedOutputArtifacts(FileType newFileType){
  ImmutableList.Builder<Artifact> builder=new ImmutableList.Builder<>();
  for (  Artifact protoFile : getProtoSources()) {
    String protoFileName=FileSystemUtils.removeExtension(protoFile.getFilename());
    String generatedOutputName;
    if (attributes.outputsCpp()) {
      generatedOutputName=protoFileName;
    }
 else     if (usesProtobufLibrary()) {
      generatedOutputName=generateProtobufFilename(protoFileName);
    }
 else {
      String lowerUnderscoreBaseName=protoFileName.replace('-','_').toLowerCase();
      generatedOutputName=LOWER_UNDERSCORE.to(UPPER_CAMEL,lowerUnderscoreBaseName);
    }
    PathFragment generatedFilePath=new PathFragment(protoFile.getRootRelativePath().getParentDirectory(),new PathFragment(generatedOutputName));
    PathFragment outputFile=FileSystemUtils.appendExtension(generatedFilePath,newFileType.getExtensions().get(0));
    if (outputFile != null) {
      builder.add(ruleContext.getUniqueDirectoryArtifact(UNIQUE_DIRECTORY_NAME,outputFile,ruleContext.getBinOrGenfilesDirectory()));
    }
  }
  return builder.build();
}

Fixed version (ground truth):
private ImmutableList<Artifact> generatedOutputArtifacts(FileType newFileType){
  ImmutableList.Builder<Artifact> builder=new ImmutableList.Builder<>();
  for (  Artifact protoFile : getFilteredProtoSources()) {
    String protoFileName=FileSystemUtils.removeExtension(protoFile.getFilename());
    String generatedOutputName;
    if (attributes.outputsCpp()) {
      generatedOutputName=protoFileName;
    }
 else     if (usesProtobufLibrary()) {
      generatedOutputName=generateProtobufFilename(protoFileName);
    }
 else {
      String lowerUnderscoreBaseName=protoFileName.replace('-','_').toLowerCase();
      generatedOutputName=LOWER_UNDERSCORE.to(UPPER_CAMEL,lowerUnderscoreBaseName);
    }
    PathFragment generatedFilePath=new PathFragment(protoFile.getRootRelativePath().getParentDirectory(),new PathFragment(generatedOutputName));
    PathFragment outputFile=FileSystemUtils.appendExtension(generatedFilePath,newFileType.getExtensions().get(0));
    if (outputFile != null) {
      builder.add(ruleContext.getUniqueDirectoryArtifact(UNIQUE_DIRECTORY_NAME,outputFile,ruleContext.getBinOrGenfilesDirectory()));
    }
  }
  return builder.build();
}
Program: 110895
Project: 110895
Buggy source:
private String getProtoInputListFileContents(){
  return Artifact.joinExecPaths("String_Node_Str",getProtoSources());
}

Fixed version (ground truth):
private String getProtoInputListFileContents(){
  return Artifact.joinExecPaths("String_Node_Str",getFilteredProtoSources());
}