diff --git a/src/main/java/net/sf/jsqlparser/parser/SimpleCharStream.java b/src/main/java/net/sf/jsqlparser/parser/SimpleCharStream.java index 8515d1cc1..bf296b7bf 100644 --- a/src/main/java/net/sf/jsqlparser/parser/SimpleCharStream.java +++ b/src/main/java/net/sf/jsqlparser/parser/SimpleCharStream.java @@ -51,6 +51,9 @@ public class SimpleCharStream { // line, column and absolute position of each match begun since the last positionSpecialTokens() private int[] matchBegins = new int[24]; private int matchBeginCount = 0; + // signals the end of input to the token manager, which discards it; created once per stream + // because filling in the stack trace of the deep lookahead recursion dominates short inputs + private java.io.IOException endOfInput; int bufsize; int available; int tokenBegin; @@ -200,7 +203,10 @@ protected void FillBuff() throws java.io.IOException { try { if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) { inputStream.close(); - throw new java.io.IOException(); + if (endOfInput == null) { + endOfInput = new java.io.IOException(); + } + throw endOfInput; } else { maxNextCharInd += i; }