John Doe created LUCENE-8294:
--------------------------------

             Summary: KeywordTokenizer hangs with user misconfigured inputs
                 Key: LUCENE-8294
                 URL: https://issues.apache.org/jira/browse/LUCENE-8294
             Project: Lucene - Core
          Issue Type: Bug
    Affects Versions: 2.1
            Reporter: John Doe


When a user configures the bufferSize to be 0, the while loop in 
KeywordTokenizer.next() function hangs endlessly. Here is the code snippet.

{code:java}
  public KeywordTokenizer(Reader input, int bufferSize) {
    super(input);
    this.buffer = new char[bufferSize];//bufferSize is misconfigured with 0
    this.done = false;
  }

  public Token next() throws IOException {
    if (!done) {
      done = true;
      StringBuffer buffer = new StringBuffer();
      int length;
      while (true) {
        length = input.read(this.buffer); //length is always 0 when the 
buffer.size == 0
        if (length == -1) break;

        buffer.append(this.buffer, 0, length);
      }
      String text = buffer.toString();
      return new Token(text, 0, text.length());
    }
    return null;
  }
{code}




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to