nus-yam/ex-repair huggingface dataset:
Program: 53038
Project: 53038
Buggy source:
private static ImmutableList<String> getAsflags(NdkCxxPlatformTargetConfiguration targetConfiguration,NdkCxxToolchainPaths toolchainPaths){
  return ImmutableList.<String>builder().addAll(getCommonFlags(targetConfiguration,toolchainPaths)).add("String_Node_Str","String_Node_Str").addAll(targetConfiguration.getAssemblerFlags(targetConfiguration.getCompiler().getType())).build();
}

Fixed version (ground truth):
private static ImmutableList<String> getAsflags(NdkCxxPlatformTargetConfiguration targetConfiguration,NdkCxxToolchainPaths toolchainPaths,ImmutableList<String> sanitizerFlags){
  return ImmutableList.<String>builder().addAll(getCommonFlags(targetConfiguration,toolchainPaths)).addAll(sanitizerFlags).add("String_Node_Str","String_Node_Str").addAll(targetConfiguration.getAssemblerFlags(targetConfiguration.getCompiler().getType())).build();
}
Program: 53041
Project: 53041
Buggy source:
/** 
 * Should only be constructed by   {@link CellProvider}.
 */
Cell(final ImmutableSet<Path> knownRoots,final ProjectFilesystem filesystem,final Watchman watchman,final BuckConfig config,final KnownBuildRuleTypesFactory knownBuildRuleTypesFactory,final CellProvider cellProvider,WatchmanDiagnosticCache watchmanDiagnosticCache) throws IOException, InterruptedException {
  this.knownRoots=knownRoots;
  this.filesystem=filesystem;
  this.watchman=watchman;
  this.config=config;
  PythonBuckConfig pythonConfig=new PythonBuckConfig(config,new ExecutableFinder());
  this.pythonInterpreter=pythonConfig.getPythonInterpreter();
  this.knownBuildRuleTypesFactory=knownBuildRuleTypesFactory;
  this.knownBuildRuleTypes=knownBuildRuleTypesFactory.create(config);
  this.cellProvider=cellProvider;
  this.watchmanDiagnosticCache=watchmanDiagnosticCache;
}

Fixed version (ground truth):
/** 
 * Should only be constructed by   {@link CellProvider}.
 */
Cell(final ImmutableSet<Path> knownRoots,final ProjectFilesystem filesystem,final Watchman watchman,final BuckConfig config,final KnownBuildRuleTypesFactory knownBuildRuleTypesFactory,final CellProvider cellProvider,WatchmanDiagnosticCache watchmanDiagnosticCache) throws IOException, InterruptedException {
  this.knownRoots=knownRoots;
  this.filesystem=filesystem;
  this.watchman=watchman;
  this.config=config;
  PythonBuckConfig pythonConfig=new PythonBuckConfig(config,new ExecutableFinder());
  this.pythonInterpreter=pythonConfig.getPythonInterpreter();
  this.knownBuildRuleTypesFactory=knownBuildRuleTypesFactory;
  this.knownBuildRuleTypes=knownBuildRuleTypesFactory.create(config,filesystem);
  this.cellProvider=cellProvider;
  this.watchmanDiagnosticCache=watchmanDiagnosticCache;
}
Program: 53042
Project: 53042
Buggy source:
@Override public void publish(LogRecord record){
  if (!isLoggable(record)) {
    return;
  }
  int ix=(start + count) % buffer.length;
  buffer[ix]=record;
  if (count < buffer.length) {
    count++;
  }
 else {
    start++;
    start%=buffer.length;
  }
  if (record.getLevel().intValue() >= pushLevel.intValue()) {
    push();
  }
}

Fixed version (ground truth):
@Override public void publish(LogRecord record){
  if (!isLoggable(record)) {
    return;
  }
  List<LogRecord> recordsToLog=null;
synchronized (buffer) {
    int ix=(start + count) % buffer.length;
    buffer[ix]=record;
    if (count < buffer.length) {
      count++;
    }
 else {
      start++;
      start%=buffer.length;
    }
    if (record.getLevel().intValue() >= pushLevel.intValue()) {
      recordsToLog=new ArrayList<>();
      while (count > 0) {
        LogRecord oldRecord=buffer[start];
        recordsToLog.add(oldRecord);
        buffer[start]=null;
        start++;
        start%=buffer.length;
        count--;
      }
    }
  }
}
Program: 53043
Project: 53043
Buggy source:
@Override public void documentChanged(DocumentEvent documentEvent){
  if (BuckSettingsProvider.getInstance().getState().enableAutoDeps) {
    String newLine=documentEvent.getNewFragment().toString();
    if (importPattern.matcher(newLine).matches()) {
      addDependency(getVirtualFileFromImportLine(newLine),Optional.fromNullable(FileDocumentManager.getInstance().getFile(document)));
    }
  }
}

Fixed version (ground truth):
@Override public void documentChanged(DocumentEvent documentEvent){
  if (!BuckSettingsProvider.getInstance().getState().enableAutoDeps) {
    return;
  }
  VirtualFile documentFile=FileDocumentManager.getInstance().getFile(document);
  if (documentFile == null) {
    return;
  }
  CharSequence fragment=documentEvent.getNewFragment();
  Matcher matcher=importPattern.matcher(fragment);
  while (matcher.find()) {
    String classname=matcher.group(1);
    VirtualFile classFile=getVirtualFileFromClassname(classname);
    if (classFile == null) {
      continue;
    }
    addDependency(classFile,documentFile);
  }
}
Program: 53044
Project: 53044
Buggy source:
@Override public void documentCreated(@NotNull final Document document,final PsiFile psiFile){
  document.addDocumentListener(new DocumentListener(){
    @Override public void beforeDocumentChange(    DocumentEvent documentEvent){
    }
    @Override public void documentChanged(    DocumentEvent documentEvent){
      if (BuckSettingsProvider.getInstance().getState().enableAutoDeps) {
        String newLine=documentEvent.getNewFragment().toString();
        if (importPattern.matcher(newLine).matches()) {
          addDependency(getVirtualFileFromImportLine(newLine),Optional.fromNullable(FileDocumentManager.getInstance().getFile(document)));
        }
      }
    }
  }
);
}

Fixed version (ground truth):
@Override public void documentCreated(@NotNull final Document document,final PsiFile psiFile){
  document.addDocumentListener(new DocumentListener(){
    @Override public void beforeDocumentChange(    DocumentEvent documentEvent){
    }
    @Override public void documentChanged(    DocumentEvent documentEvent){
      if (!BuckSettingsProvider.getInstance().getState().enableAutoDeps) {
        return;
      }
      VirtualFile documentFile=FileDocumentManager.getInstance().getFile(document);
      if (documentFile == null) {
        return;
      }
      CharSequence fragment=documentEvent.getNewFragment();
      Matcher matcher=importPattern.matcher(fragment);
      while (matcher.find()) {
        String classname=matcher.group(1);
        VirtualFile classFile=getVirtualFileFromClassname(classname);
        if (classFile == null) {
          continue;
        }
        addDependency(classFile,documentFile);
      }
    }
  }
);
}
Program: 53046
Project: 53046
Buggy source:
@Override public void onSuccess(@Nullable String buckTargetResult){
  try {
    String currentClassPath=currentClass.get().getPath();
    Map<String,List<String>> pathAndTargetData=mObjectMapper.readValue(buckTargetResult,Map.class);
    String importTargetName="String_Node_Str";
    String importPath="String_Node_Str";
    String currentTargetName="String_Node_Str";
    String currentPath="String_Node_Str";
    for (    Map.Entry<String,List<String>> targetAndPathEntry : pathAndTargetData.entrySet()) {
      String[] pathAndTarget=targetAndPathEntry.getValue().get(0).replaceFirst("String_Node_Str","String_Node_Str").split("String_Node_Str");
      if (currentClassPath.contains(targetAndPathEntry.getKey())) {
        currentTargetName=pathAndTarget[1];
        currentPath=pathAndTarget[0];
      }
 else {
        importTargetName=pathAndTarget[1];
        importPath=pathAndTarget[0];
      }
    }
    BuckDeps.addDeps(mProject,importPath,currentPath,importTargetName,currentTargetName);
  }
 catch (  IOException e) {
    LOG.error(e.toString());
  }
}

Fixed version (ground truth):
@Override public void onSuccess(@Nullable String buckTargetResult){
  try {
    String currentClassPath=currentClass.getPath();
    Map<String,List<String>> pathAndTargetData=mObjectMapper.readValue(buckTargetResult,Map.class);
    String importTargetName="String_Node_Str";
    String importPath="String_Node_Str";
    String currentTargetName="String_Node_Str";
    String currentPath="String_Node_Str";
    for (    Map.Entry<String,List<String>> targetAndPathEntry : pathAndTargetData.entrySet()) {
      String[] pathAndTarget=targetAndPathEntry.getValue().get(0).replaceFirst("String_Node_Str","String_Node_Str").split("String_Node_Str");
      if (currentClassPath.contains(targetAndPathEntry.getKey())) {
        currentTargetName=pathAndTarget[1];
        currentPath=pathAndTarget[0];
      }
 else {
        importTargetName=pathAndTarget[1];
        importPath=pathAndTarget[0];
      }
    }
    if (!Strings.isNullOrEmpty(currentTargetName) && !Strings.isNullOrEmpty(currentPath) && !Strings.isNullOrEmpty(importTargetName)&& !Strings.isNullOrEmpty(importPath)) {
      BuckDeps.addDeps(mProject,importPath,currentPath,importTargetName,currentTargetName);
      BuckDeps.addVisibility(mProject,importPath,currentPath,importTargetName,currentTargetName);
    }
  }
 catch (  IOException e) {
    LOG.error(e.toString());
  }
}
Program: 53047
Project: 53047
Buggy source:
public static void addDeps(Project project,String importBuckPath,String currentBuckPath,String importTarget,String currentTarget){
  String absoluteCurrentBuckPath=project.getBaseDir().getPath() + "String_Node_Str" + currentBuckPath;
  StringBuilder importBuck=new StringBuilder(readBuckFile(absoluteCurrentBuckPath + "String_Node_Str"));
  String newDep="String_Node_Str" + importBuckPath + "String_Node_Str"+ importTarget+ "String_Node_Str";
  int startOfNewTarget=importBuck.indexOf("String_Node_Str" + currentTarget + "String_Node_Str");
  int startOfDeps=0;
  int endOfDeps;
  Matcher startMatcher=depsStartPattern.matcher(importBuck);
  if (startMatcher.find(startOfNewTarget)) {
    startOfDeps=startMatcher.end();
  }
  endOfDeps=importBuck.indexOf("String_Node_Str",startOfDeps);
  if (!importBuck.substring(startOfDeps,endOfDeps).contains(newDep)) {
    importBuck.insert(startOfDeps,"String_Node_Str" + newDep + "String_Node_Str");
    writeBuckFile(absoluteCurrentBuckPath + "String_Node_Str",importBuck.toString());
  }
  addVisibility(project,importBuckPath,currentBuckPath,importTarget,currentTarget);
}

Fixed version (ground truth):
public static void addDeps(Project project,String importBuckPath,String currentBuckPath,String importTarget,String currentTarget){
  String buckPath=project.getBaseDir().getPath() + "String_Node_Str" + currentBuckPath+ "String_Node_Str";
  String contents=readBuckFile(buckPath);
  String dependency="String_Node_Str" + importBuckPath + "String_Node_Str"+ importTarget;
  String newContents=maybeAddDepToTarget(contents,dependency,currentTarget);
  if (!contents.equals(newContents)) {
    writeBuckFile(buckPath,newContents);
  }
}
Program: 53048
Project: 53048
Buggy source:
public static void addVisibility(Project project,String importBuckPath,String currentBuckPath,String importTarget,String currentTarget){
  String absoluteImportBuckPath=project.getBaseDir().getPath() + "String_Node_Str" + importBuckPath;
  StringBuilder currentBuck=new StringBuilder(readBuckFile(absoluteImportBuckPath + "String_Node_Str"));
  String newVisibility="String_Node_Str" + currentBuckPath + "String_Node_Str"+ currentTarget+ "String_Node_Str";
  int startOfNewTarget=currentBuck.indexOf("String_Node_Str" + importTarget + "String_Node_Str");
  int startOfVisibility=0;
  int endOfVisibility;
  Matcher startMatcher=visibilityStartPattern.matcher(currentBuck);
  if (startMatcher.find(startOfNewTarget)) {
    startOfVisibility=startMatcher.end();
  }
  endOfVisibility=currentBuck.indexOf("String_Node_Str",startOfVisibility);
  if (!currentBuck.substring(startOfVisibility,endOfVisibility).contains(newVisibility) && !currentBuck.substring(startOfVisibility,endOfVisibility).contains("String_Node_Str")) {
    currentBuck.insert(startOfVisibility,"String_Node_Str" + newVisibility + "String_Node_Str");
    writeBuckFile(absoluteImportBuckPath + "String_Node_Str",currentBuck.toString());
  }
}

Fixed version (ground truth):
public static void addVisibility(Project project,String importBuckPath,String currentBuckPath,String importTarget,String currentTarget){
  String buckPath=project.getBaseDir().getPath() + "String_Node_Str" + importBuckPath+ "String_Node_Str";
  String contents=readBuckFile(buckPath);
  String visibility="String_Node_Str" + currentBuckPath + "String_Node_Str"+ currentTarget;
  String newContents=maybeAddVisibilityToTarget(contents,visibility,importTarget);
  if (!contents.equals(newContents)) {
    writeBuckFile(buckPath,newContents);
  }
}
Program: 53049
Project: 53049
Buggy source:
@Override public Iterable<String> getIgnoreUndefinedSymbolsFlags(){
  return Linkers.iXlinker("String_Node_Str");
}

Fixed version (ground truth):
@Override public Iterable<String> getIgnoreUndefinedSymbolsFlags(){
  return Linkers.iXlinker("String_Node_Str","String_Node_Str");
}
Program: 53051
Project: 53051
Buggy source:
public BuildRuleParams appendExtraDeps(Iterable<? extends BuildRule> additional){
  return appendExtraDeps(Suppliers.ofInstance(additional));
}

Fixed version (ground truth):
public BuildRuleParams appendExtraDeps(BuildRule... additional){
  return appendExtraDeps(Suppliers.ofInstance(ImmutableList.copyOf(additional)));
}
Program: 53052
Project: 53052
Buggy source:
private Archive requireStaticLibrary(BuildTarget baseTarget,BuildRuleParams baseParams,BuildRuleResolver resolver,SourcePathResolver pathResolver,CxxPlatform cxxPlatform,Arg args,Linker.LinkableDepType depType) throws NoSuchBuildTargetException {
  Preconditions.checkArgument(Sets.intersection(baseTarget.getFlavors(),Sets.union(Type.FLAVOR_VALUES,cxxPlatforms.getFlavors())).isEmpty());
  BuildTarget target=baseTarget.withFlavors(Type.STATIC.getFlavor(),cxxPlatform.getFlavor());
  Optional<Archive> archive=resolver.getRuleOptionalWithType(target,Archive.class);
  if (archive.isPresent()) {
    return archive.get();
  }
  return resolver.addToIndex(createStaticLibrary(target,baseParams,resolver,pathResolver,cxxPlatform,args,depType));
}

Fixed version (ground truth):
private Archive requireStaticLibrary(BuildTarget baseTarget,BuildRuleParams baseParams,BuildRuleResolver resolver,SourcePathResolver pathResolver,CxxPlatform cxxPlatform,Arg args,Linker.LinkableDepType depType) throws NoSuchBuildTargetException {
  Preconditions.checkArgument(Sets.intersection(baseTarget.getFlavors(),Sets.union(Type.FLAVOR_VALUES,cxxPlatforms.getFlavors())).isEmpty());
  BuildTarget target=baseTarget.withFlavors(depType == Linker.LinkableDepType.STATIC ? Type.STATIC.getFlavor() : Type.STATIC_PIC.getFlavor(),cxxPlatform.getFlavor());
  Optional<Archive> archive=resolver.getRuleOptionalWithType(target,Archive.class);
  if (archive.isPresent()) {
    return archive.get();
  }
  return resolver.addToIndex(createStaticLibrary(target,baseParams,resolver,pathResolver,cxxPlatform,args,depType));
}
Program: 53053
Project: 53053
Buggy source:
private HaskellLinkRule requireSharedLibrary(BuildTarget baseTarget,BuildRuleParams baseParams,BuildRuleResolver resolver,SourcePathResolver pathResolver,CxxPlatform cxxPlatform,Arg args) throws NoSuchBuildTargetException {
  Preconditions.checkArgument(Sets.intersection(baseTarget.getFlavors(),Sets.union(Type.FLAVOR_VALUES,cxxPlatforms.getFlavors())).isEmpty());
  BuildTarget target=baseTarget.withFlavors(Type.STATIC.getFlavor(),cxxPlatform.getFlavor());
  Optional<HaskellLinkRule> linkRule=resolver.getRuleOptionalWithType(target,HaskellLinkRule.class);
  if (linkRule.isPresent()) {
    return linkRule.get();
  }
  return resolver.addToIndex(createSharedLibrary(target,baseParams,resolver,pathResolver,cxxPlatform,args));
}

Fixed version (ground truth):
private HaskellLinkRule requireSharedLibrary(BuildTarget baseTarget,BuildRuleParams baseParams,BuildRuleResolver resolver,SourcePathResolver pathResolver,CxxPlatform cxxPlatform,Arg args) throws NoSuchBuildTargetException {
  Preconditions.checkArgument(Sets.intersection(baseTarget.getFlavors(),Sets.union(Type.FLAVOR_VALUES,cxxPlatforms.getFlavors())).isEmpty());
  BuildTarget target=baseTarget.withFlavors(Type.SHARED.getFlavor(),cxxPlatform.getFlavor());
  Optional<HaskellLinkRule> linkRule=resolver.getRuleOptionalWithType(target,HaskellLinkRule.class);
  if (linkRule.isPresent()) {
    return linkRule.get();
  }
  return resolver.addToIndex(createSharedLibrary(target,baseParams,resolver,pathResolver,cxxPlatform,args));
}
Program: 53054
Project: 53054
Buggy source:
private Archive createStaticLibrary(BuildTarget target,BuildRuleParams baseParams,BuildRuleResolver resolver,SourcePathResolver pathResolver,CxxPlatform cxxPlatform,Arg args,Linker.LinkableDepType depType) throws NoSuchBuildTargetException {
  HaskellCompileRule compileRule=requireCompileRule(baseParams,resolver,pathResolver,cxxPlatform,args,depType);
  return Archive.from(target,baseParams,pathResolver,cxxPlatform,cxxBuckConfig.getArchiveContents(),CxxDescriptionEnhancer.getStaticLibraryPath(baseParams.getProjectFilesystem(),target,cxxPlatform.getFlavor(),CxxSourceRuleFactory.PicType.PDC),compileRule.getObjects());
}

Fixed version (ground truth):
private Archive createStaticLibrary(BuildTarget target,BuildRuleParams baseParams,BuildRuleResolver resolver,SourcePathResolver pathResolver,CxxPlatform cxxPlatform,Arg args,Linker.LinkableDepType depType) throws NoSuchBuildTargetException {
  HaskellCompileRule compileRule=requireCompileRule(baseParams,resolver,pathResolver,cxxPlatform,args,depType);
  return Archive.from(target,baseParams,pathResolver,cxxPlatform,cxxBuckConfig.getArchiveContents(),CxxDescriptionEnhancer.getStaticLibraryPath(baseParams.getProjectFilesystem(),target,cxxPlatform.getFlavor(),depType == Linker.LinkableDepType.STATIC ? CxxSourceRuleFactory.PicType.PDC : CxxSourceRuleFactory.PicType.PIC),compileRule.getObjects());
}
Program: 53055
Project: 53055
Buggy source:
@VisibleForTesting static boolean isTestRunRequiredForTest(TestRule test,BuildEngine cachingBuildEngine,ExecutionContext executionContext,TestRuleKeyFileHelper testRuleKeyFileHelper,boolean isResultsCacheEnabled,boolean isRunningWithTestSelectors,boolean hasEnvironmentOverrides) throws IOException, ExecutionException, InterruptedException {
  boolean isTestRunRequired;
  BuildResult result;
  if (executionContext.isDebugEnabled()) {
    isTestRunRequired=true;
  }
 else   if (isRunningWithTestSelectors) {
    isTestRunRequired=true;
  }
 else   if (hasEnvironmentOverrides) {
    isTestRunRequired=true;
  }
 else   if (((result=cachingBuildEngine.getBuildRuleResult(test.getBuildTarget())) != null) && result.getSuccess() == BuildRuleSuccessType.MATCHING_RULE_KEY && isResultsCacheEnabled && test.hasTestResultFiles() && testRuleKeyFileHelper.isRuleKeyInDir(test)) {
    isTestRunRequired=false;
  }
 else {
    isTestRunRequired=true;
  }
  return isTestRunRequired;
}

Fixed version (ground truth):
@VisibleForTesting static boolean isTestRunRequiredForTest(TestRule test,BuildEngine cachingBuildEngine,ExecutionContext executionContext,TestRuleKeyFileHelper testRuleKeyFileHelper,boolean isResultsCacheEnabled,boolean isRunningWithTestSelectors,boolean hasEnvironmentOverrides,boolean isDryRun) throws IOException, ExecutionException, InterruptedException {
  boolean isTestRunRequired;
  BuildResult result;
  if (executionContext.isDebugEnabled()) {
    isTestRunRequired=true;
  }
 else   if (isRunningWithTestSelectors) {
    isTestRunRequired=true;
  }
 else   if (hasEnvironmentOverrides) {
    isTestRunRequired=true;
  }
 else   if (isDryRun) {
    isTestRunRequired=true;
  }
 else   if (((result=cachingBuildEngine.getBuildRuleResult(test.getBuildTarget())) != null) && result.getSuccess() == BuildRuleSuccessType.MATCHING_RULE_KEY && isResultsCacheEnabled && test.hasTestResultFiles() && testRuleKeyFileHelper.isRuleKeyInDir(test)) {
    isTestRunRequired=false;
  }
 else {
    isTestRunRequired=true;
  }
  return isTestRunRequired;
}
Program: 53057
Project: 53057
Buggy source:
@Test public void testIsTestRunRequiredForTestInDebugMode() throws IOException, ExecutionException, InterruptedException {
  ExecutionContext executionContext=TestExecutionContext.newBuilder().setDebugEnabled(true).build();
  assertTrue(executionContext.isDebugEnabled());
  assertTrue("String_Node_Str" + "String_Node_Str",TestRunning.isTestRunRequiredForTest(createMock(TestRule.class),createMock(CachingBuildEngine.class),executionContext,createMock(TestRuleKeyFileHelper.class),true,false,false));
}

Fixed version (ground truth):
@Test public void testIsTestRunRequiredForTestInDebugMode() throws IOException, ExecutionException, InterruptedException {
  ExecutionContext executionContext=TestExecutionContext.newBuilder().setDebugEnabled(true).build();
  assertTrue(executionContext.isDebugEnabled());
  assertTrue("String_Node_Str" + "String_Node_Str",TestRunning.isTestRunRequiredForTest(createMock(TestRule.class),createMock(CachingBuildEngine.class),executionContext,createMock(TestRuleKeyFileHelper.class),true,false,false,false));
}
Program: 53058
Project: 53058
Buggy source:
@Test public void testIsTestRunRequiredForTestBuiltLocally() throws IOException, ExecutionException, InterruptedException {
  ExecutionContext executionContext=TestExecutionContext.newInstance();
  assertFalse(executionContext.isDebugEnabled());
  FakeTestRule testRule=new FakeTestRule(ImmutableSet.of(Label.of("String_Node_Str")),BuildTargetFactory.newInstance("String_Node_Str"),new SourcePathResolver(new BuildRuleResolver(TargetGraph.EMPTY,new DefaultTargetNodeToBuildRuleTransformer())),ImmutableSortedSet.<BuildRule>of());
  CachingBuildEngine cachingBuildEngine=createMock(CachingBuildEngine.class);
  BuildResult result=BuildResult.success(testRule,BUILT_LOCALLY,CacheResult.miss());
  expect(cachingBuildEngine.getBuildRuleResult(BuildTargetFactory.newInstance("String_Node_Str"))).andReturn(result);
  replay(cachingBuildEngine);
  assertTrue("String_Node_Str",TestRunning.isTestRunRequiredForTest(testRule,cachingBuildEngine,executionContext,createMock(TestRuleKeyFileHelper.class),true,false,false));
  verify(cachingBuildEngine);
}

Fixed version (ground truth):
@Test public void testIsTestRunRequiredForTestBuiltLocally() throws IOException, ExecutionException, InterruptedException {
  ExecutionContext executionContext=TestExecutionContext.newInstance();
  assertFalse(executionContext.isDebugEnabled());
  FakeTestRule testRule=new FakeTestRule(ImmutableSet.of(Label.of("String_Node_Str")),BuildTargetFactory.newInstance("String_Node_Str"),new SourcePathResolver(new BuildRuleResolver(TargetGraph.EMPTY,new DefaultTargetNodeToBuildRuleTransformer())),ImmutableSortedSet.<BuildRule>of());
  CachingBuildEngine cachingBuildEngine=createMock(CachingBuildEngine.class);
  BuildResult result=BuildResult.success(testRule,BUILT_LOCALLY,CacheResult.miss());
  expect(cachingBuildEngine.getBuildRuleResult(BuildTargetFactory.newInstance("String_Node_Str"))).andReturn(result);
  replay(cachingBuildEngine);
  assertTrue("String_Node_Str",TestRunning.isTestRunRequiredForTest(testRule,cachingBuildEngine,executionContext,createMock(TestRuleKeyFileHelper.class),true,false,false,false));
  verify(cachingBuildEngine);
}
Program: 53059
Project: 53059
Buggy source:
@Test public void testIsTestRunRequiredIfRuleKeyNotPresent() throws IOException, ExecutionException, InterruptedException {
  ExecutionContext executionContext=TestExecutionContext.newInstance();
  assertFalse(executionContext.isDebugEnabled());
  FakeTestRule testRule=new FakeTestRule(ImmutableSet.of(Label.of("String_Node_Str")),BuildTargetFactory.newInstance("String_Node_Str"),new SourcePathResolver(new BuildRuleResolver(TargetGraph.EMPTY,new DefaultTargetNodeToBuildRuleTransformer())),ImmutableSortedSet.<BuildRule>of()){
    @Override public boolean hasTestResultFiles(){
      return true;
    }
  }
;
  TestRuleKeyFileHelper testRuleKeyFileHelper=createNiceMock(TestRuleKeyFileHelper.class);
  expect(testRuleKeyFileHelper.isRuleKeyInDir(testRule)).andReturn(false);
  CachingBuildEngine cachingBuildEngine=createMock(CachingBuildEngine.class);
  BuildResult result=BuildResult.success(testRule,MATCHING_RULE_KEY,CacheResult.miss());
  expect(cachingBuildEngine.getBuildRuleResult(BuildTargetFactory.newInstance("String_Node_Str"))).andReturn(result);
  replay(cachingBuildEngine,testRuleKeyFileHelper);
  assertTrue("String_Node_Str" + "String_Node_Str",TestRunning.isTestRunRequiredForTest(testRule,cachingBuildEngine,executionContext,testRuleKeyFileHelper,true,false,false));
  verify(cachingBuildEngine,testRuleKeyFileHelper);
}

Fixed version (ground truth):
@Test public void testIsTestRunRequiredIfRuleKeyNotPresent() throws IOException, ExecutionException, InterruptedException {
  ExecutionContext executionContext=TestExecutionContext.newInstance();
  assertFalse(executionContext.isDebugEnabled());
  FakeTestRule testRule=new FakeTestRule(ImmutableSet.of(Label.of("String_Node_Str")),BuildTargetFactory.newInstance("String_Node_Str"),new SourcePathResolver(new BuildRuleResolver(TargetGraph.EMPTY,new DefaultTargetNodeToBuildRuleTransformer())),ImmutableSortedSet.<BuildRule>of()){
    @Override public boolean hasTestResultFiles(){
      return true;
    }
  }
;
  TestRuleKeyFileHelper testRuleKeyFileHelper=createNiceMock(TestRuleKeyFileHelper.class);
  expect(testRuleKeyFileHelper.isRuleKeyInDir(testRule)).andReturn(false);
  CachingBuildEngine cachingBuildEngine=createMock(CachingBuildEngine.class);
  BuildResult result=BuildResult.success(testRule,MATCHING_RULE_KEY,CacheResult.miss());
  expect(cachingBuildEngine.getBuildRuleResult(BuildTargetFactory.newInstance("String_Node_Str"))).andReturn(result);
  replay(cachingBuildEngine,testRuleKeyFileHelper);
  assertTrue("String_Node_Str" + "String_Node_Str",TestRunning.isTestRunRequiredForTest(testRule,cachingBuildEngine,executionContext,testRuleKeyFileHelper,true,false,false,false));
  verify(cachingBuildEngine,testRuleKeyFileHelper);
}
Program: 53060
Project: 53060
Buggy source:
@Test public void testRunAlwaysRequiredIfEnvironmentOverridesPresent() throws Exception {
  ExecutionContext executionContext=TestExecutionContext.newBuilder().setDebugEnabled(false).build();
  FakeTestRule testRule=new FakeTestRule(ImmutableSet.of(Label.of("String_Node_Str")),BuildTargetFactory.newInstance("String_Node_Str"),new SourcePathResolver(new BuildRuleResolver(TargetGraph.EMPTY,new DefaultTargetNodeToBuildRuleTransformer())),ImmutableSortedSet.<BuildRule>of()){
    @Override public boolean hasTestResultFiles(){
      return true;
    }
  }
;
  TestRuleKeyFileHelper testRuleKeyFileHelper=createNiceMock(TestRuleKeyFileHelper.class);
  expect(testRuleKeyFileHelper.isRuleKeyInDir(testRule)).andReturn(true).times(1);
  CachingBuildEngine cachingBuildEngine=createMock(CachingBuildEngine.class);
  BuildResult result=BuildResult.success(testRule,MATCHING_RULE_KEY,CacheResult.miss());
  expect(cachingBuildEngine.getBuildRuleResult(BuildTargetFactory.newInstance("String_Node_Str"))).andReturn(result).times(1);
  replay(cachingBuildEngine,testRuleKeyFileHelper);
  assertFalse("String_Node_Str",TestRunning.isTestRunRequiredForTest(testRule,cachingBuildEngine,executionContext,testRuleKeyFileHelper,true,false,false));
  assertTrue("String_Node_Str",TestRunning.isTestRunRequiredForTest(testRule,cachingBuildEngine,executionContext,testRuleKeyFileHelper,true,false,true));
  verify(cachingBuildEngine,testRuleKeyFileHelper);
}

Fixed version (ground truth):
@Test public void testRunAlwaysRequiredIfEnvironmentOverridesPresent() throws Exception {
  ExecutionContext executionContext=TestExecutionContext.newBuilder().setDebugEnabled(false).build();
  FakeTestRule testRule=new FakeTestRule(ImmutableSet.of(Label.of("String_Node_Str")),BuildTargetFactory.newInstance("String_Node_Str"),new SourcePathResolver(new BuildRuleResolver(TargetGraph.EMPTY,new DefaultTargetNodeToBuildRuleTransformer())),ImmutableSortedSet.<BuildRule>of()){
    @Override public boolean hasTestResultFiles(){
      return true;
    }
  }
;
  TestRuleKeyFileHelper testRuleKeyFileHelper=createNiceMock(TestRuleKeyFileHelper.class);
  expect(testRuleKeyFileHelper.isRuleKeyInDir(testRule)).andReturn(true).times(1);
  CachingBuildEngine cachingBuildEngine=createMock(CachingBuildEngine.class);
  BuildResult result=BuildResult.success(testRule,MATCHING_RULE_KEY,CacheResult.miss());
  expect(cachingBuildEngine.getBuildRuleResult(BuildTargetFactory.newInstance("String_Node_Str"))).andReturn(result).times(1);
  replay(cachingBuildEngine,testRuleKeyFileHelper);
  assertFalse("String_Node_Str",TestRunning.isTestRunRequiredForTest(testRule,cachingBuildEngine,executionContext,testRuleKeyFileHelper,true,false,false,false));
  assertTrue("String_Node_Str",TestRunning.isTestRunRequiredForTest(testRule,cachingBuildEngine,executionContext,testRuleKeyFileHelper,true,false,true,false));
  verify(cachingBuildEngine,testRuleKeyFileHelper);
}
Program: 53061
Project: 53061
Buggy source:
@Test public void testIsTestRunRequiredForTestBuiltFromCacheIfHasTestResultFiles() throws IOException, ExecutionException, InterruptedException {
  ExecutionContext executionContext=TestExecutionContext.newInstance();
  assertFalse(executionContext.isDebugEnabled());
  FakeTestRule testRule=new FakeTestRule(ImmutableSet.of(Label.of("String_Node_Str")),BuildTargetFactory.newInstance("String_Node_Str"),new SourcePathResolver(new BuildRuleResolver(TargetGraph.EMPTY,new DefaultTargetNodeToBuildRuleTransformer())),ImmutableSortedSet.<BuildRule>of());
  CachingBuildEngine cachingBuildEngine=createMock(CachingBuildEngine.class);
  BuildResult result=BuildResult.success(testRule,FETCHED_FROM_CACHE,CacheResult.hit("String_Node_Str"));
  expect(cachingBuildEngine.getBuildRuleResult(BuildTargetFactory.newInstance("String_Node_Str"))).andReturn(result);
  replay(cachingBuildEngine);
  assertTrue("String_Node_Str" + "String_Node_Str",TestRunning.isTestRunRequiredForTest(testRule,cachingBuildEngine,executionContext,createMock(TestRuleKeyFileHelper.class),true,false,false));
  verify(cachingBuildEngine);
}

Fixed version (ground truth):
@Test public void testIsTestRunRequiredForTestBuiltFromCacheIfHasTestResultFiles() throws IOException, ExecutionException, InterruptedException {
  ExecutionContext executionContext=TestExecutionContext.newInstance();
  assertFalse(executionContext.isDebugEnabled());
  FakeTestRule testRule=new FakeTestRule(ImmutableSet.of(Label.of("String_Node_Str")),BuildTargetFactory.newInstance("String_Node_Str"),new SourcePathResolver(new BuildRuleResolver(TargetGraph.EMPTY,new DefaultTargetNodeToBuildRuleTransformer())),ImmutableSortedSet.<BuildRule>of());
  CachingBuildEngine cachingBuildEngine=createMock(CachingBuildEngine.class);
  BuildResult result=BuildResult.success(testRule,FETCHED_FROM_CACHE,CacheResult.hit("String_Node_Str"));
  expect(cachingBuildEngine.getBuildRuleResult(BuildTargetFactory.newInstance("String_Node_Str"))).andReturn(result);
  replay(cachingBuildEngine);
  assertTrue("String_Node_Str" + "String_Node_Str",TestRunning.isTestRunRequiredForTest(testRule,cachingBuildEngine,executionContext,createMock(TestRuleKeyFileHelper.class),true,false,false,false));
  verify(cachingBuildEngine);
}
Program: 53062
Project: 53062
Buggy source:
/** 
 * Use our own method to compare 'deps' stings. 'deps' should be sorted with local references ':' preceding any cross-repo references '@' e.g :inner, //world:empty, //world/asia:jp, @mars, @moon
 */
private static int compareDependencyStrings(String baseString,String anotherString){
  int endBaseString=baseString.length();
  int endAnotherString=anotherString.length();
  int i=0;
  int j=0;
  while (i < endBaseString && j < endAnotherString) {
    char c1=baseString.charAt(i);
    char c2=anotherString.charAt(j);
    if (c1 == ' ') {
      i++;
      continue;
    }
 else     if (c2 == ' ') {
      j++;
      continue;
    }
 else     if (c1 == c2) {
      i++;
      j++;
      continue;
    }
 else     if (c1 == ':') {
      return -1;
    }
 else     if (c2 == ':') {
      return 1;
    }
 else     if (c1 == '@') {
      return 1;
    }
 else     if (c2 == '@') {
      return -1;
    }
 else     if (c1 < c2) {
      return -1;
    }
 else {
      return 1;
    }
  }
  return baseString.compareTo(anotherString);
}

Fixed version (ground truth):
/** 
 * Use our own method to compare 'deps' strings. 'deps' should be sorted with local references ':' preceding any cross-repo references 'cell//' e.g :inner, //world:empty, //world/asia:jp, mars//olympus, moon//sea:tranquility
 */
private static int compareDependencyStrings(String baseString,String anotherString){
  int endBaseString=baseString.length();
  int endAnotherString=anotherString.length();
  int i=0;
  int j=0;
  while (i < endBaseString && j < endAnotherString) {
    char c1=baseString.charAt(i);
    char c2=anotherString.charAt(j);
    if (c1 == ' ') {
      i++;
      continue;
    }
 else     if (c2 == ' ') {
      j++;
      continue;
    }
 else     if (c1 == c2) {
      i++;
      j++;
      continue;
    }
 else     if (c1 == ':') {
      return -1;
    }
 else     if (c2 == ':') {
      return 1;
    }
 else     if (c1 < c2) {
      return -1;
    }
 else {
      return 1;
    }
  }
  return baseString.compareTo(anotherString);
}
Program: 53063
Project: 53063
Buggy source:
private CounterSnapshot.Builder generateCounterSnapshot(){
  CounterSnapshot.Builder builder=CounterSnapshot.builder().setCategory("String_Node_Str").putValues("String_Node_Str",uploadThreadCount).putValues("String_Node_Str",artifactCount).putValues("String_Node_Str",totalUploadedBytes);
  if (totalNetworkTimeMillis != -1) {
    builder.putValues("String_Node_Str",totalNetworkTimeMillis);
  }
  if (totalNetworkTimeMillis > 0) {
    builder.putValues("String_Node_Str",totalUploadedBytes / TimeUnit.MILLISECONDS.toSeconds(totalNetworkTimeMillis));
  }
  if (buildFinishMillis != -1 && lastUploadFinishMillis != -1) {
    builder.putValues("String_Node_Str",buildFinishMillis - lastUploadFinishMillis);
  }
  return builder;
}

Fixed version (ground truth):
private CounterSnapshot.Builder generateCounterSnapshot(){
  CounterSnapshot.Builder builder=CounterSnapshot.builder().setCategory("String_Node_Str").putValues("String_Node_Str",uploadThreadCount).putValues("String_Node_Str",artifactCount).putValues("String_Node_Str",totalUploadedBytes);
  if (totalNetworkTimeMillis != -1) {
    builder.putValues("String_Node_Str",totalNetworkTimeMillis);
  }
  if (totalNetworkTimeMillis > 0) {
    builder.putValues("String_Node_Str",(1000 * totalUploadedBytes) / totalNetworkTimeMillis);
  }
  if (buildFinishMillis != -1 && lastUploadFinishMillis != -1) {
    builder.putValues("String_Node_Str",buildFinishMillis - lastUploadFinishMillis);
  }
  return builder;
}
Program: 53064
Project: 53064
Buggy source:
private static ArtifactCache newInstanceInternal(ArtifactCacheBuckConfig buckConfig,BuckEventBus buckEventBus,ProjectFilesystem projectFilesystem,Optional<String> wifiSsid,ListeningExecutorService httpWriteExecutorService) throws InterruptedException {
  ImmutableSet<ArtifactCacheBuckConfig.ArtifactCacheMode> modes=buckConfig.getArtifactCacheModes();
  if (modes.isEmpty()) {
    return new NoopArtifactCache();
  }
  ImmutableList.Builder<ArtifactCache> builder=ImmutableList.builder();
  for (  ArtifactCacheBuckConfig.ArtifactCacheMode mode : modes) {
switch (mode) {
case dir:
      builder.add(createDirArtifactCache(Optional.of(buckEventBus),buckConfig.getDirCache(),projectFilesystem));
    break;
case http:
  initializeDistributedCaches(buckConfig,buckEventBus,projectFilesystem,wifiSsid,httpWriteExecutorService,builder,HTTP_PROTOCOL);
break;
case thrift_over_http:
initializeDistributedCaches(buckConfig,buckEventBus,projectFilesystem,wifiSsid,httpWriteExecutorService,builder,THRIFT_PROTOCOL);
break;
}
}
ImmutableList<ArtifactCache> artifactCaches=builder.build();
ArtifactCache result;
if (artifactCaches.size() == 1) {
result=artifactCaches.get(0);
}
 else {
result=new MultiArtifactCache(artifactCaches);
}
result=new TwoLevelArtifactCacheDecorator(result,projectFilesystem,buckEventBus,httpWriteExecutorService,buckConfig.getTwoLevelCachingEnabled(),buckConfig.getTwoLevelCachingMinimumSize(),buckConfig.getTwoLevelCachingMaximumSize());
return result;
}

Fixed version (ground truth):
private static ArtifactCache newInstanceInternal(ArtifactCacheBuckConfig buckConfig,BuckEventBus buckEventBus,ProjectFilesystem projectFilesystem,Optional<String> wifiSsid,ListeningExecutorService httpWriteExecutorService) throws InterruptedException {
  ImmutableSet<ArtifactCacheBuckConfig.ArtifactCacheMode> modes=buckConfig.getArtifactCacheModes();
  if (modes.isEmpty()) {
    return new NoopArtifactCache();
  }
  ImmutableList.Builder<ArtifactCache> builder=ImmutableList.builder();
  for (  ArtifactCacheBuckConfig.ArtifactCacheMode mode : modes) {
switch (mode) {
case dir:
      builder.add(createDirArtifactCache(Optional.of(buckEventBus),buckConfig.getDirCache(),projectFilesystem));
    break;
case http:
  initializeDistributedCaches(buckConfig,buckEventBus,projectFilesystem,wifiSsid,httpWriteExecutorService,builder,HTTP_PROTOCOL);
break;
case thrift_over_http:
initializeDistributedCaches(buckConfig,buckEventBus,projectFilesystem,wifiSsid,httpWriteExecutorService,builder,THRIFT_PROTOCOL);
break;
}
}
ImmutableList<ArtifactCache> artifactCaches=builder.build();
ArtifactCache result;
if (artifactCaches.size() == 1) {
result=artifactCaches.get(0);
}
 else {
result=new MultiArtifactCache(artifactCaches);
}
result=new TwoLevelArtifactCacheDecorator(result,projectFilesystem,buckEventBus,buckConfig.getTwoLevelCachingEnabled(),buckConfig.getTwoLevelCachingMinimumSize(),buckConfig.getTwoLevelCachingMaximumSize());
return result;
}
Program: 53066
Project: 53066
Buggy source:
@Override public ListenableFuture<Boolean> apply(Optional<String> contentHash) throws Exception {
  if (!contentHash.isPresent()) {
    return Futures.immediateFuture(false);
  }
  ImmutableMap<String,String> metadataWithCacheKey=ImmutableMap.<String,String>builder().putAll(info.getMetadata()).put(METADATA_KEY,contentHash.get()).build();
  return Futures.transform(delegate.store(ArtifactInfo.builder().setRuleKeys(info.getRuleKeys()).setMetadata(metadataWithCacheKey).build(),BorrowablePath.notBorrowablePath(emptyFilePath)),Functions.constant(true));
}

Fixed version (ground truth):
@Override public ListenableFuture<Boolean> apply(Void input) throws Exception {
  long fileSize=projectFilesystem.getFileSize(output.getPath());
  if (!performTwoLevelStores || fileSize < minimumTwoLevelStoredArtifactSize || (maximumTwoLevelStoredArtifactSize.isPresent() && fileSize > maximumTwoLevelStoredArtifactSize.get())) {
    return Futures.immediateFuture(false);
  }
  long hashComputationStart=System.currentTimeMillis();
  String hashCode=projectFilesystem.computeSha1(output.getPath()) + "String_Node_Str";
  long hashComputationEnd=System.currentTimeMillis();
  secondLevelHashComputationTimeMs.addSample(hashComputationEnd - hashComputationStart);
  ImmutableMap<String,String> metadataWithCacheKey=ImmutableMap.<String,String>builder().putAll(info.getMetadata()).put(METADATA_KEY,hashCode).build();
  return Futures.transform(Futures.allAsList(delegate.store(ArtifactInfo.builder().setRuleKeys(info.getRuleKeys()).setMetadata(metadataWithCacheKey).build(),BorrowablePath.notBorrowablePath(emptyFilePath)),delegate.store(ArtifactInfo.builder().addRuleKeys(new RuleKey(hashCode)).build(),output)),Functions.constant(true));
}
Program: 53068
Project: 53068
Buggy source:
@Test public void testMetadataIsNotShared() throws InterruptedException, IOException {
  try (InMemoryArtifactCache inMemoryArtifactCache=new InMemoryArtifactCache();TwoLevelArtifactCacheDecorator twoLevelCache=new TwoLevelArtifactCacheDecorator(inMemoryArtifactCache,new ProjectFilesystem(tmp.getRoot()),BuckEventBusFactory.newInstance(),MoreExecutors.newDirectExecutorService(),true,0L,Optional.<Long>absent())){
    LazyPath dummyFile=LazyPath.ofInstance(tmp.newFile());
    final String testMetadataKey="String_Node_Str";
    twoLevelCache.store(ArtifactInfo.builder().addRuleKeys(dummyRuleKey).setMetadata(ImmutableMap.of(testMetadataKey,"String_Node_Str")).build(),BorrowablePath.notBorrowablePath(dummyFile.get()));
    twoLevelCache.store(ArtifactInfo.builder().addRuleKeys(dummyRuleKey2).setMetadata(ImmutableMap.of(testMetadataKey,"String_Node_Str")).build(),BorrowablePath.notBorrowablePath(dummyFile.get()));
    CacheResult fetch1=twoLevelCache.fetch(dummyRuleKey,dummyFile);
    CacheResult fetch2=twoLevelCache.fetch(dummyRuleKey2,dummyFile);
    assertEquals(fetch1.getMetadata().get(TwoLevelArtifactCacheDecorator.METADATA_KEY),fetch2.getMetadata().get(TwoLevelArtifactCacheDecorator.METADATA_KEY));
    assertNotEquals(fetch1.getMetadata().get(testMetadataKey),fetch2.getMetadata().get(testMetadataKey));
  }
 }

Fixed version (ground truth):
@Test public void testMetadataIsNotShared() throws InterruptedException, IOException {
  try (InMemoryArtifactCache inMemoryArtifactCache=new InMemoryArtifactCache();TwoLevelArtifactCacheDecorator twoLevelCache=new TwoLevelArtifactCacheDecorator(inMemoryArtifactCache,new ProjectFilesystem(tmp.getRoot()),BuckEventBusFactory.newInstance(),true,0L,Optional.<Long>absent())){
    LazyPath dummyFile=LazyPath.ofInstance(tmp.newFile());
    final String testMetadataKey="String_Node_Str";
    twoLevelCache.store(ArtifactInfo.builder().addRuleKeys(dummyRuleKey).setMetadata(ImmutableMap.of(testMetadataKey,"String_Node_Str")).build(),BorrowablePath.notBorrowablePath(dummyFile.get()));
    twoLevelCache.store(ArtifactInfo.builder().addRuleKeys(dummyRuleKey2).setMetadata(ImmutableMap.of(testMetadataKey,"String_Node_Str")).build(),BorrowablePath.notBorrowablePath(dummyFile.get()));
    CacheResult fetch1=twoLevelCache.fetch(dummyRuleKey,dummyFile);
    CacheResult fetch2=twoLevelCache.fetch(dummyRuleKey2,dummyFile);
    assertEquals(fetch1.getMetadata().get(TwoLevelArtifactCacheDecorator.METADATA_KEY),fetch2.getMetadata().get(TwoLevelArtifactCacheDecorator.METADATA_KEY));
    assertNotEquals(fetch1.getMetadata().get(testMetadataKey),fetch2.getMetadata().get(testMetadataKey));
  }
 }
Program: 53069
Project: 53069
Buggy source:
private void testStoreThresholds(int artifactSize,int expectedArtifactsInCache) throws InterruptedException, IOException {
  try (InMemoryArtifactCache inMemoryArtifactCache=new InMemoryArtifactCache();TwoLevelArtifactCacheDecorator twoLevelCache=new TwoLevelArtifactCacheDecorator(inMemoryArtifactCache,new ProjectFilesystem(tmp.getRoot()),BuckEventBusFactory.newInstance(),MoreExecutors.newDirectExecutorService(),true,5L,Optional.of(10L))){
    LazyPath lazyPath=LazyPath.ofInstance(tmp.newFile());
    Files.write(lazyPath.get(),new byte[artifactSize]);
    twoLevelCache.store(ArtifactInfo.builder().addRuleKeys(dummyRuleKey).build(),BorrowablePath.notBorrowablePath(lazyPath.get()));
    assertThat(inMemoryArtifactCache.getArtifactCount(),Matchers.equalTo(expectedArtifactsInCache));
  }
 }

Fixed version (ground truth):
private void testStoreThresholds(int artifactSize,int expectedArtifactsInCache) throws InterruptedException, IOException {
  try (InMemoryArtifactCache inMemoryArtifactCache=new InMemoryArtifactCache();TwoLevelArtifactCacheDecorator twoLevelCache=new TwoLevelArtifactCacheDecorator(inMemoryArtifactCache,new ProjectFilesystem(tmp.getRoot()),BuckEventBusFactory.newInstance(),true,5L,Optional.of(10L))){
    LazyPath lazyPath=LazyPath.ofInstance(tmp.newFile());
    Files.write(lazyPath.get(),new byte[artifactSize]);
    twoLevelCache.store(ArtifactInfo.builder().addRuleKeys(dummyRuleKey).build(),BorrowablePath.notBorrowablePath(lazyPath.get()));
    assertThat(inMemoryArtifactCache.getArtifactCount(),Matchers.equalTo(expectedArtifactsInCache));
  }
 }
Program: 53070
Project: 53070
Buggy source:
@Test public void testCanRead2LStoresIfStoresDisabled() throws InterruptedException, IOException {
  try (InMemoryArtifactCache inMemoryArtifactCache=new InMemoryArtifactCache();TwoLevelArtifactCacheDecorator twoLevelCache=new TwoLevelArtifactCacheDecorator(inMemoryArtifactCache,new ProjectFilesystem(tmp.getRoot()),BuckEventBusFactory.newInstance(),MoreExecutors.newDirectExecutorService(),true,0L,Optional.<Long>absent());TwoLevelArtifactCacheDecorator twoLevelCacheNoStore=new TwoLevelArtifactCacheDecorator(inMemoryArtifactCache,new ProjectFilesystem(tmp.getRoot()),BuckEventBusFactory.newInstance(),MoreExecutors.newDirectExecutorService(),false,0L,Optional.<Long>absent())){
    LazyPath dummyFile=LazyPath.ofInstance(tmp.newFile());
    twoLevelCache.store(ArtifactInfo.builder().addRuleKeys(dummyRuleKey).build(),BorrowablePath.notBorrowablePath(dummyFile.get()));
    assertThat(inMemoryArtifactCache.getArtifactCount(),Matchers.equalTo(2));
    assertThat(twoLevelCacheNoStore.fetch(dummyRuleKey,dummyFile).getType(),Matchers.equalTo(CacheResultType.HIT));
  }
 }

Fixed version (ground truth):
@Test public void testCanRead2LStoresIfStoresDisabled() throws InterruptedException, IOException {
  try (InMemoryArtifactCache inMemoryArtifactCache=new InMemoryArtifactCache();TwoLevelArtifactCacheDecorator twoLevelCache=new TwoLevelArtifactCacheDecorator(inMemoryArtifactCache,new ProjectFilesystem(tmp.getRoot()),BuckEventBusFactory.newInstance(),true,0L,Optional.<Long>absent());TwoLevelArtifactCacheDecorator twoLevelCacheNoStore=new TwoLevelArtifactCacheDecorator(inMemoryArtifactCache,new ProjectFilesystem(tmp.getRoot()),BuckEventBusFactory.newInstance(),false,0L,Optional.<Long>absent())){
    LazyPath dummyFile=LazyPath.ofInstance(tmp.newFile());
    twoLevelCache.store(ArtifactInfo.builder().addRuleKeys(dummyRuleKey).build(),BorrowablePath.notBorrowablePath(dummyFile.get()));
    assertThat(inMemoryArtifactCache.getArtifactCount(),Matchers.equalTo(2));
    assertThat(twoLevelCacheNoStore.fetch(dummyRuleKey,dummyFile).getType(),Matchers.equalTo(CacheResultType.HIT));
  }
 }
Program: 53071
Project: 53071
Buggy source:
@Test public void testCacheFetch() throws InterruptedException, IOException {
  try (InMemoryArtifactCache inMemoryArtifactCache=new InMemoryArtifactCache();TwoLevelArtifactCacheDecorator twoLevelCache=new TwoLevelArtifactCacheDecorator(inMemoryArtifactCache,new ProjectFilesystem(tmp.getRoot()),BuckEventBusFactory.newInstance(),MoreExecutors.newDirectExecutorService(),true,0L,Optional.<Long>absent())){
    LazyPath dummyFile=LazyPath.ofInstance(tmp.newFile());
    assertThat(twoLevelCache.fetch(dummyRuleKey,dummyFile).getType(),Matchers.equalTo(CacheResultType.MISS));
    twoLevelCache.store(ArtifactInfo.builder().addRuleKeys(dummyRuleKey).build(),BorrowablePath.notBorrowablePath(dummyFile.get()));
    assertThat(twoLevelCache.fetch(dummyRuleKey,dummyFile).getType(),Matchers.equalTo(CacheResultType.HIT));
    twoLevelCache.store(ArtifactInfo.builder().addRuleKeys(dummyRuleKey2).build(),BorrowablePath.notBorrowablePath(dummyFile.get()));
    assertThat(twoLevelCache.fetch(dummyRuleKey2,dummyFile).getType(),Matchers.equalTo(CacheResultType.HIT));
    assertThat(inMemoryArtifactCache.getArtifactCount(),Matchers.equalTo(3));
  }
 }

Fixed version (ground truth):
@Test public void testCacheFetch() throws InterruptedException, IOException {
  try (InMemoryArtifactCache inMemoryArtifactCache=new InMemoryArtifactCache();TwoLevelArtifactCacheDecorator twoLevelCache=new TwoLevelArtifactCacheDecorator(inMemoryArtifactCache,new ProjectFilesystem(tmp.getRoot()),BuckEventBusFactory.newInstance(),true,0L,Optional.<Long>absent())){
    LazyPath dummyFile=LazyPath.ofInstance(tmp.newFile());
    assertThat(twoLevelCache.fetch(dummyRuleKey,dummyFile).getType(),Matchers.equalTo(CacheResultType.MISS));
    twoLevelCache.store(ArtifactInfo.builder().addRuleKeys(dummyRuleKey).build(),BorrowablePath.notBorrowablePath(dummyFile.get()));
    assertThat(twoLevelCache.fetch(dummyRuleKey,dummyFile).getType(),Matchers.equalTo(CacheResultType.HIT));
    twoLevelCache.store(ArtifactInfo.builder().addRuleKeys(dummyRuleKey2).build(),BorrowablePath.notBorrowablePath(dummyFile.get()));
    assertThat(twoLevelCache.fetch(dummyRuleKey2,dummyFile).getType(),Matchers.equalTo(CacheResultType.HIT));
    assertThat(inMemoryArtifactCache.getArtifactCount(),Matchers.equalTo(3));
  }
 }