You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Oleg Kalnichevski <ol...@apache.org> on 2007/07/09 11:30:44 UTC

Re: svn commit: r554367 - in /jakarta/httpcomponents/httpcore/trunk: ./ module-main/src/main/java/org/apache/http/protocol/ module-main/src/test/java/org/apache/http/protocol/

On Mon, 2007-07-09 at 11:02 +0200, Roland Weber wrote:
> Oleg Kalnichevski wrote:
> > I would actually expect a IndexOutOfRangeExceptions in case of an
> > invalid index. What if one passes -1 by mistake and gets the interceptor
> > quietly appended to the list last?
> 
> I see. Good point.
> 
> > For the same reason I do not quite
> > like the idea of using Integer.MAX_VALUE, but I have promised to myself
> > to not get into API purity discussions with you.
> 
> I don't like Integer.MAX_VALUE as a magic number either.
> I wrote it only as an example in my JIRA comment, since
> I would map everything beyond the end of the list to
> the end of the list. If we define a single magic number,
> it should be defined as a constant in our interface.
> 
> How about mapping all positive values beyond the end to
> the end of the list, but throwing an exception for
> negatives? That avoids unexpected wrap-around behavior
> near 0, but also avoids querying the size of the list
> if all you want to do is adding something at the end:
> 
> if (index < 0)
>   throw IndexOutOfBoundsException(...);
> if (index > ...size())
>   index = ...size();
> 
> cheers,
>   Roland
> 

Cool. Sounds reasonable to me.

Cheers

Oleg

> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org
> 
> 


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


Re: svn commit: r554367 - in /jakarta/httpcomponents/httpcore/trunk: ./ module-main/src/main/java/org/apache/http/protocol/ module-main/src/test/java/org/apache/http/protocol/

Posted by Roland Weber <os...@dubioso.net>.
Oleg Kalnichevski wrote:
> On Mon, 2007-07-09 at 11:02 +0200, Roland Weber wrote:
>>
>> if (index < 0)
>>   throw IndexOutOfBoundsException(...);
>> if (index > ...size())
>>   index = ...size();
> 
> Cool. Sounds reasonable to me.

I'll take care of it.

cheers,
  Roland


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