commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Sanders" <ssand...@nextance.com>
Subject RE: [Collections] Array Stack throws NPE on push() but not add()
Date Sat, 14 Sep 2002 01:39:55 GMT
I will commit the change then next week, unless there is a dissenting
opinion.

Scott

> -----Original Message-----
> From: Steve Downey [mailto:steve.downey@netfolio.com] 
> Sent: Friday, September 13, 2002 5:59 PM
> To: Jakarta Commons Developers List
> Subject: Re: [Collections] Array Stack throws NPE on push() 
> but not add()
> 
> 
> I can't see any reason for it to throw an exception. In fact, 
> it even has a 
> specific check for == null, and throws the exception specifically.
> 
> In general collections should only throw a null pointer 
> exception when it has 
> to. And then as a side effect of calling a method on a null object.
> 
> On Friday 13 September 2002 08:20 pm, Scott Sanders wrote:
> > I am trying to use ArrayStack as a sort of sparse stack 
> (most elements 
> > are null), and noticed that push guards against null, whereas add() 
> > does not.  For example:
> >
> > 1. stack.push(null) throws NPE
> > 2. stack.add(null) works fine
> >
> > Which one is incorrect?  I believe that these should be 
> symmetric, but 
> > which way? I actually don't want to guard against null in 
> either.  If 
> > the decision is for guarding, do I just extend and override 
> or does it 
> > have a place in collections?
> >
> > Cheers,
> > Scott Sanders
> >
> > Perfection is achieved, not when there is nothing more to add, but 
> > when there is nothing left to take away. - Antoine de Saint-Exupery
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:commons-dev-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <mailto:commons-dev-help@jakarta.apache.org>
> 
> 

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


Mime
View raw message