groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (GROOVY-8805) GroovyScriptEngine reload fails when dependent class is deleted
Date Fri, 21 Sep 2018 19:55:00 GMT


ASF GitHub Bot commented on GROOVY-8805:

GitHub user gclayburg opened a pull request:

    GROOVY-8805 reloading a script under GroovyScriptEngine should succee…

    …d when dependent class is deleted

You can merge this pull request into a Git repository by running:

    $ git pull GROOVY_2_5_X

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #799
commit b56ba11d335f969682b151719f5ad278bb695d9c
Author: Gary Clayburg <gclaybur@...>
Date:   2018-09-21T19:50:23Z

    GROOVY-8805 reloading a script under GroovyScriptEngine should succeed when dependent
class is deleted


> GroovyScriptEngine reload fails when dependent class is deleted
> ---------------------------------------------------------------
>                 Key: GROOVY-8805
>                 URL:
>             Project: Groovy
>          Issue Type: Bug
>          Components: GroovyScriptEngine
>    Affects Versions: 2.4.15, 2.5.2
>            Reporter: Gary Clayburg
>            Priority: Major
> When using GroovyScriptEngine.loadScriptByName(scriptName), the reloading will fail with
a groovy.util.ResourceException if a dependent class has been removed from the script root
filesystem.  To reproduce this issue, start with a script and a dependent class:
> ClassA.groovy
> {code:java}
> DependentClass ic = new DependentClass(){code}
>  DependentClass.groovy
> {code:java}
>  class DependentClass {}
> {code}
> When these classes are initially compiled with GroovyScriptEngine, things work fine. 
There are no errors when loading the script like this:
> {code:java}
> gse.loadScriptByName('ClassA.groovy'){code}
> However, once DependentClass.groovy is completely removed from the filesystem and ClassA
is modified to remove the reference, the same gse.loadScriptByName('ClassA.groovy') will fail
with a groovy.utilResourceExeption. 
> It appears GroovyScriptEngine keeps a dependency cache and gets confused in this case. 
The line that fails is a check for lastModifedTime of this dependency.  The dependency of
course no longer exists, but the check for lastModiedTime occurs before ClassA compile has
been attempted.
> I am working on a PR that fixes this.  It seems to me that inside gse.isSourceNewer(entry),
it can just treat a ResourceException during getLastModifed(scriptName) as an indication to
just attempt a recompile instead of throwing the exception.

This message was sent by Atlassian JIRA

View raw message