I'm still working through making my own directory, based on JDBC (and yes,
I know, there are some out there already, unsuitable for this reason or
that reason.)

One thing I've noticed is that the Lock procedure in IndexWriter is a
little off, I think.

My normal process on application startup is to get an IndexWriter, just to
make sure an index is there. If I get an exception (FileNotFoundException
for the FSDirectory, for example), I assume the index isn't created
properly, so then I create a new IndexWriter set to create the index.

With a file-based directory, that works well enough - and I realise there
might be a better way to do it (but I don't know it yet.)

However, the SQL-based directory leaves the lock. I think what's happening
is that the IndexWriter constructor (IndexWriter.java:216 from 1.4.3's
souce distribution) is obtaining the lock, but then the synchronized block
(starting at line 227) gets an IOException from
segmentInfos.read(directory), which throws an IOException - but the
writeLock is never explicitly removed once it's obtained.

I would think that a try/finally (or something even more predictable,
like a try/catch tht rethrows the IOException after cleanup) would be
appropriate to clear the lock *provided it's obtained* in the IndexWriter
construction, and it'd make the code that I typically use work regardless
of the specific directory I rely on.

Now, to be sure, I'm VERY FAR from a Lucene expert; am I missing
something? (I can contribute a patch if you'd like.)

-----------------------------------------------------------------------
Joseph B. Ottinger                             http://enigmastation.com
IT Consultant                                    [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to