Issue Details (XML | Word | Printable)

Key: LUCENE-669
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Trivial Trivial
Assignee: Michael Busch
Reporter: Michael Busch
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Lucene - Java

finalize()-methods of FSDirectory.FSIndexInput and FSDirectory.FSIndexOutput try to close already closed file

Created: 07/Sep/06 07:46 AM   Updated: 27/Feb/07 06:10 PM
Return to search
Component/s: Store
Affects Version/s: None
Fix Version/s: 2.1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works FSDirectory_close_file2.patch 2006-11-26 06:56 AM Michael Busch 2 kB

Lucene Fields: Patch Available
Resolution Date: 30/Nov/06 12:08 AM


 Description  « Hide
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.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #480785 Thu Nov 30 00:07:46 UTC 2006 mikemccand LUCENE-669: don't double-close RandomAccessFile in finalize
Files Changed
MODIFY /lucene/java/trunk/CHANGES.txt
MODIFY /lucene/java/trunk/src/java/org/apache/lucene/store/FSDirectory.java

Repository Revision Date User Message
ASF #485686 Mon Dec 11 15:01:07 UTC 2006 mikemccand LUCENE-669: I forgot attribution to Michael Busch for this (thanks Michael!)
Files Changed
MODIFY /lucene/java/trunk/CHANGES.txt