[jira] [Commented] (GROOVY-8056) GroovyCodeSource(URL) can leak a file handler

2017-06-03 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on GROOVY-8056:


Github user jwagenleitner closed the pull request at:

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


> 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.(Unknown Source)
>   at java.io.FileInputStream.(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.(GroovyCodeSource.java:176)
>   at 
> groovy.text.markup.MarkupTemplateEngine$MarkupTemplateMaker.(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)


[jira] [Commented] (GROOVY-8056) GroovyCodeSource(URL) can leak a file handler

2017-06-03 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on GROOVY-8056:


Github user jwagenleitner closed the pull request at:

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


> 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.(Unknown Source)
>   at java.io.FileInputStream.(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.(GroovyCodeSource.java:176)
>   at 
> groovy.text.markup.MarkupTemplateEngine$MarkupTemplateMaker.(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)


[jira] [Commented] (GROOVY-8056) GroovyCodeSource(URL) can leak a file handler

2017-06-03 Thread ASF GitHub Bot (JIRA)

[ 
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 
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.(Unknown Source)
>   at java.io.FileInputStream.(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.(GroovyCodeSource.java:176)
>   at 
> groovy.text.markup.MarkupTemplateEngine$MarkupTemplateMaker.(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)


[jira] [Commented] (GROOVY-8056) GroovyCodeSource(URL) can leak a file handler

2017-02-18 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on GROOVY-8056:


GitHub user jwagenleitner opened a pull request:

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

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

URLConnect.getContentEncoding returns the Content-Encoding
HTTP Header [1] which is not a charset.  Since this method would
have either returned null or an invalid charset, the code path
specifying the encoding would normally not have been executed.
The charset may be contained in the Content-Type header, but
rather than attempt to parse that string which would require
closing the connection, this fix avoids opening the connection
and relies on the default charset.

[1] https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11

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

$ git pull https://github.com/jwagenleitner/groovy 
groovy8056-content-encoding

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

https://github.com/apache/groovy/pull/500.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 #500


commit 29a641ccc212d397bdc11d3a995763b88dfe34b5
Author: John Wagenleitner 
Date:   2017-02-19T00:22:49Z

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

URLConnect.getContentEncoding returns the Content-Encoding
HTTP Header [1] which is not a charset.  Since this method would
have either returned null or an invalid charset, the code path
specifying the encoding would normally not have been executed.
The charset may be contained in the Content-Type header, but
rather than attempt to parse that string which would require
closing the connection, this fix avoids opening the connection
and relies on the default charset.

[1] https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11




> 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.(Unknown Source)
>   at java.io.FileInputStream.(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.(GroovyCodeSource.java:176)
>   at 
> groovy.text.markup.MarkupTemplateEngine$MarkupTemplateMaker.(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)


[jira] [Commented] (GROOVY-8056) GroovyCodeSource(URL) can leak a file handler

2017-01-22 Thread John Wagenleitner (JIRA)

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

John Wagenleitner commented on GROOVY-8056:
---

I think {{getContentEncoding()}} is not correct since we are looking for a 
charset but it returns how the content is compressed (i.e., gzip, deflate) that 
is specified in the [Content-Encoding HTTP 
Header|https://tools.ietf.org/html/rfc7231#section-3.1.2.2].

To obtain a charset it's the {{getContentType()}} value and it's in the form 
(when it's present) {{text/html; charset=UTF-8}}.  Futher, I think we could 
skip this call completely if {{"file".equals(url.getProtocol())}} since no 
Content-Type header will be available.

> 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.(Unknown Source)
>   at java.io.FileInputStream.(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.(GroovyCodeSource.java:176)
>   at 
> groovy.text.markup.MarkupTemplateEngine$MarkupTemplateMaker.(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.4#6332)


[jira] [Commented] (GROOVY-8056) GroovyCodeSource(URL) can leak a file handler

2017-01-18 Thread Jochen Theodorou (JIRA)

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

Jochen Theodorou commented on GROOVY-8056:
--

Yes, this should not happen... I hope that this then really solves the problem 
on the spring-boot side, since Windows tends to not close file handles right 
away and just because we close may not mean windows closes it at that time too. 
But anyway, this needs to be fixed

> 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.(Unknown Source)
>   at java.io.FileInputStream.(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.(GroovyCodeSource.java:176)
>   at 
> groovy.text.markup.MarkupTemplateEngine$MarkupTemplateMaker.(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.4#6332)