Program: 110438
Project: 110438
Buggy source:
@Override public final void getChunkOperation(List<? extends MediaChunk> queue,long seekPositionUs,long playbackPositionUs,ChunkOperationHolder out){
  if (fatalError != null) {
    out.chunk=null;
    return;
  }
  evaluation.queueSize=queue.size();
  if (evaluation.format == null || !lastChunkWasInitialization) {
    PeriodHolder periodHolder=null;
    if (!queue.isEmpty()) {
      periodHolder=periodHolders.get(queue.get(queue.size() - 1).parentId);
    }
    if (periodHolder == null) {
      periodHolder=periodHolders.valueAt(0);
    }
    formatEvaluator.evaluate(queue,playbackPositionUs,periodHolder.formats,evaluation);
  }
  Format selectedFormat=evaluation.format;
  out.queueSize=evaluation.queueSize;
  if (selectedFormat == null) {
    out.chunk=null;
    return;
  }
 else   if (out.queueSize == queue.size() && out.chunk != null && out.chunk.format.equals(selectedFormat)) {
    return;
  }
  out.chunk=null;
  if (currentManifest.dynamic && periodHolders.valueAt(periodHolders.size() - 1).isIndexUnbounded()) {
    updateAvailableBounds(getNowUs());
  }
  availableRangeValues=availableRange.getCurrentBoundsUs(availableRangeValues);
  long segmentStartTimeUs;
  int segmentNum=-1;
  boolean startingNewPeriod=false;
  PeriodHolder periodHolder;
  if (queue.isEmpty()) {
    if (currentManifest.dynamic) {
      if (startAtLiveEdge) {
        seekPositionUs=Math.max(availableRangeValues[0],availableRangeValues[1] - liveEdgeLatencyUs);
      }
 else {
        seekPositionUs=Math.max(seekPositionUs,availableRangeValues[0]);
        seekPositionUs=Math.min(seekPositionUs,availableRangeValues[1] - 1);
      }
    }
    periodHolder=findPeriodHolder(seekPositionUs);
    segmentStartTimeUs=seekPositionUs;
    startingNewPeriod=true;
  }
 else {
    if (startAtLiveEdge) {
      startAtLiveEdge=false;
    }
    MediaChunk previous=queue.get(out.queueSize - 1);
    if (previous.isLastChunk) {
      return;
    }
    segmentNum=previous.chunkIndex + 1;
    segmentStartTimeUs=previous.endTimeUs;
    if (currentManifest.dynamic) {
      if (segmentStartTimeUs < availableRangeValues[0]) {
        fatalError=new BehindLiveWindowException();
        return;
      }
 else       if (segmentStartTimeUs >= availableRangeValues[1]) {
        return;
      }
    }
    periodHolder=periodHolders.get(previous.parentId);
    if (periodHolder == null) {
      periodHolder=periodHolders.valueAt(0);
      startingNewPeriod=true;
    }
 else     if (!periodHolder.isIndexUnbounded() && segmentStartTimeUs >= periodHolder.getAvailableEndTimeUs()) {
      periodHolder=periodHolders.get(previous.parentId + 1);
      startingNewPeriod=true;
    }
  }
  RepresentationHolder representationHolder=periodHolder.representationHolders.get(selectedFormat.id);
  Representation selectedRepresentation=representationHolder.representation;
  ChunkExtractorWrapper extractorWrapper=representationHolder.extractorWrapper;
  RangedUri pendingInitializationUri=null;
  RangedUri pendingIndexUri=null;
  MediaFormat mediaFormat=representationHolder.mediaFormat;
  if (mediaFormat == null) {
    pendingInitializationUri=selectedRepresentation.getInitializationUri();
  }
  if (representationHolder.segmentIndex == null) {
    pendingIndexUri=selectedRepresentation.getIndexUri();
  }
  if (pendingInitializationUri != null || pendingIndexUri != null) {
    Chunk initializationChunk=newInitializationChunk(pendingInitializationUri,pendingIndexUri,selectedRepresentation,extractorWrapper,dataSource,periodHolder.manifestIndex,evaluation.trigger);
    lastChunkWasInitialization=true;
    out.chunk=initializationChunk;
    return;
  }
  if (startingNewPeriod) {
    if (queue.isEmpty()) {
      segmentNum=representationHolder.getSegmentNum(segmentStartTimeUs);
    }
 else {
      segmentNum=representationHolder.getFirstAvailableSegmentNum();
    }
  }
  Chunk nextMediaChunk=newMediaChunk(periodHolder,representationHolder,dataSource,mediaFormat,segmentNum,evaluation.trigger);
  lastChunkWasInitialization=false;
  out.chunk=nextMediaChunk;
}

Fixed version (ground truth):
@Override public final void getChunkOperation(List<? extends MediaChunk> queue,long seekPositionUs,long playbackPositionUs,ChunkOperationHolder out){
  if (fatalError != null) {
    out.chunk=null;
    return;
  }
  evaluation.queueSize=queue.size();
  if (evaluation.format == null || !lastChunkWasInitialization) {
    PeriodHolder periodHolder=null;
    if (!queue.isEmpty()) {
      periodHolder=periodHolders.get(queue.get(queue.size() - 1).parentId);
    }
    if (periodHolder == null) {
      periodHolder=periodHolders.valueAt(0);
    }
    formatEvaluator.evaluate(queue,playbackPositionUs,periodHolder.formats,evaluation);
  }
  Format selectedFormat=evaluation.format;
  out.queueSize=evaluation.queueSize;
  if (selectedFormat == null) {
    out.chunk=null;
    return;
  }
 else   if (out.queueSize == queue.size() && out.chunk != null && out.chunk.format.equals(selectedFormat)) {
    return;
  }
  out.chunk=null;
  if (currentManifest.dynamic && periodHolders.valueAt(periodHolders.size() - 1).isIndexUnbounded()) {
    updateAvailableBounds(getNowUs());
  }
  availableRangeValues=availableRange.getCurrentBoundsUs(availableRangeValues);
  long segmentStartTimeUs;
  int segmentNum=-1;
  boolean startingNewPeriod=false;
  PeriodHolder periodHolder;
  if (queue.isEmpty()) {
    if (currentManifest.dynamic) {
      if (startAtLiveEdge) {
        seekPositionUs=Math.max(availableRangeValues[0],availableRangeValues[1] - liveEdgeLatencyUs);
      }
 else {
        seekPositionUs=Math.min(seekPositionUs,availableRangeValues[1] - 1);
        seekPositionUs=Math.max(seekPositionUs,availableRangeValues[0]);
      }
    }
    periodHolder=findPeriodHolder(seekPositionUs);
    segmentStartTimeUs=seekPositionUs;
    startingNewPeriod=true;
  }
 else {
    if (startAtLiveEdge) {
      startAtLiveEdge=false;
    }
    MediaChunk previous=queue.get(out.queueSize - 1);
    if (previous.isLastChunk) {
      return;
    }
    segmentNum=previous.chunkIndex + 1;
    segmentStartTimeUs=previous.endTimeUs;
    if (currentManifest.dynamic) {
      if (segmentStartTimeUs < availableRangeValues[0]) {
        fatalError=new BehindLiveWindowException();
        return;
      }
 else       if (segmentStartTimeUs >= availableRangeValues[1]) {
        return;
      }
    }
    periodHolder=periodHolders.get(previous.parentId);
    if (periodHolder == null) {
      periodHolder=periodHolders.valueAt(0);
      startingNewPeriod=true;
    }
 else     if (!periodHolder.isIndexUnbounded() && segmentStartTimeUs >= periodHolder.getAvailableEndTimeUs()) {
      periodHolder=periodHolders.get(previous.parentId + 1);
      startingNewPeriod=true;
    }
  }
  RepresentationHolder representationHolder=periodHolder.representationHolders.get(selectedFormat.id);
  Representation selectedRepresentation=representationHolder.representation;
  ChunkExtractorWrapper extractorWrapper=representationHolder.extractorWrapper;
  RangedUri pendingInitializationUri=null;
  RangedUri pendingIndexUri=null;
  MediaFormat mediaFormat=representationHolder.mediaFormat;
  if (mediaFormat == null) {
    pendingInitializationUri=selectedRepresentation.getInitializationUri();
  }
  if (representationHolder.segmentIndex == null) {
    pendingIndexUri=selectedRepresentation.getIndexUri();
  }
  if (pendingInitializationUri != null || pendingIndexUri != null) {
    Chunk initializationChunk=newInitializationChunk(pendingInitializationUri,pendingIndexUri,selectedRepresentation,extractorWrapper,dataSource,periodHolder.manifestIndex,evaluation.trigger);
    lastChunkWasInitialization=true;
    out.chunk=initializationChunk;
    return;
  }
  if (startingNewPeriod) {
    if (queue.isEmpty()) {
      segmentNum=representationHolder.getSegmentNum(segmentStartTimeUs);
    }
 else {
      segmentNum=representationHolder.getFirstAvailableSegmentNum();
    }
  }
  Chunk nextMediaChunk=newMediaChunk(periodHolder,representationHolder,dataSource,mediaFormat,segmentNum,evaluation.trigger);
  lastChunkWasInitialization=false;
  out.chunk=nextMediaChunk;
}