Program: 37678
Project: 37678
Buggy source:
/** 
 * Handles connecting to the Kafka cluster, determining which partitions to subscribe to, and based on previously saved state from ConsumerStateManager, seek to the last positions processed on each partition. Warning: Consumes from ALL partitions.
 * @param startingState Starting state of the consumer
 * @param partitions The partitions to consume from
 */
public void open(ConsumerState startingState,List<PartitionInfo> partitions){
  if (isOpen) {
    throw new RuntimeException("String_Node_Str");
  }
  isOpen=true;
  if (startingState != null) {
    persistenceManager.persistConsumerState(getConsumerId(),startingState);
  }
  ConsumerState initialState=persistenceManager.retrieveConsumerState(getConsumerId());
  if (initialState == null) {
    initialState=new ConsumerState();
  }
  final KafkaConsumer kafkaConsumer=getKafkaConsumer();
  List<TopicPartition> allTopicPartitions=Lists.newArrayList();
  for (  PartitionInfo partition : partitions) {
    allTopicPartitions.add(new TopicPartition(partition.topic(),partition.partition()));
  }
  kafkaConsumer.assign(allTopicPartitions);
  List<TopicPartition> noStatePartitions=Lists.newArrayList();
  for (  PartitionInfo partition : partitions) {
    final TopicPartition availableTopicPartition=new TopicPartition(partition.topic(),partition.partition());
    Long offset=initialState.getOffsetForTopicAndPartition(availableTopicPartition);
    if (offset == null) {
      noStatePartitions.add(availableTopicPartition);
      offset=-1L;
    }
 else {
      logger.info("String_Node_Str",availableTopicPartition.topic(),availableTopicPartition.partition(),(offset + 1));
      kafkaConsumer.seek(availableTopicPartition,offset + 1);
      logger.info("String_Node_Str",kafkaConsumer.position(availableTopicPartition));
    }
    partitionStateManagers.put(availableTopicPartition,new PartitionOffsetManager(availableTopicPartition.topic(),availableTopicPartition.partition(),offset));
  }
  if (!noStatePartitions.isEmpty()) {
    logger.info("String_Node_Str",noStatePartitions);
    kafkaConsumer.seekToBeginning(noStatePartitions);
  }
}

Fixed version (ground truth):
/** 
 * Handles connecting to the Kafka cluster, determining which partitions to subscribe to, and based on previously saved state from ConsumerStateManager, seek to the last positions processed on each partition. Warning: Consumes from ALL partitions.
 * @param startingState Starting state of the consumer
 * @param partitions The partitions to consume from
 */
public void open(ConsumerState startingState,List<PartitionInfo> partitions){
  if (isOpen) {
    throw new RuntimeException("String_Node_Str");
  }
  isOpen=true;
  if (startingState != null) {
    persistenceManager.persistConsumerState(getConsumerId(),startingState);
  }
  ConsumerState initialState=persistenceManager.retrieveConsumerState(getConsumerId());
  if (initialState == null) {
    initialState=new ConsumerState();
  }
  final KafkaConsumer kafkaConsumer=getKafkaConsumer();
  List<TopicPartition> allTopicPartitions=Lists.newArrayList();
  for (  PartitionInfo partition : partitions) {
    allTopicPartitions.add(new TopicPartition(partition.topic(),partition.partition()));
  }
  kafkaConsumer.assign(allTopicPartitions);
  List<TopicPartition> noStatePartitions=Lists.newArrayList();
  for (  PartitionInfo partition : partitions) {
    final TopicPartition availableTopicPartition=new TopicPartition(partition.topic(),partition.partition());
    Long offset=initialState.getOffsetForTopicAndPartition(availableTopicPartition);
    if (offset == null) {
      noStatePartitions.add(availableTopicPartition);
    }
 else {
      logger.info("String_Node_Str",availableTopicPartition.topic(),availableTopicPartition.partition(),(offset + 1));
      getKafkaConsumer().seek(availableTopicPartition,offset + 1);
      logger.info("String_Node_Str",kafkaConsumer.position(availableTopicPartition));
      partitionStateManagers.put(availableTopicPartition,new PartitionOffsetManager(availableTopicPartition.topic(),availableTopicPartition.partition(),offset));
    }
  }
  if (!noStatePartitions.isEmpty()) {
    logger.info("String_Node_Str",noStatePartitions);
    resetPartitionsToEarliest(noStatePartitions);
  }
}