[
https://issues.apache.org/jira/browse/LUCENE-4165?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401359#comment-13401359
]
Uwe Schindler commented on LUCENE-4165:
---------------------------------------
If you close the Reader it automatically closes all underlying streams (see
docs). So: No, you simply wrap any readers around in your code and let GC do
its work. Reader dont allocate any resources like file handles whatever.
InputStreamReader just wraps a CharsetDecoder on top. Buffers it allocates will
be freed by GC.
So just take the IS as got from caller, do something with it (e.g. wrap a
Reader on top) and then return method without doing anything. Closing any
wrapped readers would break the contract. If the caller closes the InputStream
he releases resources.
> HunspellDictionary - AffixFile Reader closed, Dictionary Readers left unclosed
> ------------------------------------------------------------------------------
>
> Key: LUCENE-4165
> URL: https://issues.apache.org/jira/browse/LUCENE-4165
> Project: Lucene - Java
> Issue Type: Bug
> Components: modules/analysis
> Affects Versions: 3.6
> Environment: Linux, Java 1.6
> Reporter: Torsten Krah
> Priority: Minor
> Attachments: lucene_36.patch, lucene_trunk.patch
>
>
> The HunspellDictionary takes an InputStream for affix file and a List of
> Streams for dictionaries.
> Javadoc is not clear about i have to close those stream myself or the
> Dictionary constructor does this already.
> Looking at the code, at least reader.close() is called when the affix file is
> read via readAffixFile() method (although closing streams is not done in a
> finally block - so the constructor may fail to do so).
> The readDictionaryFile() method does miss the call to close the reader in
> contrast to readAffixFile().
> So the question here is - have i have to close the streams myself after
> instantiating the dictionary?
> Or is the close call only missing for the dictionary streams?
> Either way, please add the close calls in a safe manner or clarify javadoc so
> i have to do this myself.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]