Program: 53127
Project: 53127
Buggy source:
private TargetGraph buildTargetGraphSerially(final BuckEventBus eventBus,final Cell rootCell,final boolean enableProfiling,final Iterable<BuildTarget> toExplore) throws IOException, InterruptedException, BuildFileParseException {
  final MutableDirectedGraph<TargetNode<?>> graph=new MutableDirectedGraph<>();
  final Map<BuildTarget,TargetNode<?>> index=new HashMap<>();
  ParseEvent.Started parseStart=ParseEvent.started(toExplore);
  eventBus.post(parseStart);
  TargetGraph targetGraph=null;
  try (final PerBuildState state=new SerialPerBuildState(permState,marshaller,eventBus,rootCell,enableProfiling)){
    final AbstractAcyclicDepthFirstPostOrderTraversal<BuildTarget> traversal=new AbstractAcyclicDepthFirstPostOrderTraversal<BuildTarget>(){
      @Override protected Iterator<BuildTarget> findChildren(      BuildTarget target) throws IOException, InterruptedException {
        try (SimplePerfEvent.Scope getTargetDepsEventScope=SimplePerfEvent.scope(eventBus,PerfEventId.of("String_Node_Str"),"String_Node_Str",target)){
          TargetNode<?> node;
          try (SimplePerfEvent.Scope scope=getTargetNodeEventScope(eventBus,target)){
            try {
              node=state.getTargetNode(target);
            }
 catch (            BuildFileParseException|BuildTargetException e) {
              throw new RuntimeException(e);
            }
          }
           Set<BuildTarget> deps=Sets.newHashSet();
          for (          BuildTarget dep : node.getDeps()) {
            TargetNode<?> depTargetNode;
            try (SimplePerfEvent.Scope scope=getTargetNodeEventScope(eventBus,dep)){
              try {
                depTargetNode=state.getTargetNode(dep);
              }
 catch (              BuildFileParseException|BuildTargetException|HumanReadableException e) {
                throw new HumanReadableException(e,"String_Node_Str",dep,target,e.getMessage());
              }
            }
             depTargetNode.checkVisibility(target);
            deps.add(dep);
          }
          return deps.iterator();
        }
       }
      @Override protected void onNodeExplored(      BuildTarget target) throws IOException, InterruptedException {
        try {
          TargetNode<?> targetNode=state.getTargetNode(target);
          Preconditions.checkNotNull(targetNode,"String_Node_Str",target);
          graph.addNode(targetNode);
          MoreMaps.putCheckEquals(index,target,targetNode);
          if (target.isFlavored()) {
            BuildTarget unflavoredTarget=BuildTarget.of(target.getUnflavoredBuildTarget());
            MoreMaps.putCheckEquals(index,unflavoredTarget,state.getTargetNode(unflavoredTarget));
          }
          for (          BuildTarget dep : targetNode.getDeps()) {
            graph.addEdge(targetNode,state.getTargetNode(dep));
          }
        }
 catch (        BuildFileParseException|BuildTargetException e) {
          throw new RuntimeException(e);
        }
      }
      @Override protected void onTraversalComplete(      Iterable<BuildTarget> nodesInExplorationOrder){
      }
    }
;
    traversal.traverse(toExplore);
    targetGraph=new TargetGraph(graph,ImmutableMap.copyOf(index));
    return targetGraph;
  }
 catch (  AbstractAcyclicDepthFirstPostOrderTraversal.CycleException e) {
    throw new HumanReadableException(e.getMessage());
  }
 finally {
    eventBus.post(ParseEvent.finished(parseStart,Optional.fromNullable(targetGraph)));
  }
}

Fixed version (ground truth):
private TargetGraph buildTargetGraphSerially(final BuckEventBus eventBus,final Cell rootCell,final boolean enableProfiling,final Iterable<BuildTarget> toExplore) throws IOException, InterruptedException, BuildFileParseException, BuildTargetException {
  final MutableDirectedGraph<TargetNode<?>> graph=new MutableDirectedGraph<>();
  final Map<BuildTarget,TargetNode<?>> index=new HashMap<>();
  ParseEvent.Started parseStart=ParseEvent.started(toExplore);
  eventBus.post(parseStart);
  TargetGraph targetGraph=null;
  try (final PerBuildState state=new SerialPerBuildState(permState,marshaller,eventBus,rootCell,enableProfiling)){
    final AbstractAcyclicDepthFirstPostOrderTraversal<BuildTarget> traversal=new AbstractAcyclicDepthFirstPostOrderTraversal<BuildTarget>(){
      @Override protected Iterator<BuildTarget> findChildren(      BuildTarget target) throws IOException, InterruptedException {
        try (SimplePerfEvent.Scope getTargetDepsEventScope=SimplePerfEvent.scope(eventBus,PerfEventId.of("String_Node_Str"),"String_Node_Str",target)){
          TargetNode<?> node;
          try (SimplePerfEvent.Scope scope=getTargetNodeEventScope(eventBus,target)){
            try {
              node=state.getTargetNode(target);
            }
 catch (            BuildFileParseException|BuildTargetException e) {
              throw new RuntimeException(e);
            }
          }
           Set<BuildTarget> deps=Sets.newHashSet();
          for (          BuildTarget dep : node.getDeps()) {
            TargetNode<?> depTargetNode;
            try (SimplePerfEvent.Scope scope=getTargetNodeEventScope(eventBus,dep)){
              try {
                depTargetNode=state.getTargetNode(dep);
              }
 catch (              BuildFileParseException|BuildTargetException|HumanReadableException e) {
                throw new HumanReadableException(e,"String_Node_Str",dep,target,e.getMessage());
              }
            }
             depTargetNode.checkVisibility(target);
            deps.add(dep);
          }
          return deps.iterator();
        }
       }
      @Override protected void onNodeExplored(      BuildTarget target) throws IOException, InterruptedException {
        try {
          TargetNode<?> targetNode=state.getTargetNode(target);
          Preconditions.checkNotNull(targetNode,"String_Node_Str",target);
          graph.addNode(targetNode);
          MoreMaps.putCheckEquals(index,target,targetNode);
          if (target.isFlavored()) {
            BuildTarget unflavoredTarget=BuildTarget.of(target.getUnflavoredBuildTarget());
            MoreMaps.putCheckEquals(index,unflavoredTarget,state.getTargetNode(unflavoredTarget));
          }
          for (          BuildTarget dep : targetNode.getDeps()) {
            graph.addEdge(targetNode,state.getTargetNode(dep));
          }
        }
 catch (        BuildFileParseException|BuildTargetException e) {
          throw new RuntimeException(e);
        }
      }
      @Override protected void onTraversalComplete(      Iterable<BuildTarget> nodesInExplorationOrder){
      }
    }
;
    traversal.traverse(toExplore);
    targetGraph=new TargetGraph(graph,ImmutableMap.copyOf(index));
    return targetGraph;
  }
 catch (  AbstractAcyclicDepthFirstPostOrderTraversal.CycleException e) {
    throw new HumanReadableException(e.getMessage());
  }
catch (  RuntimeException e) {
    throw propagateRuntimeCause(e);
  }
 finally {
    eventBus.post(ParseEvent.finished(parseStart,Optional.fromNullable(targetGraph)));
  }
}