lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael McCandless (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LUCENE-7584) Potential leak issue
Date Fri, 09 Dec 2016 22:53:58 GMT

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

Michael McCandless commented on LUCENE-7584:
--------------------------------------------

Hmm which version of Lucene is this?  It looks quite old ... newer versions of Lucene put
compound file writing under codec control.

Also, I don't think there's a leak in the above code, because if {{createOutput}} throws any
exception, it must not leave any file handles open; this is part of its contract.

> Potential leak issue
> --------------------
>
>                 Key: LUCENE-7584
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7584
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Jaechang Nam
>            Priority: Trivial
>
> May the following method have a potential leak like LUCENE-3251 when  directory.createOutput(fileName)
throws IOException?
> (Found the code from the recent code snapshot)
> lucene/src/java/org/apache/lucene/index/CompoundFileWriter.java
> {noformat}
>    public void close() throws IOException {
>         if (merged)
>             throw new IllegalStateException("Merge already performed");
>         if (entries.isEmpty())
>             throw new IllegalStateException("No entries to merge have been defined");
>         merged = true;
>         // open the compound stream
>         IndexOutput os = directory.createOutput(fileName);
>         IOException priorException = null;
>         try {
>             // Write the Version info - must be a VInt because CFR reads a VInt
>             // in older versions!
>             os.writeVInt(FORMAT_CURRENT);
>             // Write the number of entries
>             os.writeVInt(entries.size());
>             // Write the directory with all offsets at 0.
>             // Remember the positions of directory entries so that we can
>             // adjust the offsets later
>             long totalSize = 0;
>             for (FileEntry fe : entries) {
>                 fe.directoryOffset = os.getFilePointer();
>                 os.writeLong(0);    // for now
>                 os.writeString(IndexFileNames.stripSegmentName(fe.file));
>                 totalSize += directory.fileLength(fe.file);
>             }
>             // Pre-allocate size of file as optimization --
> ...
>         } catch (IOException e) {
>           priorException = e;
>         } finally {
>           IOUtils.closeSafely(priorException, os);
>         }
>     }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message