Program: 52855
Project: 52855
Buggy source:
@Test public void testThriftServerWithDiamondGraph() throws IOException, NoSuchBuildTargetException {
  int port=findRandomOpenPortOnAllLocalInterfaces();
  BuildTargetsQueue diamondQueue=BuildTargetsQueueTest.createDiamondDependencyQueue();
  ThriftCoordinatorServer.EventListener eventListener=EasyMock.createMock(ThriftCoordinatorServer.EventListener.class);
  eventListener.onThriftServerStarted(EasyMock.anyString(),EasyMock.eq(port));
  EasyMock.expectLastCall().once();
  eventListener.onThriftServerClosing(0);
  EasyMock.expectLastCall().once();
  EasyMock.replay(eventListener);
  try (ThriftCoordinatorServer server=createCoordinatorServer(port,diamondQueue,eventListener);ThriftCoordinatorClient client=new ThriftCoordinatorClient("String_Node_Str",port,STAMPEDE_ID)){
    server.start();
    client.start();
    GetWorkResponse responseOne=client.getWork(MINION_ID,0,ImmutableList.of(),MAX_WORK_UNITS_TO_FETCH);
    Assert.assertEquals(responseOne.getWorkUnitsSize(),1);
    Assert.assertTrue(responseOne.isContinueBuilding());
    GetWorkResponse responseTwo=client.getWork(MINION_ID,0,ImmutableList.of(BuildTargetsQueueTest.LEAF_TARGET),MAX_WORK_UNITS_TO_FETCH);
    Assert.assertEquals(responseTwo.getWorkUnitsSize(),2);
    Assert.assertTrue(responseTwo.isContinueBuilding());
    GetWorkResponse responseThree=client.getWork(MINION_ID,0,ImmutableList.of(BuildTargetsQueueTest.LEFT_TARGET,BuildTargetsQueueTest.RIGHT_TARGET),MAX_WORK_UNITS_TO_FETCH);
    Assert.assertEquals(responseThree.getWorkUnitsSize(),1);
    Assert.assertTrue(responseThree.isContinueBuilding());
    GetWorkResponse responseFour=client.getWork(MINION_ID,0,ImmutableList.of(BuildTargetsQueueTest.TARGET_NAME),MAX_WORK_UNITS_TO_FETCH);
    Assert.assertEquals(responseFour.getWorkUnitsSize(),0);
    Assert.assertFalse(responseFour.isContinueBuilding());
  }
   EasyMock.verify(eventListener);
}

Fixed version (ground truth):
@Test public void testThriftServerWithDiamondGraph() throws IOException, NoSuchBuildTargetException {
  int port=findRandomOpenPortOnAllLocalInterfaces();
  BuildTargetsQueue diamondQueue=BuildTargetsQueueTest.createDiamondDependencyQueue();
  ThriftCoordinatorServer.EventListener eventListener=EasyMock.createMock(ThriftCoordinatorServer.EventListener.class);
  eventListener.onThriftServerStarted(EasyMock.anyString(),EasyMock.eq(port));
  EasyMock.expectLastCall().once();
  eventListener.onThriftServerClosing(0);
  EasyMock.expectLastCall().once();
  EasyMock.replay(eventListener);
  try (ThriftCoordinatorServer server=createCoordinatorServer(port,diamondQueue,eventListener);ThriftCoordinatorClient client=new ThriftCoordinatorClient("String_Node_Str",port,STAMPEDE_ID)){
    server.start();
    client.start();
    GetWorkResponse responseOne=client.getWork(MINION_ID,0,ImmutableList.of(),MAX_WORK_UNITS_TO_FETCH);
    Assert.assertEquals(responseOne.getWorkUnitsSize(),1);
    Assert.assertTrue(responseOne.isContinueBuilding());
    GetWorkResponse responseTwo=client.getWork(MINION_ID,0,ImmutableList.of(BuildTargetsQueueTest.LEAF_TARGET),MAX_WORK_UNITS_TO_FETCH);
    Assert.assertEquals(responseTwo.getWorkUnitsSize(),2);
    Assert.assertTrue(responseTwo.isContinueBuilding());
    GetWorkResponse responseThree=client.getWork(MINION_ID,0,ImmutableList.of(BuildTargetsQueueTest.LEFT_TARGET,BuildTargetsQueueTest.RIGHT_TARGET),MAX_WORK_UNITS_TO_FETCH);
    Assert.assertEquals(responseThree.getWorkUnitsSize(),1);
    Assert.assertTrue(responseThree.isContinueBuilding());
    GetWorkResponse responseFour=client.getWork(MINION_ID,0,ImmutableList.of(BuildTargetsQueueTest.TARGET_NAME),MAX_WORK_UNITS_TO_FETCH);
    Assert.assertEquals(responseFour.getWorkUnitsSize(),0);
    Assert.assertFalse(responseFour.isContinueBuilding());
    GetWorkResponse responseFive=client.getWork(MINION_ID,0,ImmutableList.of(BuildTargetsQueueTest.TARGET_NAME),MAX_WORK_UNITS_TO_FETCH);
    Assert.assertEquals(responseFive.getWorkUnitsSize(),0);
    Assert.assertFalse(responseFive.isContinueBuilding());
  }
   EasyMock.verify(eventListener);
}