Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7.5
-
Fix Version/s: 1.7.6, 1.8-beta-3
-
Component/s: Groovlet / GSP
-
Labels:None
-
Environment:Bug is independent of OS and JVM. I'm running Ubuntu 10.10 with OpenJDK 1.6.0_18.
-
Number of attachments :
Description
isSourceNewer() method in groovy.util.GroovyScriptEngine does evaluate script sources for recompilation (it will return true) in cases where 'nextPossibleRecompilationTime >= lastMod'. This is wrong and results in gratuitous recompilations of scripts.
An ugly side effect of this bug is, that groovlet state (static objects kept in a static class) is being lost between incoming requests, due to gratuitous recompilation and subsequent restart of groovlets.
The attached patch fixes the issue.
Running the two related GroovyScriptEngine (GSE for short) tests make one fail.
You can try running them with
That's GroovyScriptEngineTest which is failing here with your patch.
Any idea why the test is failing?
[junit] Testcase: testReloadingInterval(groovy.util.GroovyScriptEngineTest): FAILED [junit] assert gse.run(scriptName, binding) == 12 [junit] | | | | | [junit] | 1 | | false [junit] | | groovy.lang.Binding@23b17d49 [junit] | gse4241425475617288650.groovy [junit] groovy.util.GroovyScriptEngine@599855ed [junit] junit.framework.AssertionFailedError: assert gse.run(scriptName, binding) == 12 [junit] | | | | | [junit] | 1 | | false [junit] | | groovy.lang.Binding@23b17d49 [junit] | gse4241425475617288650.groovy [junit] groovy.util.GroovyScriptEngine@599855ed [junit] at org.codehaus.groovy.runtime.InvokerHelper.assertFailed(InvokerHelper.java:386) [junit] at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.assertFailed(ScriptBytecodeAdapter.java:658) [junit] at groovy.util.GroovyScriptEngineTest.testReloadingInterval(GroovyScriptEngineTest.groovy:245) [junit]Perhaps in some cases the logic was reloading the class too often... but in this case, the reloading should have happened, but has not with the patch applied.
[junit] Testcase: testReloadingInterval(groovy.util.GroovyScriptEngineTest): FAILED [junit] assert gse.run(scriptName, binding) == 12 [junit] | | | | | [junit] | 1 | | false [junit] | | groovy.lang.Binding@23b17d49 [junit] | gse4241425475617288650.groovy [junit] groovy.util.GroovyScriptEngine@599855ed [junit] junit.framework.AssertionFailedError: assert gse.run(scriptName, binding) == 12 [junit] | | | | | [junit] | 1 | | false [junit] | | groovy.lang.Binding@23b17d49 [junit] | gse4241425475617288650.groovy [junit] groovy.util.GroovyScriptEngine@599855ed [junit] at org.codehaus.groovy.runtime.InvokerHelper.assertFailed(InvokerHelper.java:386) [junit] at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.assertFailed(ScriptBytecodeAdapter.java:658) [junit] at groovy.util.GroovyScriptEngineTest.testReloadingInterval(GroovyScriptEngineTest.groovy:245) [junit]