[ 
http://issues.apache.org/jira/browse/LUCENE-669?page=comments#action_12454488 ] 
            
Michael McCandless commented on LUCENE-669:
-------------------------------------------

Ugh!  This bug is clearly a heisenbug.

OK, I can also reproduce this on Windows when I use the IBM 1.5.0 JRE.
I can't repro with the Sun 1.5.0_07 JRE.

When I apply your patch, the IOException goes away.

Furthermore, my best efforts to get a standalone test to show the
error have failed.  I don't understand what precise tickling is
required to get the IOException to happen.

Finally, I found this spooky very recent thread on java-user that
looks very much like this error (and was never resolved):

    http://www.gossamer-threads.com/lists/lucene/java-user/40357

I think in this case it was on Sun's JRE.  So I tried the test using
"java -server" but it didn't fail.  Sigh.

My conclusion is: double-closing a RandomAccessFile is dangerous!  And
quite possibly can cause problems for "real" use cases (ie, not just
when testing under Eclipse).

I will commit this patch.

I made a couple of tiny changes: changed the name to "isOpen" and
moved up the "isOpen = true" to be right after the file is actually
opened.

I also like the change to flush the buffer on finalize (if the file is
still open).

Thanks Michael!


> finalize()-methods of FSDirectory.FSIndexInput and FSDirectory.FSIndexOutput 
> try to close already closed file
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-669
>                 URL: http://issues.apache.org/jira/browse/LUCENE-669
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Store
>            Reporter: Michael Busch
>         Assigned To: Michael Busch
>            Priority: Trivial
>         Attachments: FSDirectory_close_file2.patch
>
>
> Hi all,
> I found a small problem in FSDirectory: The finalize()-methods of 
> FSDirectory.FSIndexInput and FSDirectory.FSIndexOutput try to close the 
> underlying file. This is not a problem unless the file has been closed before 
> by calling the close() method. If it has been closed before, the finalize 
> method throws an IOException saying that the file is already closed. Usually 
> this IOException would go unnoticed, because the GarbageCollector, which 
> calls finalize(), just eats it. However, if I use the Eclipse debugger the 
> execution of my code will always be suspended when this exception is thrown.
> Even though this exception probably won't cause problems during normal 
> execution of Lucene, the code becomes cleaner if we apply this small patch. 
> Might this IOException also have a performance impact, if it is thrown very 
> frequently?
> I attached the patch which applies cleanly on the current svn HEAD. All 
> testcases pass and I verfied with the Eclipse debugger that the IOException 
> is not longer thrown.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.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]

Reply via email to