Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.1.3
-
None
-
None
Description
Previously evaluation of the same script (but different String instances) led to reading script class from cache, now if different String instances are used for script text, the value is not found in cache, so that script engine compiles the same script again and adds new Class instance to the classMap.
This leads to inefficient caching, and also may cause memory leak.
Please consider the following code sample:
e = new org.codehaus.groovy.jsr223.GroovyScriptEngineImpl() println e.eval('System.identityHashCode(this.getClass())') println e.eval('System.identityHashCode(this.getClass())') println e.eval(new String('System.identityHashCode(this.getClass())'))
In groovy 1.7 it produced 3 identical lines in output.
In groovy 2.1.3 the third line differs from previous two.