Well, I'm running on linux and I thought the problem was that the writer was not being closed but the ioexception is thrown at:
IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(), true); so if I try to close() it in a finally or something it throws a null pointer exception since the exception was throw in the constructor. I'm simulating the exception by hand-creating the index directory and then setting it to read only. that way when the above tries to create the index it throws an exception. I was guessing the delay was is because something else is holding onto the file but I wasn't sure in terms of lucene how to make sure the lock file is deleted if an exception like the above is thrown. On Tue, 2005-11-01 at 11:42 -0800, Chris Hostetter wrote: > 1) how do you simulate the exception? > 2) you didn't say you got a lock timeout error, you said you got a > "couldnt delete the lock file" exception ... is your second test > forcably trying to unlock the index? > 3) are you running this test on a windows machine? > 4) can you post your unit test? > > > If i had to guess... > > You probably aren't closing the writer in your first > test (as a result of the exception) so the write lock it has open isn't > being released untill the GC calls the finalize() method on that object. > > When the tests run normally, the lag for GC is great enough that the lock > file cannot be removed becuase windows won't let you remove a file that is > open. When you run in the debugger, the pause because of the breakpoint > gives the JVM a chance to call the finalize method. > > > > : Date: Tue, 01 Nov 2005 14:39:09 -0500 > : From: Dan Adams <[EMAIL PROTECTED]> > : Reply-To: java-user@lucene.apache.org > : To: java-user@lucene.apache.org > : Subject: lock file race conditions > : > : I have 2 junit tests. The first opens on index writer and then simulates > : have an IOException get throw when trying to add a document. The test > : that runs after than is just a normal test of the search. After the > : first test completes a lock file is left in /tmp. Now, if I run the test > : suite normally I get a "couldnt delete the lock file" exception from the > : second test. If I run it again and set a breakpoint at the beginning of > : the second test, wait a second, and then let it continue it runs fine. > : What is causing this? > : > : -- > : Dan Adams > : Software Engineer > : Interactive Factory > : > : > : --------------------------------------------------------------------- > : To unsubscribe, e-mail: [EMAIL PROTECTED] > : For additional commands, e-mail: [EMAIL PROTECTED] > : > > > > -Hoss > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- Dan Adams Software Engineer Interactive Factory --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]