Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.6.4
-
Fix Version/s: 1.6.5, 1.7-beta-2
-
Component/s: JSR / TCK / GLS
-
Labels:None
-
Number of attachments :
Description
Example:
import java.lang.*
This causes:
... Caused by: javax.script.ScriptException at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:306) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:113) ... 92 more Caused by: java.lang.NullPointerException at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:253)
The reason is that GroovyScriptEngineImpl.getScriptClass() returns null in this case (I tried to understand why but couldn't).
Since it's null the eval() method fails at line 253.
Note that there was another error hiding this error, this time caused by livetribe, which is now fixed in livetribe 2.0.6. You can see more information here:
http://jira.xwiki.org/jira/browse/XWIKI-4246
Thanks
I would like to work on it, but I need one clarification:
NPE can easily be avoided by a check that if GroovyClassLoader.parseClass() returned null, then GroovyScriptEngineImpl can throw javax.script.ScriptException("script class is null") or with a more appropriate message.
My question is whether GroovyClassLoader should fail to generate a class for the script string
import java.lang.*in the first place. I thought that it would generate a script class even in this case