Program: 2131
Project: 2131
Buggy source:
public Collection<? extends TimelineChunk> getInMemoryTimelineChunks(final Integer hostId,final List<Integer> sampleKindIds,@Nullable final DateTime filterStartTime,@Nullable final DateTime filterEndTime) throws IOException, ExecutionException {
  getInMemoryChunksCallCount.inc();
  final Map<Integer,TimelineHostEventAccumulator> hostAccumulators=accumulators.get(hostId);
  if (hostAccumulators == null) {
    return ImmutableList.of();
  }
  final List<TimelineChunk> samplesByHostName=new ArrayList<TimelineChunk>();
  for (  final TimelineHostEventAccumulator accumulator : hostAccumulators.values()) {
    for (    TimelineChunk chunk : accumulator.getPendingTimelineChunks()) {
      if ((filterStartTime != null && chunk.getEndTime().isBefore(filterStartTime)) || (filterStartTime != null && chunk.getStartTime().isAfter(filterEndTime))) {
        continue;
      }
 else {
        samplesByHostName.add(chunk);
      }
    }
    final List<DateTime> accumulatorTimes=accumulator.getTimes();
    if (accumulatorTimes.size() == 0) {
      continue;
    }
    final DateTime accumulatorStartTime=accumulator.getStartTime();
    final DateTime accumulatorEndTime=accumulator.getEndTime();
    if ((filterStartTime != null && accumulatorEndTime.isBefore(filterStartTime)) || (filterStartTime != null && accumulatorStartTime.isAfter(filterEndTime))) {
      continue;
    }
    for (    final TimelineChunkAccumulator chunkAccumulator : accumulator.getTimelines().values()) {
      accumulatorDeepCopyCount.inc();
      final TimelineChunkAccumulator chunkAccumulatorCopy=chunkAccumulator.deepCopy();
      final TimelineChunk timelineChunk=chunkAccumulatorCopy.extractTimelineChunkAndReset(accumulatorStartTime,accumulatorEndTime,accumulatorTimes);
      if (!sampleKindIds.contains(timelineChunk.getSampleKindId())) {
        continue;
      }
      samplesByHostName.add(timelineChunk);
    }
  }
  inMemoryChunksReturnedCount.inc(samplesByHostName.size());
  return samplesByHostName;
}

Fixed version (ground truth):
public Collection<? extends TimelineChunk> getInMemoryTimelineChunks(final Integer hostId,final List<Integer> sampleKindIds,@Nullable final DateTime filterStartTime,@Nullable final DateTime filterEndTime) throws IOException, ExecutionException {
  getInMemoryChunksCallCount.inc();
  final Map<Integer,TimelineHostEventAccumulator> hostAccumulators=accumulators.get(hostId);
  if (hostAccumulators == null) {
    return ImmutableList.of();
  }
  final List<TimelineChunk> samplesByHostName=new ArrayList<TimelineChunk>();
  for (  final TimelineHostEventAccumulator accumulator : hostAccumulators.values()) {
    for (    TimelineChunk chunk : accumulator.getPendingTimelineChunks()) {
      if ((filterStartTime != null && chunk.getEndTime().isBefore(filterStartTime)) || (filterStartTime != null && chunk.getStartTime().isAfter(filterEndTime))) {
        continue;
      }
 else {
        samplesByHostName.add(chunk);
      }
    }
    final List<DateTime> accumulatorTimes=accumulator.getTimes();
    if (accumulatorTimes.size() == 0) {
      continue;
    }
    final DateTime accumulatorStartTime=accumulator.getStartTime();
    final DateTime accumulatorEndTime=accumulator.getEndTime();
    if ((filterStartTime != null && accumulatorEndTime.isBefore(filterStartTime)) || (filterStartTime != null && accumulatorStartTime.isAfter(filterEndTime))) {
      continue;
    }
    for (    final TimelineChunkAccumulator chunkAccumulator : accumulator.getTimelines().values()) {
      accumulatorDeepCopyCount.inc();
      final TimelineChunkAccumulator chunkAccumulatorCopy=chunkAccumulator.deepCopy();
      final TimelineChunk timelineChunk=chunkAccumulatorCopy.extractTimelineChunkAndReset(accumulatorStartTime,accumulatorEndTime,accumulatorTimes);
      if (!sampleKindIds.contains(timelineChunk.getSampleKindId())) {
        continue;
      }
      samplesByHostName.add(timelineChunk);
    }
  }
  inMemoryChunksReturnedCount.inc(samplesByHostName.size());
  Collections.sort(samplesByHostName,CHUNK_COMPARATOR);
  return samplesByHostName;
}