You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Robert Newson (JIRA)" <ji...@apache.org> on 2007/02/06 17:24:05 UTC

[jira] Commented: (LUCENE-669) finalize()-methods of FSDirectory.FSIndexInput and FSDirectory.FSIndexOutput try to close already closed file

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

Robert Newson commented on LUCENE-669:
--------------------------------------


The close() method in RandomAccessFile is defined not to throw IOException if it's merely closed twice. The bug here is with the IBM JDK and not Lucene. 

This stanza;

final RandomAccessFile raf = new RandomAccessFile("/tmp/raf", "rw");
		for (int i = 0; i < 1000; i++) {
			raf.close();
		}

should run fine everywhere, according to Javadocs;

file:///home/rnewson/Documents/jdk-1.5/api/java/io/Closeable.html#close()
"Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect."

This behavior was clarified with the introduction of the Closeable interface in 1.5, so perhaps IBM are not to blame for this. 

> finalize()-methods of FSDirectory.FSIndexInput and FSDirectory.FSIndexOutput try to close already closed file
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-669
>                 URL: https://issues.apache.org/jira/browse/LUCENE-669
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Store
>            Reporter: Michael Busch
>         Assigned To: Michael Busch
>            Priority: Trivial
>             Fix For: 2.1
>
>         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.
-
You can reply to this email to add a comment to the issue online.


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