Program: 8003
Project: 8003
Buggy source:
@Override public DequeueResult dequeue(QueueConsumer consumer,ReadPointer readPointer) throws OperationException {
  final QueueConfig config=consumer.getQueueConfig();
  if (LOG.isTraceEnabled()) {
    LOG.trace(getLogMessage("String_Node_Str" + this.dequeueReturns.get() + "String_Node_Str"+ consumer+ "String_Node_Str"+ config+ "String_Node_Str"+ readPointer+ "String_Node_Str"));
  }
  final DequeueStrategy dequeueStrategy=getDequeueStrategy(config.getPartitionerType().getPartitioner());
  final QueueStateImpl queueState=getQueueState(consumer,readPointer);
  if (config.isSingleEntry()) {
    final DequeuedEntrySet dequeueEntrySet=queueState.getDequeueEntrySet();
    if (!dequeueEntrySet.isEmpty()) {
      final TransientWorkingSet transientWorkingSet=queueState.getTransientWorkingSet();
      final Map<Long,byte[]> cachedEntries=queueState.getTransientWorkingSet().getCachedEntries();
      int numToReturn=config.returnsBatch() ? getBatchSize(config) : 1;
      List<QueueEntry> entries=Lists.newArrayListWithCapacity(numToReturn);
      List<QueueEntryPointer> pointers=Lists.newArrayListWithCapacity(numToReturn);
      for (      DequeueEntry returnEntry : dequeueEntrySet.getEntryList()) {
        if (entries.size() >= numToReturn) {
          break;
        }
        long returnEntryId=returnEntry.getEntryId();
        if (transientWorkingSet.hasNext() && transientWorkingSet.peekNext().getEntryId() == returnEntryId) {
          transientWorkingSet.next();
        }
        byte[] entryBytes=cachedEntries.get(returnEntryId);
        if (entryBytes == null) {
          throw new OperationException(StatusCode.INTERNAL_ERROR,getLogMessage(String.format("String_Node_Str",returnEntryId)));
        }
        entries.add(new QueueEntry(entryBytes));
        pointers.add(new QueueEntryPointer(this.queueName,returnEntryId,returnEntry.getTries()));
      }
      if (entries.size() > 0) {
        dequeueStrategy.saveDequeueState(consumer,config,queueState,readPointer);
        return new DequeueResult(DequeueResult.DequeueStatus.SUCCESS,pointers.toArray(new QueueEntryPointer[pointers.size()]),entries.toArray(new QueueEntry[entries.size()]));
      }
    }
  }
  if (!queueState.getTransientWorkingSet().hasNext()) {
    List<Long> entryIds=dequeueStrategy.fetchNextEntries(consumer,config,queueState,readPointer);
    readEntries(consumer,config,queueState,readPointer,entryIds);
  }
  if (!queueState.getTransientWorkingSet().hasNext()) {
    if (LOG.isTraceEnabled()) {
      LOG.trace(getLogMessage("String_Node_Str" + "String_Node_Str" + readPointer));
    }
    dequeueStrategy.saveDequeueState(consumer,config,queueState,readPointer);
    return new DequeueResult(DequeueResult.DequeueStatus.EMPTY);
  }
  if (!config.returnsBatch()) {
    DequeueEntry dequeueEntry=queueState.getTransientWorkingSet().next();
    queueState.getDequeueEntrySet().add(dequeueEntry);
    QueueEntry entry=new QueueEntry(queueState.getTransientWorkingSet().getCachedEntries().get(dequeueEntry.getEntryId()));
    dequeueStrategy.saveDequeueState(consumer,config,queueState,readPointer);
    this.dequeueReturns.incrementAndGet();
    return new DequeueResult(DequeueResult.DequeueStatus.SUCCESS,new QueueEntryPointer(this.queueName,dequeueEntry.getEntryId(),dequeueEntry.getTries()),entry);
  }
 else {
    final int batchSize=getBatchSize(config);
    List<QueueEntryPointer> pointers=Lists.newArrayListWithCapacity(batchSize);
    List<QueueEntry> entries=Lists.newArrayListWithCapacity(batchSize);
    while (queueState.getTransientWorkingSet().hasNext() && entries.size() < batchSize) {
      DequeueEntry dequeueEntry=queueState.getTransientWorkingSet().next();
      queueState.getDequeueEntrySet().add(dequeueEntry);
      entries.add(new QueueEntry(queueState.getTransientWorkingSet().getCachedEntries().get(dequeueEntry.getEntryId())));
      pointers.add(new QueueEntryPointer(this.queueName,dequeueEntry.getEntryId(),dequeueEntry.getTries()));
    }
    dequeueStrategy.saveDequeueState(consumer,config,queueState,readPointer);
    this.dequeueReturns.incrementAndGet();
    return new DequeueResult(DequeueResult.DequeueStatus.SUCCESS,pointers.toArray(new QueueEntryPointer[pointers.size()]),entries.toArray(new QueueEntry[entries.size()]));
  }
}

Fixed version (ground truth):
@Override public DequeueResult dequeue(QueueConsumer consumer,ReadPointer readPointer) throws OperationException {
  final QueueConfig config=consumer.getQueueConfig();
  if (LOG.isTraceEnabled()) {
    LOG.trace(getLogMessage("String_Node_Str" + this.dequeueReturns.get() + "String_Node_Str"+ consumer+ "String_Node_Str"+ config+ "String_Node_Str"+ readPointer+ "String_Node_Str"));
  }
  final DequeueStrategy dequeueStrategy=getDequeueStrategy(config.getPartitionerType().getPartitioner());
  final QueueStateImpl queueState=getQueueState(consumer,readPointer);
  if (config.isSingleEntry()) {
    final DequeuedEntrySet dequeueEntrySet=queueState.getDequeueEntrySet();
    if (!dequeueEntrySet.isEmpty()) {
      final TransientWorkingSet transientWorkingSet=queueState.getTransientWorkingSet();
      final Map<Long,byte[]> cachedEntries=queueState.getTransientWorkingSet().getCachedEntries();
      int numToReturn=config.returnsBatch() ? getBatchSize(config) : 1;
      List<QueueEntry> entries=Lists.newArrayListWithCapacity(numToReturn);
      List<QueueEntryPointer> pointers=Lists.newArrayListWithCapacity(numToReturn);
      for (      DequeueEntry returnEntry : dequeueEntrySet.getEntryList()) {
        if (entries.size() >= numToReturn) {
          break;
        }
        long returnEntryId=returnEntry.getEntryId();
        if (transientWorkingSet.hasNext() && transientWorkingSet.peekNext().getEntryId() == returnEntryId) {
          transientWorkingSet.next();
        }
        byte[] entryBytes=cachedEntries.get(returnEntryId);
        if (entryBytes == null) {
          throw new OperationException(StatusCode.INTERNAL_ERROR,getLogMessage(String.format("String_Node_Str",returnEntryId)));
        }
        entries.add(new QueueEntry(entryBytes));
        pointers.add(new QueueEntryPointer(this.queueName,returnEntryId,returnEntry.getTries()));
      }
      if (entries.size() > 0) {
        dequeueStrategy.saveDequeueState(consumer,config,queueState,readPointer);
        return new DequeueResult(DequeueResult.DequeueStatus.SUCCESS,pointers.toArray(new QueueEntryPointer[pointers.size()]),entries.toArray(new QueueEntry[entries.size()]));
      }
    }
  }
  if (!queueState.getTransientWorkingSet().hasNext()) {
    dequeueStrategy.fetchNextEntries(consumer,config,queueState,readPointer);
  }
  if (!queueState.getTransientWorkingSet().hasNext()) {
    if (LOG.isTraceEnabled()) {
      LOG.trace(getLogMessage("String_Node_Str" + "String_Node_Str" + readPointer));
    }
    dequeueStrategy.saveDequeueState(consumer,config,queueState,readPointer);
    return new DequeueResult(DequeueResult.DequeueStatus.EMPTY);
  }
  if (!config.returnsBatch()) {
    DequeueEntry dequeueEntry=queueState.getTransientWorkingSet().next();
    queueState.getDequeueEntrySet().add(dequeueEntry);
    QueueEntry entry=new QueueEntry(queueState.getTransientWorkingSet().getCachedEntries().get(dequeueEntry.getEntryId()));
    dequeueStrategy.saveDequeueState(consumer,config,queueState,readPointer);
    this.dequeueReturns.incrementAndGet();
    return new DequeueResult(DequeueResult.DequeueStatus.SUCCESS,new QueueEntryPointer(this.queueName,dequeueEntry.getEntryId(),dequeueEntry.getTries()),entry);
  }
 else {
    final int batchSize=getBatchSize(config);
    List<QueueEntryPointer> pointers=Lists.newArrayListWithCapacity(batchSize);
    List<QueueEntry> entries=Lists.newArrayListWithCapacity(batchSize);
    while (queueState.getTransientWorkingSet().hasNext() && entries.size() < batchSize) {
      DequeueEntry dequeueEntry=queueState.getTransientWorkingSet().next();
      queueState.getDequeueEntrySet().add(dequeueEntry);
      entries.add(new QueueEntry(queueState.getTransientWorkingSet().getCachedEntries().get(dequeueEntry.getEntryId())));
      pointers.add(new QueueEntryPointer(this.queueName,dequeueEntry.getEntryId(),dequeueEntry.getTries()));
    }
    dequeueStrategy.saveDequeueState(consumer,config,queueState,readPointer);
    this.dequeueReturns.incrementAndGet();
    return new DequeueResult(DequeueResult.DequeueStatus.SUCCESS,pointers.toArray(new QueueEntryPointer[pointers.size()]),entries.toArray(new QueueEntry[entries.size()]));
  }
}