You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Josh Joy <jo...@yahoo.com> on 2007/02/02 01:28:06 UTC
Lucene Javadoc Exception - cause?
Hi,
I was implementing some calls to Lucene, though was
curious if there was
some documentation I was missing that indicated why a
method throws an
exception.
Example, IndexReader - deleteDocuments() - what is the
root cause as to
why it throws IOException?
I'm trying to utilize this info to determine my
exception handling
strategy for all my Lucene API calls (should I fail,
retry, ignore, etc)
Thanks,
Josh
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Lucene Javadoc Exception - cause?
Posted by Michael McCandless <lu...@mikemccandless.com>.
Josh Joy wrote:
> I was implementing some calls to Lucene, though was
> curious if there was
> some documentation I was missing that indicated why a
> method throws an
> exception.
>
> Example, IndexReader - deleteDocuments() - what is the
> root cause as to
> why it throws IOException?
>
> I'm trying to utilize this info to determine my
> exception handling
> strategy for all my Lucene API calls (should I fail,
> retry, ignore, etc)
I agree we don't have enough documentation around why an IOException
might be thrown for the various Lucene methods.
For your example (IndexReader.deleteDocuments) there are some
"interesting" cases that I think we should call out:
* Another "writer" (IndexWriter or IndexReader with pending deletes)
is already open against the index (this will be the "Lock obtain
timed out" IOException).
* The reader is "stale" meaning another writer has committed changes
to the index since this reader was opened.
Then of course index corruption, transient IO problems, permission
problems, etc, can lead to IOExceptions.
I will open a JIRA issue.
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Lucene Javadoc Exception - cause?
Posted by Erick Erickson <er...@gmail.com>.
Well, in the normal course of events, things like deleteDocuments(Term)
shouldn't throw an exception unless I've screwed up. In my experience,
Lucene usually gracefully handles "normal" error cases. In this case, there
not being any underlying documents that match on Term is, I believe, handled
by just returning 0 for the documents deleted.
If the underlying Directory is closed, say, or the index is corrupted or you
might get an error thrown. Neither would be safe to ignore.
Except for a single case in my experience, exceptions are thrown by Lucene
because of a failure that retrying won't solve and ignoring would be a bad
idea. Good programming practice precludes throwing exceptions for
*recoverable* problems.
The only case I can remember where Lucene threw what I thought was an
inappropriate exception was calling a WildcardEnum with a term that had no
wildcard, and that's since been fixed in the trunk.
catching and ignoring errors is not something I'd recommend unless there is
*good* reason to believe that the underlying cause will fix itself. That's
much more common in, say, communications programs where the network can be
flaky than it is in programs like Lucene.
Best
Erick
On 2/1/07, Josh Joy <jo...@yahoo.com> wrote:
>
> Hi,
>
> I was implementing some calls to Lucene, though was
> curious if there was
> some documentation I was missing that indicated why a
> method throws an
> exception.
>
> Example, IndexReader - deleteDocuments() - what is the
> root cause as to
> why it throws IOException?
>
> I'm trying to utilize this info to determine my
> exception handling
> strategy for all my Lucene API calls (should I fail,
> retry, ignore, etc)
>
> Thanks,
> Josh
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>