Program: 37682
Project: 37682
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 testSimpleConsumeFromTopicWithAckingInOrderAllAtTheEnd(){
  final int numberOfRecordsToProduce=5;
  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);
  for (  ConsumerRecord foundRecord : foundRecords) {
    sidelineConsumer.commitOffset(foundRecord);
  }
  ConsumerState consumerState=sidelineConsumer.flushConsumerState();
  validateConsumerState(consumerState,partition0,(numberOfRecordsToProduce - 1));
  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 testSimpleConsumeFromTopicWithAckingInOrderAllAtTheEnd(){
  final int numberOfRecordsToProduce=5;
  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);
  for (  ConsumerRecord foundRecord : foundRecords) {
    sidelineConsumer.commitOffset(foundRecord);
  }
  ConsumerState consumerState=sidelineConsumer.flushConsumerState();
  validateConsumerState(consumerState,partition0,(numberOfRecordsToProduce - 1));
  logger.info("String_Node_Str",sidelineConsumer.flushConsumerState());
  sidelineConsumer.close();
}