Program: 8009
Project: 8009
Buggy source:
private void testReconfig(List<Integer> consumerCounts,final int numEntries,final int queueBatchSize,final int perConsumerDequeueBatchSize,QueuePartitioner.PartitionerType partitionerType,Condition condition) throws Exception {
  TTQueue queue=createQueue();
  List<Integer> expectedEntries=Lists.newArrayList();
  for (int i=0; i < numEntries; ++i) {
    expectedEntries.add(i + 1);
    QueueEntry queueEntry=new QueueEntry(Bytes.toBytes(i + 1));
    queueEntry.addPartitioningKey(HASH_KEY,i + 1);
    assertTrue(queue.enqueue(queueEntry,getDirtyWriteVersion()).isSuccess());
  }
  expectedEntries=ImmutableList.copyOf(expectedEntries);
  assertEquals(numEntries,expectedEntries.size());
  List<Integer> actualEntries=Lists.newArrayList();
  List<Integer> sortedActualEntries=Lists.newArrayList();
  List<StatefulQueueConsumer> consumers=Collections.emptyList();
  QueueConfig config=new QueueConfig(partitionerType,true,queueBatchSize);
  long groupId=queue.getGroupID();
  int expectedOldConsumerCount=0;
  loop:   while (true) {
    for (    Integer newConsumerCount : consumerCounts) {
      consumers=Lists.newArrayListWithCapacity(newConsumerCount);
      int actualOldConsumerCount=-1;
      for (int i=0; i < newConsumerCount; ++i) {
        StatefulQueueConsumer consumer;
        if (partitionerType != QueuePartitioner.PartitionerType.HASH) {
          consumer=new StatefulQueueConsumer(i,groupId,newConsumerCount,config);
        }
 else {
          consumer=new StatefulQueueConsumer(i,groupId,newConsumerCount,"String_Node_Str",HASH_KEY,config);
        }
        consumers.add(consumer);
        int oldConsumerCount=queue.configure(consumer);
        if (oldConsumerCount >= 0) {
          actualOldConsumerCount=oldConsumerCount;
        }
      }
      assertEquals(expectedOldConsumerCount,actualOldConsumerCount);
      int numDequeuesThisRun=0;
      for (      QueueConsumer consumer : consumers) {
        for (int i=0; i < perConsumerDequeueBatchSize; ++i) {
          DequeueResult result=queue.dequeue(consumer,getDirtyPointer());
          if (result.isEmpty()) {
            break;
          }
          ++numDequeuesThisRun;
          actualEntries.add(Bytes.toInt(result.getEntry().getData()));
          queue.ack(result.getEntryPointer(),consumer,getDirtyPointer());
          assertTrue(condition.check(result.getEntryPointer().getEntryId(),newConsumerCount,consumer.getInstanceId(),(int)result.getEntryPointer().getEntryId()));
        }
        actualEntries.add(-1);
      }
      sortedActualEntries=Lists.newArrayList(actualEntries);
      Collections.sort(sortedActualEntries);
      if (numDequeuesThisRun == 0) {
        break loop;
      }
      expectedOldConsumerCount=newConsumerCount;
    }
  }
  for (  QueueConsumer consumer : consumers) {
    DequeueResult result=queue.dequeue(consumer,getDirtyPointer());
    assertTrue(result.isEmpty());
  }
  sortedActualEntries.removeAll(Lists.newArrayList(-1));
  assertEquals(expectedEntries,sortedActualEntries);
}

Fixed version (ground truth):
private void testReconfig(List<Integer> consumerCounts,final int numEntries,final int queueBatchSize,final int perConsumerDequeueBatchSize,QueuePartitioner.PartitionerType partitionerType,Condition condition) throws Exception {
  Random random=new Random(System.currentTimeMillis());
  TTQueue queue=createQueue();
  List<Integer> expectedEntries=Lists.newArrayList();
  for (int i=0; i < numEntries; ++i) {
    expectedEntries.add(i + 1);
    QueueEntry queueEntry=new QueueEntry(Bytes.toBytes(i + 1));
    queueEntry.addPartitioningKey(HASH_KEY,i + 1);
    assertTrue(queue.enqueue(queueEntry,getDirtyWriteVersion()).isSuccess());
  }
  expectedEntries=ImmutableList.copyOf(expectedEntries);
  assertEquals(numEntries,expectedEntries.size());
  List<Integer> actualEntries=Lists.newArrayList();
  List<String> actualPrintEntries=Lists.newArrayList();
  List<Integer> sortedActualEntries=Lists.newArrayList();
  List<StatefulQueueConsumer> consumers=Collections.emptyList();
  QueueConfig config=new QueueConfig(partitionerType,true,queueBatchSize);
  long groupId=queue.getGroupID();
  int expectedOldConsumerCount=0;
  loop:   while (true) {
    for (    Integer newConsumerCount : consumerCounts) {
      consumers=Lists.newArrayListWithCapacity(newConsumerCount);
      int actualOldConsumerCount=-1;
      for (int i=0; i < newConsumerCount; ++i) {
        StatefulQueueConsumer consumer;
        if (partitionerType != QueuePartitioner.PartitionerType.HASH) {
          consumer=new StatefulQueueConsumer(i,groupId,newConsumerCount,config);
        }
 else {
          consumer=new StatefulQueueConsumer(i,groupId,newConsumerCount,"String_Node_Str",HASH_KEY,config);
        }
        consumers.add(consumer);
        System.out.println("String_Node_Str");
        int oldConsumerCount=queue.configure(consumer);
        if (oldConsumerCount >= 0) {
          actualOldConsumerCount=oldConsumerCount;
        }
      }
      System.out.println(String.format("String_Node_Str",actualOldConsumerCount,newConsumerCount));
      assertEquals(expectedOldConsumerCount,actualOldConsumerCount);
      int numTriesThisRun=0;
      int numDequeuesThisRun=0;
      for (      QueueConsumer consumer : consumers) {
        int curBatchSize=random.nextInt(perConsumerDequeueBatchSize + 1);
        System.out.println("String_Node_Str" + curBatchSize);
        for (int i=0; i < curBatchSize; ++i) {
          ++numTriesThisRun;
          DequeueResult result=queue.dequeue(consumer,getDirtyPointer());
          if (result.isEmpty()) {
            break;
          }
          ++numDequeuesThisRun;
          actualEntries.add(Bytes.toInt(result.getEntry().getData()));
          actualPrintEntries.add(consumer.getInstanceId() + "String_Node_Str" + Bytes.toInt(result.getEntry().getData()));
          queue.ack(result.getEntryPointer(),consumer,getDirtyPointer());
          assertTrue(condition.check(result.getEntryPointer().getEntryId(),newConsumerCount,consumer.getInstanceId(),(int)result.getEntryPointer().getEntryId()));
        }
        actualEntries.add(-1);
      }
      System.out.println(actualPrintEntries);
      System.out.println(actualEntries);
      sortedActualEntries=Lists.newArrayList(actualEntries);
      Collections.sort(sortedActualEntries);
      System.out.println(sortedActualEntries);
      if (numDequeuesThisRun == 0 && numTriesThisRun >= consumers.size()) {
        sortedActualEntries.removeAll(Lists.newArrayList(-1));
        System.out.println("String_Node_Str" + expectedEntries);
        System.out.println("String_Node_Str" + sortedActualEntries);
        break loop;
      }
      expectedOldConsumerCount=newConsumerCount;
    }
  }
  for (  QueueConsumer consumer : consumers) {
    DequeueResult result=queue.dequeue(consumer,getDirtyPointer());
    assertTrue(result.isEmpty());
  }
  assertEquals(expectedEntries,sortedActualEntries);
}