On 15 Jun 2002, Martin van den Bemt wrote:
> Date: 15 Jun 2002 00:05:24 +0200
> From: Martin van den Bemt <[EMAIL PROTECTED]>
> Reply-To: Jakarta Commons Developers List <[EMAIL PROTECTED]>
> To: Jakarta Commons Developers List <[EMAIL PROTECTED]>
> Subject: [Digester] Digester.peek very verbose..
>
> Hi,
>
> I just fixed some "annoying" message we got in betwixt saying "[WARN]
> Empty stack return null".
>
> on the Digester.peek() methods and the pop() method it is documented
> that it will return null when there are no more objects on the stack. So
> I think it can be assumed that developers know they have to check for
> null, which makes the loglevel of WARN to verbose for these methods.
>
> Anyone in favour of moving it to DEBUG or TRACE level ?
>
I'm not in favor of this, but not adamantly opposed either.
It's a common programming mistake to attempt to pop a stack more times
than you have pushed -- and hiding the corresponding log message makes it
more likely that naive developers will end up with an NPE someplace, which
is generally harder to debug.
Besides, avoiding this message is trivially simple:
Object peekObject = null;
if (digester.getCount() > 0) {
peekObject = digester.peek();
} else {
... something is wrong ... there is nothing on the stack! ...
}
Personally, I'd rather "annoy" folks into defenseive programming :-).
> Mvgr,
> Martin
>
Craig
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>