Program: 92951
Project: 92951
Buggy source:
/** 
 * Performs one iteration of reading from a consumer iterator.
 * @return true if this read timed out, indicating the scheduler should back off
 */
public boolean doPartialRead(){
  try {
    if (iter == null) {
      parent.startRead(topicState);
      iter=topicState.getIterator();
      messages=new Vector<ConsumerRecord<ClientK,ClientV>>();
      waitExpiration=0;
    }
    boolean backoff=false;
    long startedIteration=parent.getConfig().getTime().milliseconds();
    final int requestTimeoutMs=parent.getConfig().getInt(KafkaRestConfig.CONSUMER_REQUEST_TIMEOUT_MS_CONFIG);
    try {
      while (iter.hasNext()) {
        MessageAndMetadata<KafkaK,KafkaV> msg=iter.peek();
        ConsumerRecordAndSize<ClientK,ClientV> recordAndSize=parent.createConsumerRecord(msg);
        long roughMsgSize=recordAndSize.getSize();
        if (bytesConsumed + roughMsgSize > maxResponseBytes) {
          break;
        }
        iter.next();
        messages.add(recordAndSize.getRecord());
        bytesConsumed+=roughMsgSize;
      }
    }
 catch (    ConsumerTimeoutException cte) {
      backoff=true;
    }
    long now=parent.getConfig().getTime().milliseconds();
    long elapsed=now - started;
    int itbackoff=parent.getConfig().getInt(KafkaRestConfig.CONSUMER_ITERATOR_BACKOFF_MS_CONFIG);
    long backoffExpiration=startedIteration + itbackoff;
    long requestExpiration=started + parent.getConfig().getInt(KafkaRestConfig.CONSUMER_REQUEST_TIMEOUT_MS_CONFIG);
    waitExpiration=Math.min(backoffExpiration,requestExpiration);
    if (elapsed >= requestTimeoutMs || bytesConsumed >= maxResponseBytes) {
      finish();
    }
    return backoff;
  }
 catch (  Exception e) {
    finish(e);
    log.error("String_Node_Str",e);
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Performs one iteration of reading from a consumer iterator.
 * @return true if this read timed out, indicating the scheduler should back off
 */
public boolean doPartialRead(){
  try {
    if (iter == null) {
      parent.startRead(topicState);
      iter=topicState.getIterator();
      messages=new Vector<ConsumerRecord<ClientK,ClientV>>();
      waitExpiration=0;
    }
    boolean backoff=false;
    long roughMsgSize=0;
    long startedIteration=parent.getConfig().getTime().milliseconds();
    final int requestTimeoutMs=parent.getConfig().getInt(KafkaRestConfig.CONSUMER_REQUEST_TIMEOUT_MS_CONFIG);
    try {
      while (iter.hasNext()) {
        MessageAndMetadata<KafkaK,KafkaV> msg=iter.peek();
        ConsumerRecordAndSize<ClientK,ClientV> recordAndSize=parent.createConsumerRecord(msg);
        roughMsgSize=recordAndSize.getSize();
        if (bytesConsumed + roughMsgSize >= maxResponseBytes) {
          break;
        }
        iter.next();
        messages.add(recordAndSize.getRecord());
        bytesConsumed+=roughMsgSize;
      }
    }
 catch (    ConsumerTimeoutException cte) {
      backoff=true;
    }
    long now=parent.getConfig().getTime().milliseconds();
    long elapsed=now - started;
    int itbackoff=parent.getConfig().getInt(KafkaRestConfig.CONSUMER_ITERATOR_BACKOFF_MS_CONFIG);
    long backoffExpiration=startedIteration + itbackoff;
    long requestExpiration=started + parent.getConfig().getInt(KafkaRestConfig.CONSUMER_REQUEST_TIMEOUT_MS_CONFIG);
    waitExpiration=Math.min(backoffExpiration,requestExpiration);
    if (elapsed >= requestTimeoutMs || bytesConsumed + roughMsgSize >= maxResponseBytes) {
      finish();
    }
    return backoff;
  }
 catch (  Exception e) {
    finish(e);
    log.error("String_Node_Str",e);
    return false;
  }
}