You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Martin van den Bemt <ml...@mvdb.net> on 2002/06/15 00:05:24 UTC

[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 ?

Mvgr,
Martin





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Digester] Digester.peek very verbose..

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On 15 Jun 2002, Martin van den Bemt wrote:

> Date: 15 Jun 2002 00:05:24 +0200
> From: Martin van den Bemt <ml...@mvdb.net>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> 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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>