On Sun, 2007-07-08 at 15:51 +0200, Roland Weber wrote:
> Sorry, I hadn't reviewed that patch before...
> 
> > +    // non-Javadoc, see interface HttpRequestInterceptorList
> > +    public void addRequestInterceptor(final HttpRequestInterceptor itcp, 
> > int index) {
> > +        
> > +        if (itcp == null) {
> > +            return;
> > +        }
> > +        if (this.requestInterceptors == null) {
> > +            this.requestInterceptors = new ArrayList();
> > +        }
> > +        
> > +        if (index == Integer.MAX_VALUE) {
> > +            // Add last
> > +            this.requestInterceptors.add(this.requestInterceptors.size() - 
> > 1, itcp);
> > +        } else {
> > +            // Insert at preferred index
> > +            this.requestInterceptors.add(index, itcp);
> > +        }
> > +    }
> 
> This does leave room for IndexOutOfRangeExceptions, which is not
> what I had in mind. Can you please change that to...
> 
>   if ((index < 0) || (index > this.requestInterceptors.size())
>      index = this.requestInterceptors.size();
>   this.requestInterceptors.add(index, itcp);
> 
> and likewise for the response interceptors?
> 

Roland,

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? 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'll make the change if you think it is what you want.

Oleg 


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


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

Reply via email to