Fridman Viktor created GROOVY-11391:
---------------------------------------
Summary: GroovyClassLoader hangs on parsing certain types of
scripts
Key: GROOVY-11391
URL: https://issues.apache.org/jira/browse/GROOVY-11391
Project: Groovy
Issue Type: Bug
Reporter: Fridman Viktor
Attachments: image-2024-05-30-13-32-34-933.png
i have a simple sample of code:
{code:java}
String script = "import com.atlassian.jira.component.ComponentAccessor\n" +
"\n" +
"Set<String> asdf1 = [\n" +
" \"abc\"\n" +
"] as Set<String>\n" +
"\n" +
"Set<String> asdf2 = [\n" +
" \"def\"\n" +
"] as Set<String>\n" +
"\n" +
"Set<String> asdf3 = [\n" +
" \"qwer\",\n" +
" \"wert\"\n" +
"] as Set<String>\n" +
"\n" +
"Set<String> asdf4 = [\n" +
" \"qwerty\"\n" +
"] as Set<String>\n" +
"\n" +
"Set<String> asdf5 = [\n" +
" \"asdvlkjn\",\n" +
" \"asdlvkasdlkvm\",\n" +
" \"asdviamsdov\",\n" +
" \"zxcv\",\n" +
" \"vcxz\",\n" +
" \"xcvb\",\n" +
" \"bvcx\"\n" +
"] as Set<String>\n" +
"\n" +
"Set<String> asdf6 = [ // qwer ty \"asdf\"\n" +
" \"dfbjknsldfkb \",\n" +
" \"bvcxcx\",\n" +
" \"xcvbbv\",\n" +
" \"bvcx\",\n" +
" \"xcvb\"\n" +
"] as Set<String>\n" +
"\n" +
"Set<String> asdf7 = [ //aqwerty\n" +
" \"asdfghj\",\n" +
" \"jhgfdsa\",\n" +
" \"asdfg\",\n" +
" \"gfdsa\"\n" +
"] as Set<String>\n" +
"\n" +
"Set<String> asdf8 = [ //qwerrty\n" +
" \"zxcv\",\n" +
" \"vcxz\",\n" +
" \"xcvbbnm,.\"\n" +
"] as Set<String>";
GroovyClassLoader gcl = new GroovyClassLoader();
GroovyCodeSource codeSource = new GroovyCodeSource(script, "Script",
"/groovy/script");
long l = System.currentTimeMillis();
try {
Class aClass = gcl.parseClass(codeSource);
System.out.println(aClass);
}
catch (Exception e) {
long l1 = System.currentTimeMillis();
System.out.println(l1 - l);
}{code}
code parsing hangs for a looooooooong time.
but if i add ';' after every string like
{code:java}
] as Set<String>{code}
so it will look like
{code:java}
] as Set<String>;{code}
in groovy-script, it works fast.
the problem seems somewhere deep in ParserATNSimulator, its configurations or
predictive parsing at all (seems quite greedy) - randomly stopped debugger
shows that while it hangs:
!image-2024-05-30-13-32-34-933.png|width=423,height=1356!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)