commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: [Digester] Digester.peek very verbose..
Date Sat, 15 Jun 2002 03:46:11 GMT


On 15 Jun 2002, Martin van den Bemt wrote:

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


Mime
View raw message