Program: 92367
Project: 92367
Buggy source:
private void loadLineData(){
  if (fTopLineIndex < 0) {
    if (fLines.size() > 0 && fTrace.getLocationRatio(fLines.get(0).location) > 0) {
      double lastRatio=fTrace.getLocationRatio(fLines.get(fLines.size() - 1).location);
      double firstRatio=fTrace.getLocationRatio(fLines.get(0).location);
      double delta;
      boolean singleEvent=false;
      if (firstRatio != lastRatio) {
        delta=Math.max(20,fNumVisibleLines) * (lastRatio - firstRatio) / (fLines.size() - 1);
      }
 else {
        delta=Math.pow(10,-15);
        singleEvent=true;
      }
      while (fTopLineIndex < 0) {
        ITmfLocation<?> endLocation=fLines.get(0).location;
        firstRatio=Math.max(0,firstRatio - delta);
        ITmfContext context=fTrace.seekEvent(firstRatio);
        ITmfLocation<?> location;
        int index=0;
        long rank=0;
        while (!context.getLocation().equals(endLocation)) {
          location=context.getLocation().clone();
          ITmfEvent event=fTrace.getNext(context);
          if (event == null) {
            break;
          }
          if (event.getContent() != null && event.getContent().getValue() != null) {
            String[] lines=event.getContent().getValue().toString().split("String_Node_Str");
            for (int i=0; i < lines.length; i++) {
              String line=lines[i];
              LineData lineData=new LineData(rank,location,line);
              fLines.add(index++,lineData);
              fTopLineIndex++;
              fLastTopLineIndex++;
            }
          }
          rank++;
        }
        long rankOffset=fLines.get(index).rank - rank;
        for (int i=0; i < index; i++) {
          fLines.get(i).rank+=rankOffset;
        }
        if (firstRatio == 0) {
          break;
        }
        if (singleEvent) {
          delta=Math.min(delta * 10,0.1);
        }
      }
    }
    if (fTopLineIndex < 0) {
      fTopLineIndex=0;
    }
  }
  while (fLines.size() - fTopLineIndex < fNumVisibleLines) {
    if (fBottomContext == null) {
      if (fLines.size() == 0) {
        fBottomContext=fTrace.seekEvent(0);
      }
 else {
        fBottomContext=fTrace.seekEvent(fLines.get(fLines.size() - 1).location);
        fTrace.getNext(fBottomContext);
      }
      if (fBottomContext == null) {
        break;
      }
    }
    long rank=fBottomContext.getRank();
    ITmfLocation<?> location=fBottomContext.getLocation() != null ? fBottomContext.getLocation().clone() : null;
    ITmfEvent event=fTrace.getNext(fBottomContext);
    if (event == null) {
      break;
    }
    if (event.getContent() != null && event.getContent().getValue() != null) {
      for (      String line : event.getContent().getValue().toString().split("String_Node_Str")) {
        int crPos;
        if ((crPos=line.indexOf('\r')) != -1) {
          line=line.substring(0,crPos);
        }
        LineData lineData=new LineData(rank,location,line);
        fLines.add(lineData);
      }
    }
  }
  fTopLineIndex=Math.max(0,Math.min(fTopLineIndex,fLines.size() - 1));
  if (fLines.size() > MAX_LINE_DATA_SIZE) {
    if (fTopLineIndex < MAX_LINE_DATA_SIZE / 2) {
      long rank=fLines.get(MAX_LINE_DATA_SIZE - 1).rank;
      for (int i=MAX_LINE_DATA_SIZE; i < fLines.size(); i++) {
        if (fLines.get(i).rank > rank) {
          fLines.subList(i,fLines.size()).clear();
          fBottomContext=null;
          break;
        }
      }
    }
 else {
      long rank=fLines.get(fLines.size() - MAX_LINE_DATA_SIZE).rank;
      for (int i=fLines.size() - MAX_LINE_DATA_SIZE - 1; i >= 0; i--) {
        if (fLines.get(i).rank < rank) {
          fLines.subList(0,i + 1).clear();
          fTopLineIndex-=(i + 1);
          fLastTopLineIndex-=(i + 1);
          break;
        }
      }
    }
  }
}

Fixed version (ground truth):
private void loadLineData(){
  if (fTopLineIndex < 0) {
    if (fLines.size() > 0 && fTrace.getLocationRatio(fLines.get(0).location) > 0) {
      double lastRatio=fTrace.getLocationRatio(fLines.get(fLines.size() - 1).location);
      double firstRatio=fTrace.getLocationRatio(fLines.get(0).location);
      double delta;
      boolean singleEvent=false;
      if (firstRatio != lastRatio) {
        delta=Math.max(20,fNumVisibleLines) * (lastRatio - firstRatio) / (fLines.size() - 1);
      }
 else {
        delta=Math.pow(10,-15);
        singleEvent=true;
      }
      while (fTopLineIndex < 0) {
        ITmfLocation<?> endLocation=fLines.get(0).location;
        firstRatio=Math.max(0,firstRatio - delta);
        ITmfContext context=fTrace.seekEvent(firstRatio);
        ITmfLocation<?> location;
        int index=0;
        long rank=0;
        while (!context.getLocation().equals(endLocation)) {
          location=context.getLocation().clone();
          ITmfEvent event=fTrace.getNext(context);
          if (event == null) {
            break;
          }
          if (event.getContent() != null && event.getContent().getValue() != null) {
            String[] lines=event.getContent().getValue().toString().split("String_Node_Str");
            for (int i=0; i < lines.length; i++) {
              String line=lines[i];
              LineData lineData=new LineData(rank,location,line);
              fLines.add(index++,lineData);
              fTopLineIndex++;
              fLastTopLineIndex++;
            }
          }
 else {
            LineData lineData=new LineData(rank,location,"String_Node_Str");
            fLines.add(index++,lineData);
            fTopLineIndex++;
            fLastTopLineIndex++;
          }
          rank++;
        }
        long rankOffset=fLines.get(index).rank - rank;
        for (int i=0; i < index; i++) {
          fLines.get(i).rank+=rankOffset;
        }
        if (firstRatio == 0) {
          break;
        }
        if (singleEvent) {
          delta=Math.min(delta * 10,0.1);
        }
      }
    }
    if (fTopLineIndex < 0) {
      fTopLineIndex=0;
    }
  }
  while (fLines.size() - fTopLineIndex < fNumVisibleLines) {
    if (fBottomContext == null) {
      if (fLines.size() == 0) {
        fBottomContext=fTrace.seekEvent(0);
      }
 else {
        fBottomContext=fTrace.seekEvent(fLines.get(fLines.size() - 1).location);
        fTrace.getNext(fBottomContext);
      }
      if (fBottomContext == null) {
        break;
      }
    }
    long rank=fBottomContext.getRank();
    ITmfLocation<?> location=fBottomContext.getLocation() != null ? fBottomContext.getLocation().clone() : null;
    ITmfEvent event=fTrace.getNext(fBottomContext);
    if (event == null) {
      break;
    }
    if (event.getContent() != null && event.getContent().getValue() != null) {
      for (      String line : event.getContent().getValue().toString().split("String_Node_Str")) {
        int crPos;
        if ((crPos=line.indexOf('\r')) != -1) {
          line=line.substring(0,crPos);
        }
        LineData lineData=new LineData(rank,location,line);
        fLines.add(lineData);
      }
    }
 else {
      LineData lineData=new LineData(rank,location,"String_Node_Str");
      fLines.add(lineData);
    }
  }
  fTopLineIndex=Math.max(0,Math.min(fTopLineIndex,fLines.size() - 1));
  if (fLines.size() > MAX_LINE_DATA_SIZE) {
    if (fTopLineIndex < MAX_LINE_DATA_SIZE / 2) {
      long rank=fLines.get(MAX_LINE_DATA_SIZE - 1).rank;
      for (int i=MAX_LINE_DATA_SIZE; i < fLines.size(); i++) {
        if (fLines.get(i).rank > rank) {
          fLines.subList(i,fLines.size()).clear();
          fBottomContext=null;
          break;
        }
      }
    }
 else {
      long rank=fLines.get(fLines.size() - MAX_LINE_DATA_SIZE).rank;
      for (int i=fLines.size() - MAX_LINE_DATA_SIZE - 1; i >= 0; i--) {
        if (fLines.get(i).rank < rank) {
          fLines.subList(0,i + 1).clear();
          fTopLineIndex-=(i + 1);
          fLastTopLineIndex-=(i + 1);
          break;
        }
      }
    }
  }
}