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

Mike,

I tried to add some debug to FSIndexOutput and made another observation which 
makes this issue even odder! I added a boolean variable to FSIndexOutput with 
the name isOpen. I don't do anything with this variable, I just change the 
close() method from:

  public void close() throws IOException {
    super.close();
    file.close();
  }

to 

  public void close() throws IOException {
    super.close();
    file.close();
    isOpen = false;
  }

and suddenly the problem disappears! Now I change close() to

  public void close() throws IOException {
    super.close();
    isOpen = false;
    file.close();
  }

and the IOException occurs again. Notice that I don't use isOpen anywhere else 
in the code. So it seems that the problem only occurs if file.close() is the 
last instruction in close(). I bet this is a JVM bug, maybe the compiler makes 
some kind of optimization (maybe early freeing up the resources of the method's 
context that are on the stack while the last instruction of the method is being 
executed). So I'm not completely sure what the real problem is, but I'm pretty 
sure it is a JVM bug.


> 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