Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
1.0-JSR-2
-
None
-
None
Description
The constructor of class "org.codehaus.groovy.control.ErrorCollector" should fail-fast, if it gets a null value as a compiler configuration. Or it should create a default configuration, if that's possible. Otherwise, line 113 might crash as shown below. Or, it should check before each read access to the configuration field.
I got this exception, while implementing a XML template engine using a default GroovyShell instance, i.e. new groovy.lang.GroovyShell().
UNCAUGHT EXCEPTION: null
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:805)
at org.codehaus.groovy.control.CompilationUnit.parse(CompilationUnit.java:502)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:452)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:244)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:530)
at groovy.lang.GroovyShell.parse(GroovyShell.java:542)
at groovy.lang.GroovyShell.parse(GroovyShell.java:521)
at groovy.lang.GroovyShell.parse(GroovyShell.java:560)
at groovy.text.XmlTemplateEngine.createTemplate(XmlTemplateEngine.java:126)
at groovy.text.TemplateEngine.createTemplate(TemplateEngine.java:56)
at TemplatingXml.main(TemplatingXml.java:46)
Caused by: java.lang.NullPointerException
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:113)
at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:153)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:124)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:136)
at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:449)
at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:87)
at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:277)
at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:513)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:801)
... 10 more