Skip to content

Commit

Permalink
bugfix: Fix infinite indexing
Browse files Browse the repository at this point in the history
Turns out one lbirary released broken source without ending quote and this caused the infinite indexing.

Fixes #6418
  • Loading branch information
tgodzik committed May 21, 2024
1 parent 750e0e3 commit 73d78f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ class JavaToplevelMtags(
@tailrec
def quotedLiteral(quote: Char): Token = {
reader.nextChar()

if (reader.endCharOffset >= reader.buf.length)
throw new RuntimeException("Broken file, quote doesn't end.")

reader.ch match {
case `quote` => Token.Literal
case '\\' =>
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/src/test/scala/tests/JavaToplevelSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ class JavaToplevelSuite extends BaseToplevelSuite {
List("dot/enum/Abc#"),
)

check(
"broken",
"""|package dot.enum;
|
|public class Abc {
| public static final String REFERRER_ORIGIN_HOST = "audit.example.org.apache.hadoop.shaded.org.;
|}
|""".stripMargin,
List("dot/enum/Abc#"),
)

check(
"extends",
"""|package dot.example;
Expand Down

0 comments on commit 73d78f5

Please sign in to comment.