diff --git a/ksql-parser/src/main/java/io/confluent/ksql/parser/SchemaParser.java b/ksql-parser/src/main/java/io/confluent/ksql/parser/SchemaParser.java index f4490a5a83ff..0b54f2bcd896 100644 --- a/ksql-parser/src/main/java/io/confluent/ksql/parser/SchemaParser.java +++ b/ksql-parser/src/main/java/io/confluent/ksql/parser/SchemaParser.java @@ -44,7 +44,7 @@ public static TableElements parse(final String schema) { final CommonTokenStream tokStream = new CommonTokenStream(lexer); final SqlBaseParser parser = new SqlBaseParser(tokStream); - parser.addErrorListener(new BaseErrorListener() { + final BaseErrorListener errorListener = new BaseErrorListener() { @Override public void syntaxError( final Recognizer recognizer, @@ -61,7 +61,13 @@ public void syntaxError( msg), e); } - }); + }; + + lexer.removeErrorListeners(); + lexer.addErrorListener(errorListener); + + parser.removeErrorListeners(); + parser.addErrorListener(errorListener); final List elements = parser.tableElements().tableElement() .stream()