[ 
https://issues.apache.org/jira/browse/OPENNLP-1948?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Wiesner resolved OPENNLP-1948.
-------------------------------------
    Resolution: Fixed

> Release file handles by MarkableFileInputStreamFactory and the Leipzig reader 
> on close and reset
> ------------------------------------------------------------------------------------------------
>
>                 Key: OPENNLP-1948
>                 URL: https://issues.apache.org/jira/browse/OPENNLP-1948
>             Project: OpenNLP
>          Issue Type: Bug
>    Affects Versions: 2.5.12, 3.0.0-M6
>            Reporter: Richard Zowalla
>            Assignee: Kristian Rickert
>            Priority: Minor
>             Fix For: 2.5.13, 3.0.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> * {{MarkableFileInputStream}} \(opennlp\-formats {{opennlp.tools.util}}\) 
> wraps a {{FileInputStream}} it creates itself but has no {{close\(\)}} 
> override. {{InputStream.close\(\)}} is a no\-op, so closing the stream never 
> closes the file.
> * {{LeipzigLanguageSampleStream.java:70}}: {{\(int\) 
> Files.lines\(sentencesFile.toPath\(\)\).count\(\)}}. The stream from 
> {{Files.lines}} is never closed.
> * {{PlainTextByLineStream.reset\(\)}} \({{opennlp\-api}}, line 73\) creates a 
> new reader without closing the previous one, so every reset leaks one handle.
> Impact: long\-running training or cross\-validation over many files runs into 
> "Too many open files". On Windows, files stay locked.
> Both leaks also exist on 2.x \({{opennlp\-tools}}\).
> _Fix:_
> \* Override {{close\(\)}} in {{MarkableFileInputStream}}.
> \* Use try\-with\-resources around {{Files.lines}}.
> \* Close {{in}} in {{reset\(\)}} before reassigning it.
> PR #1279 \(OPENNLP\-1933\) contains fixes for the first two; they should move 
> here.



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

Reply via email to