Program: 12366
Project: 12366
Buggy source:
@Override public boolean incrementToken() throws IOException {
  boolean tokenAvailable=false;
  int builtGramSize=0;
  if (gramSize.atMinValue() || inputWindow.size() < gramSize.getValue()) {
    shiftInputWindow();
    if (sentenceBoundaryAware)     sentenceBoundaryInWindow=findSentenceBoundary();
    gramBuilder.setLength(0);
  }
 else {
    builtGramSize=gramSize.getPreviousValue();
  }
  if (inputWindow.size() >= gramSize.getValue()) {
    boolean isAllFiller=true;
    InputWindowToken nextToken=null;
    Iterator<InputWindowToken> iter=inputWindow.iterator();
    int idxInWindow=-1;
    boolean outputThisShingle=true;
    for (int gramNum=1; iter.hasNext() && builtGramSize < gramSize.getValue(); ++gramNum) {
      nextToken=iter.next();
      idxInWindow++;
      if (idxInWindow == 0)       outputThisShingle=checkToken(nextToken);
      if (outputThisShingle && sentenceBoundaryAware)       outputThisShingle=checkSentenceBoundary(idxInWindow);
      if (outputThisShingle && idxInWindow == gramSize.getValue() - 1)       outputThisShingle=checkToken(nextToken);
      if (builtGramSize < gramNum) {
        if (builtGramSize > 0) {
          gramBuilder.append(tokenSeparator);
        }
        gramBuilder.append(nextToken.termAtt.buffer(),0,nextToken.termAtt.length());
        ++builtGramSize;
      }
      if (isAllFiller && nextToken.isFiller) {
        if (gramNum == gramSize.getValue()) {
          gramSize.advance();
        }
      }
 else {
        isAllFiller=false;
      }
    }
    if (!isAllFiller && builtGramSize == gramSize.getValue()) {
      if (gramBuilder.length() > maxCharLength || gramBuilder.length() < minCharLength)       outputThisShingle=false;
      if (outputThisShingle) {
        inputWindow.getFirst().attSource.copyTo(this);
        posIncrAtt.setPositionIncrement(isOutputHere ? 0 : 1);
        termAtt.setEmpty().append(gramBuilder);
        if (gramSize.getValue() > 1) {
          typeAtt.setType(tokenType);
          noShingleOutput=false;
        }
        offsetAtt.setOffset(offsetAtt.startOffset(),nextToken.offsetAtt.endOffset());
        if (sentenceBoundaryAware && sentenceBoundaryInWindow != -1)         posLenAtt.setPositionLength(sentenceBoundaryInWindow + 1);
 else         posIncrAtt.setPositionIncrement(builtGramSize);
        isOutputHere=true;
        gramSize.advance();
        tokenAvailable=true;
        System.out.println(new String(offsetAtt.startOffset() + "String_Node_Str" + offsetAtt.endOffset()+ "String_Node_Str"+ gramBuilder.toString()));
      }
 else {
        clearAttributes();
        gramSize.advance();
        isOutputHere=true;
        tokenAvailable=true;
      }
    }
  }
  return tokenAvailable;
}

Fixed version (ground truth):
@Override public boolean incrementToken() throws IOException {
  boolean tokenAvailable=false;
  int builtGramSize=0;
  if (gramSize.atMinValue() || inputWindow.size() < gramSize.getValue()) {
    shiftInputWindow();
    if (sentenceBoundaryAware)     sentenceBoundaryInWindow=findSentenceBoundary();
    gramBuilder.setLength(0);
  }
 else {
    builtGramSize=gramSize.getPreviousValue();
  }
  if (inputWindow.size() >= gramSize.getValue()) {
    boolean isAllFiller=true;
    InputWindowToken nextToken=null;
    Iterator<InputWindowToken> iter=inputWindow.iterator();
    int idxInWindow=-1;
    boolean outputThisShingle=true;
    for (int gramNum=1; iter.hasNext() && builtGramSize < gramSize.getValue(); ++gramNum) {
      nextToken=iter.next();
      idxInWindow++;
      if (idxInWindow == 0)       outputThisShingle=checkToken(nextToken);
      if (outputThisShingle && sentenceBoundaryAware)       outputThisShingle=checkSentenceBoundary(idxInWindow);
      if (outputThisShingle && idxInWindow == gramSize.getValue() - 1)       outputThisShingle=checkToken(nextToken);
      if (builtGramSize < gramNum) {
        if (builtGramSize > 0) {
          gramBuilder.append(tokenSeparator);
        }
        gramBuilder.append(nextToken.termAtt.buffer(),0,nextToken.termAtt.length());
        ++builtGramSize;
      }
      if (isAllFiller && nextToken.isFiller) {
        if (gramNum == gramSize.getValue()) {
          gramSize.advance();
        }
      }
 else {
        isAllFiller=false;
      }
    }
    if (!isAllFiller && builtGramSize == gramSize.getValue()) {
      if (gramBuilder.length() > maxCharLength || gramBuilder.length() < minCharLength)       outputThisShingle=false;
      if (outputThisShingle) {
        inputWindow.getFirst().attSource.copyTo(this);
        posIncrAtt.setPositionIncrement(isOutputHere ? 0 : 1);
        termAtt.setEmpty().append(gramBuilder);
        if (gramSize.getValue() > 1) {
          typeAtt.setType(tokenType);
          noShingleOutput=false;
        }
        offsetAtt.setOffset(offsetAtt.startOffset(),nextToken.offsetAtt.endOffset());
        if (sentenceBoundaryAware && sentenceBoundaryInWindow != -1)         posLenAtt.setPositionLength(sentenceBoundaryInWindow + 1);
 else         posIncrAtt.setPositionIncrement(builtGramSize);
        isOutputHere=true;
        gramSize.advance();
        tokenAvailable=true;
      }
 else {
        clearAttributes();
        gramSize.advance();
        isOutputHere=true;
        tokenAvailable=true;
      }
    }
  }
  return tokenAvailable;
}