Skip to content

Apache Lucene open-source search software

SOLR-11314: FastCharStream: re-use the READ_PAST_EOF exception

David Smiley89feb1500848
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index be89fb1880f..f652fb2d60d 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -139,6 +139,8 @@ Optimizations
* SOLR-11242: QueryParser: re-use the LookaheadSuccess exception. (Michael Braun via David Smiley)
+* SOLR-11314: FastCharStream: re-use the READ_PAST_EOF exception. (Michael Braun via David Smiley)
+
Other Changes
----------------------
diff --git a/solr/core/src/java/org/apache/solr/parser/FastCharStream.java b/solr/core/src/java/org/apache/solr/parser/FastCharStream.java
index 7039c0a582e..b9cb27abd9d 100644
--- a/solr/core/src/java/org/apache/solr/parser/FastCharStream.java
+++ b/solr/core/src/java/org/apache/solr/parser/FastCharStream.java
@@ -69,7 +69,7 @@ public final class FastCharStream implements CharStream {
int charsRead = // fill space in buffer
input.read(buffer, newPosition, buffer.length-newPosition);
if (charsRead == -1)
- throw new IOException("read past eof");
+ throw READ_PAST_EOF;
else
bufferLength += charsRead;
}
@@ -80,6 +80,11 @@ public final class FastCharStream implements CharStream {
return readChar();
}
+ /**
+ * This Exception is used as a signal rather than an exceptional state.
+ */
+ private static final IOException READ_PAST_EOF = new IOException("read past eof");
+
@Override
public final void backup(int amount) {
bufferPosition -= amount;