Program: 7587
Project: 7587
Buggy source:
/** 
 * Reads or skips a   {@link StreamEvent}.
 * @param filter to determine to accept or skip a stream event by offsetand accept or skip a stream event block by timestamp.
 * @return The next StreamEvent or {@code null} if the event is rejected by the filter or reached EOF.
 */
private PositionStreamEvent nextStreamEvent(ReadFilter filter) throws IOException {
  PositionStreamEvent event=null;
  boolean done=false;
  while (!done) {
    if (timestamp < 0) {
      timestamp=readTimestamp();
    }
    if (timestamp == -1L) {
      eof=true;
      break;
    }
    boolean isReadBlockLength=length < 0;
    if (isReadBlockLength) {
      length=readLength();
    }
    if (isReadBlockLength && !filter.acceptTimestamp(timestamp)) {
      long bytesSkipped=eventInput.skip(length);
      timestamp=-1L;
      length=-1;
      if (bytesSkipped == length) {
        continue;
      }
 else {
        throw new EOFException();
      }
    }
    if (length > 0) {
      long startPos=eventInput.getPos();
      try {
        if (filter.acceptOffset(startPos)) {
          event=new DefaultPositionStreamEvent(readStreamData(),timestamp,startPos);
        }
 else {
          skipStreamData();
        }
      }
 catch (      IOException e) {
        if (isReadBlockLength) {
          timestamp=-1L;
          length=-1;
        }
        throw e;
      }
      long endPos=eventInput.getPos();
      done=true;
      length-=(int)(endPos - startPos);
    }
    if (length == 0) {
      timestamp=-1L;
      length=-1;
    }
  }
  return event;
}

Fixed version (ground truth):
/** 
 * Reads or skips a   {@link StreamEvent}.
 * @param filter to determine to accept or skip a stream event by offsetand accept or skip a stream event block by timestamp.
 * @return The next StreamEvent or {@code null} if the event is rejected by the filter or reached EOF.
 */
private PositionStreamEvent nextStreamEvent(ReadFilter filter) throws IOException {
  PositionStreamEvent event=null;
  boolean done=false;
  while (!done) {
    if (timestamp < 0) {
      timestamp=readTimestamp();
    }
    if (timestamp == -1L) {
      eof=true;
      break;
    }
    boolean isReadBlockLength=length < 0;
    if (isReadBlockLength) {
      length=readLength();
    }
    if (isReadBlockLength && !filter.acceptTimestamp(timestamp)) {
      long bytesSkipped=eventInput.skip(length);
      if (bytesSkipped == length) {
        timestamp=-1L;
        length=-1;
        continue;
      }
 else {
        timestamp=-1L;
        length=-1;
        throw new EOFException();
      }
    }
    if (length > 0) {
      long startPos=eventInput.getPos();
      try {
        if (filter.acceptOffset(startPos)) {
          event=new DefaultPositionStreamEvent(readStreamData(),timestamp,startPos);
        }
 else {
          skipStreamData();
        }
      }
 catch (      IOException e) {
        if (isReadBlockLength) {
          timestamp=-1L;
          length=-1;
        }
        throw e;
      }
      long endPos=eventInput.getPos();
      done=true;
      length-=(int)(endPos - startPos);
    }
    if (length == 0) {
      timestamp=-1L;
      length=-1;
    }
  }
  return event;
}