Program: 59666
Project: 59666
Buggy source:
/** 
 * Check that the topology builds up as expected even when the root task is added after child tasks start running.
 */
@Test public void testLateRootTask() throws InterruptedException {
  final String rootTaskId="String_Node_Str";
  final String[] childTaskIds=new String[]{"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",4,2);
  communicationGroupDriver.addBroadcast(BroadcastOperatorName.class,BroadcastOperatorSpec.newBuilder().setSenderId(rootTaskId).build()).addReduce(ReduceOperatorName.class,ReduceOperatorSpec.newBuilder().setReceiverId(rootTaskId).build());
  final ExecutorService pool=Executors.newFixedThreadPool(4);
  final CountDownLatch countDownLatch=new CountDownLatch(4);
  for (int index=0; index < 3; 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();
    }
  }
);
  pool.shutdown();
  final boolean allThreadsFinished=countDownLatch.await(10,TimeUnit.SECONDS);
  assertTrue("String_Node_Str",allThreadsFinished);
  assertEquals("String_Node_Str",12,numMsgs.get());
}

Fixed version (ground truth):
/** 
 * Check that the topology builds up as expected even when the root task is added after child tasks start running.
 */
@Test public void testLateRootTask() throws InterruptedException {
  final String rootTaskId="String_Node_Str";
  final String[] childTaskIds=new String[]{"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",4,2);
  communicationGroupDriver.addBroadcast(BroadcastOperatorName.class,BroadcastOperatorSpec.newBuilder().setSenderId(rootTaskId).build()).addReduce(ReduceOperatorName.class,ReduceOperatorSpec.newBuilder().setReceiverId(rootTaskId).build());
  final ExecutorService pool=Executors.newFixedThreadPool(4);
  final CountDownLatch countDownLatch=new CountDownLatch(4);
  for (int index=0; index < 3; 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();
    }
  }
);
  pool.shutdown();
  final boolean allThreadsFinished=countDownLatch.await(10,TimeUnit.SECONDS);
  assertTrue("String_Node_Str",allThreadsFinished);
  assertEquals("String_Node_Str",12,numMsgs.get());
}