Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-8805

GroovyScriptEngine reload fails when dependent class is deleted

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.15, 2.5.2
    • 3.0.0-alpha-4
    • GroovyScriptEngine
    • None

    Description

      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

      DependentClass ic = new DependentClass()

       

       DependentClass.groovy

       

       class DependentClass {}
       
      

       

      When these classes are initially compiled with GroovyScriptEngine, things work fine.  There are no errors when loading the script like this:

       

      gse.loadScriptByName('ClassA.groovy')

       

      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.

       

       

      Attachments

        Issue Links

          Activity

            People

              daniel_sun Daniel Sun
              gclaybur@comcast.net Gary Clayburg
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: