Program: 59667
Project: 59667
Buggy source:
/** 
 * Checks that TreeTopology works correctly with the following task add sequence: child -> root -> child.
 */
@Test public void testLateRootAndChildTask() throws InterruptedException {
  final String rootTaskId="String_Node_Str";
  final String[] childTaskIds=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  final AtomicInteger numMsgs=new AtomicInteger(0);
  final EStage<GroupCommunicationMessage> senderStage=new ThreadPoolStage<>(new EventHandler<GroupCommunicationMessage>(){
    @Override public void onNext(    final GroupCommunicationMessage msg){
      numMsgs.getAndIncrement();
    }
  }
,1);
  final CommunicationGroupDriverImpl communicationGroupDriver=new CommunicationGroupDriverImpl(GroupName.class,new AvroConfigurationSerializer(),senderStage,new BroadcastingEventHandler<RunningTask>(),new BroadcastingEventHandler<FailedTask>(),new BroadcastingEventHandler<FailedEvaluator>(),new BroadcastingEventHandler<GroupCommunicationMessage>(),"String_Node_Str",8,2);
  communicationGroupDriver.addBroadcast(BroadcastOperatorName.class,BroadcastOperatorSpec.newBuilder().setSenderId(rootTaskId).build()).addReduce(ReduceOperatorName.class,ReduceOperatorSpec.newBuilder().setReceiverId(rootTaskId).build());
  final ExecutorService pool=Executors.newFixedThreadPool(8);
  final CountDownLatch countDownLatch=new CountDownLatch(8);
  for (int index=0; index < 2; index++) {
    final String childId=childTaskIds[index];
    pool.submit(new Runnable(){
      @Override public void run(){
        final Configuration childTaskConf=TaskConfiguration.CONF.set(TaskConfiguration.IDENTIFIER,childId).set(TaskConfiguration.TASK,DummyTask.class).build();
        communicationGroupDriver.addTask(childTaskConf);
        communicationGroupDriver.runTask(childId);
        countDownLatch.countDown();
      }
    }
);
  }
  pool.submit(new Runnable(){
    @Override public void run(){
      try {
        Thread.sleep(3000);
      }
 catch (      final InterruptedException e) {
        throw new RuntimeException(e);
      }
      final Configuration rootTaskConf=TaskConfiguration.CONF.set(TaskConfiguration.IDENTIFIER,rootTaskId).set(TaskConfiguration.TASK,DummyTask.class).build();
      communicationGroupDriver.addTask(rootTaskConf);
      communicationGroupDriver.runTask(rootTaskId);
      countDownLatch.countDown();
    }
  }
);
  for (int index=2; index < 7; index++) {
    final String childId=childTaskIds[index];
    pool.submit(new Runnable(){
      @Override public void run(){
        try {
          Thread.sleep(6000);
        }
 catch (        final InterruptedException e) {
          throw new RuntimeException(e);
        }
        final Configuration childTaskConf=TaskConfiguration.CONF.set(TaskConfiguration.IDENTIFIER,childId).set(TaskConfiguration.TASK,DummyTask.class).build();
        communicationGroupDriver.addTask(childTaskConf);
        communicationGroupDriver.runTask(childId);
        countDownLatch.countDown();
      }
    }
);
  }
  pool.shutdown();
  final boolean allThreadsFinished=countDownLatch.await(10,TimeUnit.SECONDS);
  assertTrue("String_Node_Str",allThreadsFinished);
  assertEquals("String_Node_Str",28,numMsgs.get());
}

Fixed version (ground truth):
/** 
 * Checks that TreeTopology works correctly with the following task add sequence: child -> root -> child.
 */
@Test public void testLateRootAndChildTask() throws InterruptedException {
  final String rootTaskId="String_Node_Str";
  final String[] childTaskIds=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  final AtomicInteger numMsgs=new AtomicInteger(0);
  final EStage<GroupCommunicationMessage> senderStage=new SyncStage<>(new EventHandler<GroupCommunicationMessage>(){
    @Override public void onNext(    final GroupCommunicationMessage msg){
      numMsgs.getAndIncrement();
    }
  }
);
  final CommunicationGroupDriverImpl communicationGroupDriver=new CommunicationGroupDriverImpl(GroupName.class,new AvroConfigurationSerializer(),senderStage,new BroadcastingEventHandler<RunningTask>(),new BroadcastingEventHandler<FailedTask>(),new BroadcastingEventHandler<FailedEvaluator>(),new BroadcastingEventHandler<GroupCommunicationMessage>(),"String_Node_Str",8,2);
  communicationGroupDriver.addBroadcast(BroadcastOperatorName.class,BroadcastOperatorSpec.newBuilder().setSenderId(rootTaskId).build()).addReduce(ReduceOperatorName.class,ReduceOperatorSpec.newBuilder().setReceiverId(rootTaskId).build());
  final ExecutorService pool=Executors.newFixedThreadPool(8);
  final CountDownLatch countDownLatch=new CountDownLatch(8);
  for (int index=0; index < 2; index++) {
    final String childId=childTaskIds[index];
    pool.submit(new Runnable(){
      @Override public void run(){
        final Configuration childTaskConf=TaskConfiguration.CONF.set(TaskConfiguration.IDENTIFIER,childId).set(TaskConfiguration.TASK,DummyTask.class).build();
        communicationGroupDriver.addTask(childTaskConf);
        communicationGroupDriver.runTask(childId);
        countDownLatch.countDown();
      }
    }
);
  }
  pool.submit(new Runnable(){
    @Override public void run(){
      try {
        Thread.sleep(3000);
      }
 catch (      final InterruptedException e) {
        throw new RuntimeException(e);
      }
      final Configuration rootTaskConf=TaskConfiguration.CONF.set(TaskConfiguration.IDENTIFIER,rootTaskId).set(TaskConfiguration.TASK,DummyTask.class).build();
      communicationGroupDriver.addTask(rootTaskConf);
      communicationGroupDriver.runTask(rootTaskId);
      countDownLatch.countDown();
    }
  }
);
  for (int index=2; index < 7; index++) {
    final String childId=childTaskIds[index];
    pool.submit(new Runnable(){
      @Override public void run(){
        try {
          Thread.sleep(6000);
        }
 catch (        final InterruptedException e) {
          throw new RuntimeException(e);
        }
        final Configuration childTaskConf=TaskConfiguration.CONF.set(TaskConfiguration.IDENTIFIER,childId).set(TaskConfiguration.TASK,DummyTask.class).build();
        communicationGroupDriver.addTask(childTaskConf);
        communicationGroupDriver.runTask(childId);
        countDownLatch.countDown();
      }
    }
);
  }
  pool.shutdown();
  final boolean allThreadsFinished=countDownLatch.await(10,TimeUnit.SECONDS);
  assertTrue("String_Node_Str",allThreadsFinished);
  assertEquals("String_Node_Str",28,numMsgs.get());
}