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

Dawid Weiss commented on LUCENE-8494:
-------------------------------------

Fair enough, I just looked at that one variable.

> CFS leaks a file on exception opening it
> ----------------------------------------
>
>                 Key: LUCENE-8494
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8494
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/codecs
>            Reporter: Robert Muir
>            Priority: Major
>
> If CFS hits an exception opening its file, it will leak the file handle. 
> Found by Jenkins: https://jenkins.thetaphi.de/job/Lucene-Solr-7.x-Solaris/808/
> {noformat}
>  java.lang.RuntimeException: MockDirectoryWrapper: cannot close: there are 
> still 7 open files: {_j.cfs=1, _h.cfs=1, _e.cfs=1, _g.cfs=1, _i.cfs=1, 
> _k.cfs=1, _f.cfs=1}
> ...
> Caused by: java.lang.RuntimeException: unclosed IndexInput: _f.cfs
>         at 
> org.apache.lucene.store.MockDirectoryWrapper.addFileHandle(MockDirectoryWrapper.java:730)
>         at 
> org.apache.lucene.store.MockDirectoryWrapper.openInput(MockDirectoryWrapper.java:773)
>         at 
> org.apache.lucene.codecs.lucene50.Lucene50CompoundReader.<init>(Lucene50CompoundReader.java:78)
> {noformat}
> Looks like it needs to move opening of {{handle}} into the try block 
> (untested):
> {noformat}
> diff --git 
> a/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50CompoundReader.java
>  
> b/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50CompoundReader.java
> index 7526c88c20..db54ecdee2 100644
> --- 
> a/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50CompoundReader.java
> +++ 
> b/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50CompoundReader.java
> @@ -75,8 +75,8 @@ final class Lucene50CompoundReader extends Directory {
>      }
>      expectedLength += CodecUtil.footerLength(); 
>  
> -    handle = directory.openInput(dataFileName, context);
>      try {
> +      handle = directory.openInput(dataFileName, context);
>        CodecUtil.checkIndexHeader(handle, Lucene50CompoundFormat.DATA_CODEC, 
> version, version, si.getId(), "");
>        
>        // NOTE: data file is too costly to verify checksum against all the 
> bytes on open,
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to