You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Shai Erera <se...@gmail.com> on 2010/04/15 09:16:25 UTC

SnapshotDeletionPolicy throws NPE if no commit happened

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

Re: SnapshotDeletionPolicy throws NPE if no commit happened

Posted by Michael McCandless <lu...@mikemccandless.com>.
Presumably you'd also hit this exception if the DP deletes all commit
points, right?

I like IllegalStateException.

Mike

2010/4/15 Shai Erera <se...@gmail.com>:
> 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 <se...@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 <ea...@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 <se...@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
>>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Re: SnapshotDeletionPolicy throws NPE if no commit happened

Posted by Shai Erera <se...@gmail.com>.
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 <se...@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 <ea...@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 <se...@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
>>
>>
>

Re: SnapshotDeletionPolicy throws NPE if no commit happened

Posted by Shai Erera <se...@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 <ea...@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 <se...@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
>
>

Re: SnapshotDeletionPolicy throws NPE if no commit happened

Posted by Earwin Burrfoot <ea...@gmail.com>.
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 <se...@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