[jira] [Commented] (CSV-197) CSVParser doesn't close the underlying handle after iteration
[ https://issues.apache.org/jira/browse/CSV-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15962786#comment-15962786 ] Aaron Digulla commented on CSV-197: --- I have never seen a Java library/framework which will close streams that were opened by the user. If you open a stream, you're responsible to close it. What you actually need is a framework which tracks the open streams (and where they were opened) and which warns about leaked resources you when the VM terminates. I would close this as won't fix/works as designed. > CSVParser doesn't close the underlying handle after iteration > - > > Key: CSV-197 > URL: https://issues.apache.org/jira/browse/CSV-197 > Project: Commons CSV > Issue Type: Bug > Components: Parser >Reporter: Prateek Rungta >Priority: Minor > Fix For: Patch Needed, Discussion, 1.4.1 > > > The following code leaks file handles: > {code} > CSVParser parser = // setup parser > for (CSVRecord rec: parser) { > } > // leak > {code} > I'd expect the underlying iterator to close() if it's finished iterating. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (CSV-197) CSVParser doesn't close the underlying handle after iteration
[ https://issues.apache.org/jira/browse/CSV-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15521968#comment-15521968 ] Prateek Rungta commented on CSV-197: Yep, that's what I did once I found the leak. I didn't initially, expecting an Iterable to close the underlying handle. That said, I don't know if it's any clearer than expecting users to maintain the lifecycle themselves. > CSVParser doesn't close the underlying handle after iteration > - > > Key: CSV-197 > URL: https://issues.apache.org/jira/browse/CSV-197 > Project: Commons CSV > Issue Type: Bug > Components: Parser >Reporter: Prateek Rungta >Priority: Minor > Fix For: Patch Needed, Discussion, 1.4.1 > > > The following code leaks file handles: > {code} > CSVParser parser = // setup parser > for (CSVRecord rec: parser) { > } > // leak > {code} > I'd expect the underlying iterator to close() if it's finished iterating. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (CSV-197) CSVParser doesn't close the underlying handle after iteration
[ https://issues.apache.org/jira/browse/CSV-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15519430#comment-15519430 ] Gary Gregory commented on CSV-197: -- The parser implements close() which calls close() on the lexer which closes() the reader. So all you have to do is manage the parser in a try-with-resources block: {code:java} try (final CSVParser parser = CSVParser.parse(...)) { ... } {code} > CSVParser doesn't close the underlying handle after iteration > - > > Key: CSV-197 > URL: https://issues.apache.org/jira/browse/CSV-197 > Project: Commons CSV > Issue Type: Bug > Components: Parser >Reporter: Prateek Rungta >Priority: Minor > Fix For: Patch Needed, Discussion, 1.4.1 > > > The following code leaks file handles: > {code} > CSVParser parser = // setup parser > for (CSVRecord rec: parser) { > } > // leak > {code} > I'd expect the underlying iterator to close() if it's finished iterating. -- This message was sent by Atlassian JIRA (v6.3.4#6332)