groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-8056) GroovyCodeSource(URL) can leak a file handler
Date Sat, 03 Jun 2017 14:56:04 GMT

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

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

GitHub user jwagenleitner opened a pull request:

    https://github.com/apache/groovy/pull/557

    GROOVY-8056: GroovyCodeSource(URL) can leak a file handler

    A safer fix in terms of compatibility compared to PR #500. 

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

    $ git pull https://github.com/jwagenleitner/groovy 8056-urlcon-leak

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

    https://github.com/apache/groovy/pull/557.patch

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

    This closes #557
    
----
commit d99ff70a729448d75d3ca5b98c70733ba1ca428a
Author: John Wagenleitner <jwagenleitner@apache.org>
Date:   2017-06-03T14:50:41Z

    GROOVY-8056: GroovyCodeSource(URL) can leak a file handler

----


> GroovyCodeSource(URL) can leak a file handler
> ---------------------------------------------
>
>                 Key: GROOVY-8056
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8056
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.8
>            Reporter: Andy Wilkinson
>
> When {{GroovyCodeSource}} is created from a {{URL}} it calls {{url.openConnection.getContentEncoding()}}.
When it's a {{file:}} URL, this causes a {{FileInputStream}} to be opened and never closed.
The stack trace for it being opened is:
> {noformat}
> at java.io.FileInputStream.<init>(Unknown Source)
> 	at java.io.FileInputStream.<init>(Unknown Source)
> 	at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
> 	at sun.net.www.protocol.file.FileURLConnection.initializeHeaders(Unknown Source)
> 	at sun.net.www.protocol.file.FileURLConnection.getHeaderField(Unknown Source)
> 	at java.net.URLConnection.getContentEncoding(Unknown Source)
> 	at groovy.lang.GroovyCodeSource.<init>(GroovyCodeSource.java:176)
> 	at groovy.text.markup.MarkupTemplateEngine$MarkupTemplateMaker.<init>(MarkupTemplateEngine.java:222)
> 	at groovy.text.markup.MarkupTemplateEngine.createTemplateByPath(MarkupTemplateEngine.java:145)
> {noformat}
> I believe that keeping a local reference to the {{URLConnection}} and then calling {{getInputStream().close()}}
on it will fix the problem.
> For reference [this|https://github.com/spring-projects/spring-boot/issues/7892] is the
Spring Boot issues where the problem was originally reported.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message