lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shai Erera <ser...@gmail.com>
Subject Re: SnapshotDeletionPolicy throws NPE if no commit happened
Date Thu, 15 Apr 2010 08:34:05 GMT
BTW, even if it's a stupid thing to do, someone can today create SDP and
call snapshot without ever creating IW. And it's not an impossible scenario.
Consider a backup-aware application which creates SDP first, then passes it
to the indexing process and the backup process, separately. The backup
process doesn't need to know of IW at all, and might call snapshot() before
IW was even created, and SDP.onInit was called. It's a possibility, not
saying it's a great and safe architecture.

So this is really about do we want to write clear protective code, or allow
the NPE?

Shai

2010/4/15 Shai Erera <serera@gmail.com>

> Well ... one can still call commit() or close() right after IW creation.
> And this is a very rare case to be hit by. Was just asking about whether we
> want to add an explicit and clear protective code about it or not.
>
> Shai
>
>
> On Thu, Apr 15, 2010 at 10:26 AM, Earwin Burrfoot <earwin@gmail.com>wrote:
>
>> We should just let IW create a null commit on an empty directory, like
>> it always did ;)
>> Then a whole class of such problems disappears.
>>
>> On Thu, Apr 15, 2010 at 11:16, Shai Erera <serera@gmail.com> wrote:
>> > SDP throws NPE if the index includes no commits, but snapshot() is
>> called.
>> > This is an extreme case, but can happen if one takes snapshots (for
>> backup
>> > purposes for example) in a separate code segment than indexing, and does
>> not
>> > know if commit was called or not.
>> >
>> > I think we should throw an IllegalStateException instead of falling on
>> NPE,
>> > w/ a descriptive message. Alternatively, we can just return null and
>> > document it ... But I prefer the ISE instead. What do you think?
>> >
>> > Shai
>> >
>>
>>
>>
>> --
>> Kirill Zakharenko/Кирилл Захаренко (earwin@gmail.com)
>> Home / Mobile: +7 (495) 683-567-4 / +7 (903) 5-888-423
>> ICQ: 104465785
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-dev-help@lucene.apache.org
>>
>>
>

Mime
View raw message