[ 
https://issues.apache.org/jira/browse/GROOVY-12404?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18114723#comment-18114723
 ] 

ASF GitHub Bot commented on GROOVY-12404:
-----------------------------------------

github-actions[bot] commented on PR #2928:
URL: https://github.com/apache/groovy/pull/2928#issuecomment-5651204992

   ### JMH summary — classic (commit `056a3e1`)
   
   Speedup vs trailing 90-day baseline on gh-pages. Higher = faster.
   `1.00` = in line with history. Per-benchmark ratio, geomean within group.
   Time-per-op units inverted so direction is consistent. The *calibrated*
   column divides out this runner's speed vs the baseline hardware, as
   measured by Groovy-independent pure-Java ruler benchmarks.
   
   | Group  | Speedup | Calibrated | n |
   |--------|---------|------------|---|
   | bench | 0.950 × | 1.033 × | 124 |
   | core | 1.221 × | 1.118 × | 108 |
   | grails | 1.229 × | 1.215 × | 80 |
   
   No benchmark is ≥1.5× slower than its 90-day baseline.
   
   > ⚠️ Runner speed differs ≥15% from the historical baseline hardware for: 
core-hz. Raw speedups are not meaningful for those parts — use the calibrated 
column.
   
   <sub>Runner calibration (this run vs baseline hardware): bench 0.93× (27 
rulers) · core-ag 0.96× (3 rulers) · core-hz 1.37× (3 rulers) · grails-ad 0.97× 
(3 rulers) · grails-ez 1.05× (3 rulers)</sub>
   
   <sub>Baseline: <code>dev/bench/jmh/&lt;part&gt;/classic/data.js</code> on 
gh-pages, trailing 90 days. <a 
href="https://apache.github.io/groovy/dev/bench/jmh/summary.html";>Daily 
dashboard</a> · <a 
href="https://apache.github.io/groovy/dev/bench/jmh/";>Per-suite raw 
data</a></sub>
   
   <!

> GroovyScriptEngine resource loader leaks URLConnections and ignores a custom 
> ResourceConnector
> ----------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12404
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12404
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Daniel Sun
>            Priority: Major
>
> {{groovy.util.GroovyScriptEngine}} resolves dependent sources through 
> {{ResourceConnector.getResourceConnection}}, but several call sites keep only 
> the URL and never close the {{URLConnection}}.
> {{URLConnection}} has no {{close()}} method. The engine already has 
> {{forceClose}} for this (see GROOVY-7186) and uses it from 
> {{loadScriptByName}}. The resource-loader path does not. 
> {{ClassNodeResolver.findClassNode}} only closes the connection when the 
> source is newer; the cache-hit path leaks. Long-running hosts that resolve 
> many scripts can exhaust file descriptors.
> The same resource loader has two further gaps:
> # When the parent class loader is a {{GroovyClassLoader}}, 
> {{ScriptClassLoader}} never calls {{setResLoader()}}. {{new 
> GroovyScriptEngine(rc, new GroovyClassLoader())}} then ignores {{rc}} for 
> {{loadClass}} / {{Class.forName}}.
> # Packaged names are mapped with {{File.separatorChar}}. On Windows the 
> resource name uses a backslash as the separator instead of 
> {{com/example/Foo.groovy}}, which is what {{ClassNodeResolver}} and 
> {{GroovyClassLoader}} already use.
> h3. How to reproduce
> h4. Custom ResourceConnector ignored
> {code:java}
> File dir = File.createTempDir()
> new File(dir, 'Helper.groovy').text = 'class Helper { def ping() { "pong" } }'
> ResourceConnector rc = { String name ->
>     File f = new File(dir, name)
>     if (!f.exists()) throw new ResourceException('missing ' + name)
>     f.toURI().toURL().openConnection()
> }
> def engine = new GroovyScriptEngine(rc, new GroovyClassLoader())
> engine.groovyClassLoader.loadClass('Helper')
> {code}
> h4. Resource-loader connection not closed
> With {{Foo.groovy}} present, install a {{ResourceConnector}} whose 
> {{URLConnection.getInputStream()}} records that it was called, then:
> {code:java}
> engine.groovyClassLoader.resourceLoader.loadGroovySource('Foo')
> {code}
> {{getInputStream()}} is never invoked, so {{forceClose}} did not run.
> h3. Expected result
> * Connections obtained only for their URL are closed with {{forceClose}}.
> * A custom {{ResourceConnector}} is used even when the parent is a 
> {{GroovyClassLoader}}.
> * Resource names for packaged classes use a forward slash on every platform.
> h3. Actual result
> * The resource-loader {{URLConnection}} is left open.
> * {{loadClass('Helper')}} throws {{ClassNotFoundException}} even though 
> {{Helper.groovy}} is visible to the connector.
> * On Windows, connectors that do not rewrite backslashes to slashes fail to 
> find packaged scripts.
> h3. See also
> GROOVY-7186 addressed a similar leak in {{getResourceConnection}} and added 
> {{forceClose}}. The resource-loader path and the cache-hit branch of 
> {{findClassNode}} were not covered.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to