Program: 37688
Project: 37688
Buggy source:
/** 
 * We attempt to consume from the topic and get our expected messages. We ack the messages each as we get it, in order, one by one.
 */
@Test public void testSimpleConsumeFromTopicWithAckingOutOfOrderAllAtTheEnd(){
  final int numberOfRecordsToProduce=9;
  final TopicPartition partition0=new TopicPartition(topicName,0);
  final List<ProducerRecord<byte[],byte[]>> producedRecords=produceRecords(numberOfRecordsToProduce);
  List<String> brokerHosts=Lists.newArrayList(kafkaTestServer.getKafkaServer().serverConfig().advertisedHostName() + "String_Node_Str" + kafkaTestServer.getKafkaServer().serverConfig().advertisedPort());
  SidelineConsumerConfig config=new SidelineConsumerConfig(brokerHosts,"String_Node_Str",topicName);
  config.setKafkaConsumerProperty("String_Node_Str","String_Node_Str");
  PersistenceManager persistenceManager=new InMemoryPersistenceManager();
  persistenceManager.open(Maps.newHashMap());
  SidelineConsumer sidelineConsumer=new SidelineConsumer(config,persistenceManager);
  sidelineConsumer.open(null);
  List<ConsumerRecord> foundRecords=Lists.newArrayList();
  for (int x=0; x < numberOfRecordsToProduce; x++) {
    ConsumerRecord<byte[],byte[]> foundRecord=sidelineConsumer.nextRecord();
    assertNotNull(foundRecord);
    foundRecords.add(foundRecord);
    ProducerRecord<byte[],byte[]> expectedRecord=producedRecords.get(x);
    logger.info("String_Node_Str",expectedRecord.key(),foundRecord.key());
    assertEquals("String_Node_Str",new String(expectedRecord.key(),Charsets.UTF_8),new String(foundRecord.key(),Charsets.UTF_8));
    assertEquals("String_Node_Str",new String(expectedRecord.value(),Charsets.UTF_8),new String(foundRecord.value(),Charsets.UTF_8));
  }
  logger.info("String_Node_Str",sidelineConsumer.flushConsumerState());
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,-1L);
  sidelineConsumer.commitOffset(partition0,2L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,-1L);
  sidelineConsumer.commitOffset(partition0,1L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,-1L);
  sidelineConsumer.commitOffset(partition0,0L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,2L);
  sidelineConsumer.commitOffset(partition0,3L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,3L);
  sidelineConsumer.commitOffset(partition0,4L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,4L);
  sidelineConsumer.commitOffset(partition0,5L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,5L);
  sidelineConsumer.commitOffset(partition0,7L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,5L);
  sidelineConsumer.commitOffset(partition0,8L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,5L);
  sidelineConsumer.commitOffset(partition0,6L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,8L);
  logger.info("String_Node_Str",sidelineConsumer.flushConsumerState());
  sidelineConsumer.close();
}

Fixed version (ground truth):
/** 
 * We attempt to consume from the topic and get our expected messages. We ack the messages each as we get it, in order, one by one.
 */
@Test public void testSimpleConsumeFromTopicWithAckingOutOfOrderAllAtTheEnd(){
  final int numberOfRecordsToProduce=9;
  final TopicPartition partition0=new TopicPartition(topicName,0);
  final List<ProducerRecord<byte[],byte[]>> producedRecords=produceRecords(numberOfRecordsToProduce);
  List<String> brokerHosts=Lists.newArrayList(kafkaTestServer.getKafkaServer().serverConfig().advertisedHostName() + "String_Node_Str" + kafkaTestServer.getKafkaServer().serverConfig().advertisedPort());
  SidelineConsumerConfig config=new SidelineConsumerConfig(brokerHosts,"String_Node_Str",topicName);
  PersistenceManager persistenceManager=new InMemoryPersistenceManager();
  persistenceManager.open(Maps.newHashMap());
  SidelineConsumer sidelineConsumer=new SidelineConsumer(config,persistenceManager);
  sidelineConsumer.open(null);
  List<ConsumerRecord> foundRecords=Lists.newArrayList();
  for (int x=0; x < numberOfRecordsToProduce; x++) {
    ConsumerRecord<byte[],byte[]> foundRecord=sidelineConsumer.nextRecord();
    assertNotNull(foundRecord);
    foundRecords.add(foundRecord);
    ProducerRecord<byte[],byte[]> expectedRecord=producedRecords.get(x);
    logger.info("String_Node_Str",expectedRecord.key(),foundRecord.key());
    assertEquals("String_Node_Str",new String(expectedRecord.key(),Charsets.UTF_8),new String(foundRecord.key(),Charsets.UTF_8));
    assertEquals("String_Node_Str",new String(expectedRecord.value(),Charsets.UTF_8),new String(foundRecord.value(),Charsets.UTF_8));
  }
  logger.info("String_Node_Str",sidelineConsumer.flushConsumerState());
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,-1L);
  sidelineConsumer.commitOffset(partition0,2L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,-1L);
  sidelineConsumer.commitOffset(partition0,1L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,-1L);
  sidelineConsumer.commitOffset(partition0,0L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,2L);
  sidelineConsumer.commitOffset(partition0,3L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,3L);
  sidelineConsumer.commitOffset(partition0,4L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,4L);
  sidelineConsumer.commitOffset(partition0,5L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,5L);
  sidelineConsumer.commitOffset(partition0,7L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,5L);
  sidelineConsumer.commitOffset(partition0,8L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,5L);
  sidelineConsumer.commitOffset(partition0,6L);
  validateConsumerState(sidelineConsumer.flushConsumerState(),partition0,8L);
  logger.info("String_Node_Str",sidelineConsumer.flushConsumerState());
  sidelineConsumer.close();
}