Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
3.0.19, 3.0.21, 4.0.21
-
None
-
None
Description
i have a simple sample of code:
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 parsing hangs for a looooooooong time.
but if i add ';' after every string like
] as Set<String>
so it will look like
] as Set<String>;
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:
i understand that the code of script could have errors (for example, import could not be found or smthng else), but i think that the parser hanging is quite abnormal
in pom tried both (separately ofc):
implementation 'org.apache.groovy:groovy-all:4.0.21'
implementation 'org.codehaus.groovy:groovy-all:3.0.21'