Program: 53122
Project: 53122
Buggy source:
private int doShowTargetHash(CommandRunnerParams params,Executor executor,ImmutableSet<BuildTarget> matchingBuildTargets,TargetGraph targetGraph) throws IOException, InterruptedException, BuildFileParseException {
  LOG.debug("String_Node_Str",matchingBuildTargets);
  Iterable<BuildTarget> matchingBuildTargetsWithTests;
  final TargetGraph targetGraphWithTests;
  if (isDetectTestChanges()) {
    ImmutableSet<BuildTarget> explicitTestTargets;
    explicitTestTargets=TargetGraphAndTargets.getExplicitTestTargets(matchingBuildTargets,targetGraph,true);
    LOG.debug("String_Node_Str",explicitTestTargets);
    matchingBuildTargetsWithTests=Sets.union(matchingBuildTargets,explicitTestTargets);
    targetGraphWithTests=params.getParser().buildTargetGraph(params.getBuckEventBus(),params.getCell(),getEnableProfiling(),executor,matchingBuildTargetsWithTests);
  }
 else {
    matchingBuildTargetsWithTests=matchingBuildTargets;
    targetGraphWithTests=targetGraph;
  }
  TargetHashFileMode targetHashFileMode=getTargetHashFileMode();
  FileHashLoader fileHashLoader=null;
switch (targetHashFileMode) {
case PATHS_AND_CONTENTS:
    fileHashLoader=params.getFileHashCache();
  break;
case PATHS_ONLY:
fileHashLoader=new FilePathHashLoader(params.getCell().getRoot(),getTargetHashModifiedPaths());
break;
}
if (fileHashLoader == null) {
throw new IllegalStateException("String_Node_Str" + targetHashFileMode);
}
ImmutableMap<BuildTarget,HashCode> buildTargetHashes=TargetGraphHashing.hashTargetGraph(params.getCell().getFilesystem(),targetGraphWithTests,fileHashLoader,matchingBuildTargetsWithTests);
for (BuildTarget target : matchingBuildTargets) {
TargetNode<?> targetNode=Preconditions.checkNotNull(targetGraphWithTests.get(target),"String_Node_Str",target);
ImmutableSet<TargetNode<?>> dependencyClosure=getDependencyClosure(targetGraphWithTests,targetNode);
Hasher hasher=Hashing.sha1().newHasher();
ImmutableSortedSet.Builder<TargetNode<?>> nodesWithDepsAndTests=ImmutableSortedSet.naturalOrder();
nodesWithDepsAndTests.addAll(dependencyClosure);
if (isDetectTestChanges()) {
nodesWithDepsAndTests.addAll(FluentIterable.from(dependencyClosure).transformAndConcat(new Function<TargetNode<?>,Iterable<TargetNode<?>>>(){
@Override public Iterable<TargetNode<?>> apply(TargetNode<?> node){
  return targetGraphWithTests.getAll(TargetNodes.getTestTargetsForNode(node));
}
}
));
}
LOG.debug("String_Node_Str",target,nodesWithDepsAndTests.build());
for (TargetNode<?> nodeToHash : nodesWithDepsAndTests.build()) {
HashCode dependencyHash=buildTargetHashes.get(nodeToHash.getBuildTarget());
Preconditions.checkNotNull(dependencyHash,"String_Node_Str",nodeToHash);
hasher.putBytes(dependencyHash.asBytes());
}
params.getConsole().getStdOut().format("String_Node_Str",target.getFullyQualifiedName(),hasher.hash().toString());
}
return 0;
}

Fixed version (ground truth):
private int doShowTargetHash(CommandRunnerParams params,Executor executor,ImmutableSet<BuildTarget> matchingBuildTargets,TargetGraph targetGraph) throws IOException, InterruptedException, BuildFileParseException, BuildTargetException {
  LOG.debug("String_Node_Str",matchingBuildTargets);
  Iterable<BuildTarget> matchingBuildTargetsWithTests;
  final TargetGraph targetGraphWithTests;
  if (isDetectTestChanges()) {
    ImmutableSet<BuildTarget> explicitTestTargets;
    explicitTestTargets=TargetGraphAndTargets.getExplicitTestTargets(matchingBuildTargets,targetGraph,true);
    LOG.debug("String_Node_Str",explicitTestTargets);
    matchingBuildTargetsWithTests=Sets.union(matchingBuildTargets,explicitTestTargets);
    targetGraphWithTests=params.getParser().buildTargetGraph(params.getBuckEventBus(),params.getCell(),getEnableProfiling(),executor,matchingBuildTargetsWithTests);
  }
 else {
    matchingBuildTargetsWithTests=matchingBuildTargets;
    targetGraphWithTests=targetGraph;
  }
  TargetHashFileMode targetHashFileMode=getTargetHashFileMode();
  FileHashLoader fileHashLoader=null;
switch (targetHashFileMode) {
case PATHS_AND_CONTENTS:
    fileHashLoader=params.getFileHashCache();
  break;
case PATHS_ONLY:
fileHashLoader=new FilePathHashLoader(params.getCell().getRoot(),getTargetHashModifiedPaths());
break;
}
if (fileHashLoader == null) {
throw new IllegalStateException("String_Node_Str" + targetHashFileMode);
}
ImmutableMap<BuildTarget,HashCode> buildTargetHashes=TargetGraphHashing.hashTargetGraph(params.getCell().getFilesystem(),targetGraphWithTests,fileHashLoader,matchingBuildTargetsWithTests);
for (BuildTarget target : matchingBuildTargets) {
TargetNode<?> targetNode=Preconditions.checkNotNull(targetGraphWithTests.get(target),"String_Node_Str",target);
ImmutableSet<TargetNode<?>> dependencyClosure=getDependencyClosure(targetGraphWithTests,targetNode);
Hasher hasher=Hashing.sha1().newHasher();
ImmutableSortedSet.Builder<TargetNode<?>> nodesWithDepsAndTests=ImmutableSortedSet.naturalOrder();
nodesWithDepsAndTests.addAll(dependencyClosure);
if (isDetectTestChanges()) {
nodesWithDepsAndTests.addAll(FluentIterable.from(dependencyClosure).transformAndConcat(new Function<TargetNode<?>,Iterable<TargetNode<?>>>(){
@Override public Iterable<TargetNode<?>> apply(TargetNode<?> node){
  return targetGraphWithTests.getAll(TargetNodes.getTestTargetsForNode(node));
}
}
));
}
LOG.debug("String_Node_Str",target,nodesWithDepsAndTests.build());
for (TargetNode<?> nodeToHash : nodesWithDepsAndTests.build()) {
HashCode dependencyHash=buildTargetHashes.get(nodeToHash.getBuildTarget());
Preconditions.checkNotNull(dependencyHash,"String_Node_Str",nodeToHash);
hasher.putBytes(dependencyHash.asBytes());
}
params.getConsole().getStdOut().format("String_Node_Str",target.getFullyQualifiedName(),hasher.hash().toString());
}
return 0;
}