On Wed, 2004-04-07 at 05:20, Craig R. McClanahan wrote: > robert burrell donkin wrote: > > > On 5 Apr 2004, at 03:27, Simon Kitching wrote: > > > > <snip> > > > >> You will see in CVS that Robert's new "named stack" pop method does > >> throw an EmptyStackException when an empty stack is popped, and I think > >> that is the correct behaviour. If we do a digester 2.0, I would > >> recommend that the pop() method throw an exception in this case - unless > >> I've missed a good reason for the null to be returned. I can't think of > >> one, though. > > > > > > IIRC i preferred the version that returned null but was persuaded that > > throwing an exception was more consistent with the sun collections API > > and was therefore what users would probably expect. had i check the > > original API and discovered that the rest of digester returned nulls, > > i would probably have changed my mind again. so, i suppose that i > > don't have a strong opinion on what's better :) > > How about going with "to thine own self be true" and copy what we did on > the standard object stack?
I had a look at all the places where Digester.pop() is called. In all cases, popping an empty stack is wrong, and *should* result in an error being reported. I expect that the same applies to Digester.peek(). Unfortunately because of the "null returned on empty stack" solution, what will happen in most of these cases is a NullPointerException at some random time after the real bug (the bad pop) instead of an EmptyStackException at the exact point that the bug occurred. I think having pop throw an EmptyStackException is much nicer, even if it is inconsistent with the current Digester.pop/peek. Regards, Simon > > :-) > > Craig > > > > > - robert > > > > > > --------------------------------------------------------------------- > > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
