Program: 170159
Project: 170159
Buggy source:
@Override public boolean incrementToken() throws IOException {
  if (!emitSingleTokens && unusedTokens.size() > 0) {
    Log.debug("String_Node_Str");
    Token aToken=unusedTokens.remove(0);
    emit(aToken);
    return true;
  }
  if (lastToken != null) {
    emit(lastToken);
    lastToken=null;
    return true;
  }
  char[] nextToken=nextToken();
  if (nextToken == null) {
    if (lastEmitted == null && (currentPhrase != null && currentPhrase.length() > 0)) {
      char[] lastTok=getCurrentBuffer(new char[0]);
      if (currentSetToCheck.contains(lastTok,0,lastTok.length)) {
        emit(lastTok);
        currentPhrase.setLength(0);
        return true;
      }
 else       if (lastValid != null) {
        emit(lastValid);
        return true;
      }
 else       if (!emitSingleTokens) {
        discardCharTokens(currentPhrase,unusedTokens);
        currentSetToCheck=null;
        currentPhrase.setLength(0);
        if (unusedTokens.size() > 0) {
          Token aToken=unusedTokens.remove(0);
          Log.debug("String_Node_Str");
          emit(aToken);
          return true;
        }
      }
    }
    return false;
  }
  if (emitSingleTokens) {
    lastToken=nextToken;
  }
  if (currentSetToCheck == null || currentSetToCheck.size() == 0) {
    Log.debug("String_Node_Str" + new String(nextToken) + "String_Node_Str");
    if (phraseMap.keySet().contains(nextToken,0,nextToken.length)) {
      currentSetToCheck=phraseMap.get(nextToken,0,nextToken.length);
      if (currentPhrase == null)       currentPhrase=new StringBuffer();
 else       currentPhrase.setLength(0);
      currentPhrase.append(nextToken);
      return incrementToken();
    }
 else {
      emit(nextToken);
      lastToken=null;
      return true;
    }
  }
 else {
    char[] currentBuffer=getCurrentBuffer(nextToken);
    if (currentSetToCheck.contains(currentBuffer,0,currentBuffer.length)) {
      currentSetToCheck=remove(currentSetToCheck,currentBuffer);
      if (currentSetToCheck.size() == 0) {
        emit(currentBuffer);
        lastValid=null;
      }
 else {
        if (emitSingleTokens) {
          lastToken=currentBuffer;
          return true;
        }
        lastValid=currentBuffer;
      }
      if (currentSetToCheck.size() == 0 && phraseMap.keySet().contains(nextToken,0,nextToken.length)) {
        currentSetToCheck=phraseMap.get(nextToken,0,nextToken.length);
        if (currentPhrase == null)         currentPhrase=new StringBuffer();
 else         currentPhrase.setLength(0);
        currentPhrase.append(nextToken);
      }
      return (lastValid != null) ? incrementToken() : true;
    }
    Iterator<Object> phraseIt=currentSetToCheck.iterator();
    while (phraseIt != null && phraseIt.hasNext()) {
      char[] phrase=(char[])phraseIt.next();
      if (startsWith(phrase,currentBuffer)) {
        return incrementToken();
      }
    }
    if (lastValid != null) {
      emit(lastValid);
      lastValid=null;
      return true;
    }
    if (!emitSingleTokens) {
      discardCharTokens(currentPhrase,unusedTokens);
      currentPhrase.setLength(0);
      currentSetToCheck=null;
      if (unusedTokens.size() > 0) {
        Token aToken=unusedTokens.remove(0);
        Log.debug("String_Node_Str");
        emit(aToken);
        return true;
      }
    }
    currentSetToCheck=null;
    Log.debug("String_Node_Str");
    return incrementToken();
  }
}

Fixed version (ground truth):
@Override public boolean incrementToken() throws IOException {
  if (!emitSingleTokens && unusedTokens.size() > 0) {
    Log.debug("String_Node_Str");
    Token aToken=unusedTokens.remove(0);
    emit(aToken);
    return true;
  }
  if (lastToken != null) {
    emit(lastToken);
    lastToken=null;
    return true;
  }
  char[] nextToken=nextToken();
  if (nextToken == null) {
    if (lastValid != null) {
      emit(lastValid);
      lastValid=null;
      return true;
    }
    if (emitSingleTokens && currentSetToCheck != null && currentSetToCheck.size() > 0) {
      char[] phrase=getFirst(currentSetToCheck);
      char[] lastTok=getCurrentBuffer(new char[0]);
      if (phrase != null && endsWith(lastTok,phrase)) {
        currentSetToCheck=remove(currentSetToCheck,phrase);
        emit(phrase);
        return true;
      }
    }
 else     if (!emitSingleTokens && currentSetToCheck != null && currentSetToCheck.size() > 0) {
      if (lastEmitted != null && !equals(fixWhitespace(lastEmitted),getCurrentBuffer(new char[0]))) {
        discardCharTokens(currentPhrase,unusedTokens);
        currentSetToCheck=null;
        if (unusedTokens.size() > 0) {
          Token aToken=unusedTokens.remove(0);
          Log.debug("String_Node_Str");
          emit(aToken);
          return true;
        }
      }
    }
    if (lastEmitted == null && (currentPhrase != null && currentPhrase.length() > 0)) {
      char[] lastTok=getCurrentBuffer(new char[0]);
      if (currentSetToCheck.contains(lastTok,0,lastTok.length)) {
        emit(lastTok);
        currentPhrase.setLength(0);
        return true;
      }
 else       if (!emitSingleTokens) {
        discardCharTokens(currentPhrase,unusedTokens);
        currentSetToCheck=null;
        currentPhrase.setLength(0);
        if (unusedTokens.size() > 0) {
          Token aToken=unusedTokens.remove(0);
          Log.debug("String_Node_Str");
          emit(aToken);
          return true;
        }
      }
    }
    return false;
  }
  if (emitSingleTokens) {
    lastToken=nextToken;
  }
  if (currentSetToCheck == null || currentSetToCheck.size() == 0) {
    Log.debug("String_Node_Str" + new String(nextToken) + "String_Node_Str");
    if (phraseMap.keySet().contains(nextToken,0,nextToken.length)) {
      currentSetToCheck=phraseMap.get(nextToken,0,nextToken.length);
      if (currentPhrase == null)       currentPhrase=new StringBuffer();
 else       currentPhrase.setLength(0);
      currentPhrase.append(nextToken);
      return incrementToken();
    }
 else {
      emit(nextToken);
      lastToken=null;
      return true;
    }
  }
 else {
    char[] currentBuffer=getCurrentBuffer(nextToken);
    if (currentSetToCheck.contains(currentBuffer,0,currentBuffer.length)) {
      currentSetToCheck=remove(currentSetToCheck,currentBuffer);
      if (currentSetToCheck.size() == 0) {
        emit(currentBuffer);
        lastValid=null;
      }
 else {
        if (emitSingleTokens) {
          lastToken=currentBuffer;
          return true;
        }
        lastValid=currentBuffer;
      }
      if (phraseMap.keySet().contains(nextToken,0,nextToken.length)) {
        currentSetToCheck=phraseMap.get(nextToken,0,nextToken.length);
        if (currentPhrase == null)         currentPhrase=new StringBuffer();
 else         currentPhrase.setLength(0);
        currentPhrase.append(nextToken);
      }
      return (lastValid != null) ? incrementToken() : true;
    }
    if (phraseMap.keySet().contains(nextToken,0,nextToken.length)) {
      CharArraySet newSet=phraseMap.get(nextToken,0,nextToken.length);
      Iterator<Object> phraseIt=newSet.iterator();
      while (phraseIt != null && phraseIt.hasNext()) {
        char[] phrase=(char[])phraseIt.next();
        currentSetToCheck.add(phrase);
      }
    }
    Iterator<Object> phraseIt=currentSetToCheck.iterator();
    while (phraseIt != null && phraseIt.hasNext()) {
      char[] phrase=(char[])phraseIt.next();
      if (startsWith(phrase,currentBuffer)) {
        return incrementToken();
      }
    }
    if (lastValid != null) {
      emit(lastValid);
      lastValid=null;
      return true;
    }
    if (!emitSingleTokens) {
      discardCharTokens(currentPhrase,unusedTokens);
      currentPhrase.setLength(0);
      currentSetToCheck=null;
      if (unusedTokens.size() > 0) {
        Token aToken=unusedTokens.remove(0);
        Log.debug("String_Node_Str");
        emit(aToken);
        return true;
      }
    }
    currentSetToCheck=null;
    Log.debug("String_Node_Str");
    return incrementToken();
  }
}