File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
hibernate-core/src/main/java/org/hibernate
metamodel/mapping/ordering Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -73,8 +73,13 @@ private static OrderingParser.OrderByFragmentContext buildParseTree(String fragm
7373 return parser .orderByFragment ();
7474 }
7575 catch (ParseCancellationException e ) {
76+ // When resetting the parser, its CommonTokenStream will seek(0) i.e. restart emitting buffered tokens.
77+ // This is enough when reusing the lexer and parser, and it would be wrong to also reset the lexer.
78+ // Resetting the lexer causes it to hand out tokens again from the start, which will then append to the
79+ // CommonTokenStream and cause a wrong parse
80+ // lexer.reset();
81+
7682 // reset the input token stream and parser state
77- lexer .reset ();
7883 parser .reset ();
7984
8085 // fall back to LL(k)-based parsing
Original file line number Diff line number Diff line change @@ -104,9 +104,14 @@ private HqlParser.StatementContext parseHql(String hql) {
104104 try {
105105 return hqlParser .statement ();
106106 }
107- catch ( ParseCancellationException e ) {
107+ catch (ParseCancellationException e ) {
108+ // When resetting the parser, its CommonTokenStream will seek(0) i.e. restart emitting buffered tokens.
109+ // This is enough when reusing the lexer and parser, and it would be wrong to also reset the lexer.
110+ // Resetting the lexer causes it to hand out tokens again from the start, which will then append to the
111+ // CommonTokenStream and cause a wrong parse
112+ // hqlLexer.reset();
113+
108114 // reset the input token stream and parser state
109- hqlLexer .reset ();
110115 hqlParser .reset ();
111116
112117 // fall back to LL(k)-based parsing
You can’t perform that action at this time.
0 commit comments