Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2750 rewrite GroovyScriptEngine
  3. GROOVY-4175

GroovyScriptEngine - loading non file based scripts does not work - isSourceNewer

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.0, 1.7.1, 1.7.2
    • 1.7.4, 1.8-beta-1
    • GroovyScriptEngine
    • None

    Description

      GroovyScriptEngine

      In case of using a custom ResourceConnector the provided resource might not be a file resource (within GroovyClassLoader there is similar code (isSourceNewer) already respecting non file base resources)

       protected boolean isSourceNewer(ScriptCacheEntry entry) throws ResourceException  {
              if (entry==null) return true;
              long time = System.currentTimeMillis();
              
              for (String scriptName:entry.dependencies) {
                  ScriptCacheEntry depEntry = scriptCache.get(scriptName);
                  long entryChangeTime = depEntry.lastModified + config.getMinimumRecompilationInterval();
                  if (entryChangeTime>time) continue;
      
                  URLConnection conn = rc.getResourceConnection(scriptName);
                  URL source = conn.getURL();
      -->         String path = source.getPath().replace('/', File.separatorChar).replace('|', ':');
      -->         File file = new File(path);
                  long lastMod = file.lastModified();
      
                  if (entryChangeTime > lastMod) {
                      ScriptCacheEntry newEntry = new ScriptCacheEntry(depEntry.scriptClass,time,depEntry.dependencies);
                      scriptCache.put(scriptName,newEntry);
                      continue;
                  }
                  return true;
              }
              
              return false;
          }
      

      Attachments

        Issue Links

          Activity

            People

              guillaume Guillaume Sauthier
              arno Arno Töll
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: