avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: Defensive Component Question
Date Wed, 16 Jan 2002 07:55:34 GMT
Leif Mortenson wrote:

> I was trying to get Logging configured by specifying a Configuration and
> a DefaultLogKitManager and ran into a NullPointerException because I had
> not called setLogger() on the DefaultLogKitManager before calling
> configure(). I figured out the problem after digging around in the code,
> but things would have been a lot easier had I gotten an
> IllegalStateException describing the problem or something along those lines.
> Following the examples in the docs, I have been trying to design my
> components to be fairly defensive about their own state by adding checks
> to make sure that say configure is not called before setLogger has been
> correctly called.

There is a utility class in Excalibur's Scratchpad that will help you
out.  I am not at the right computer, so I can't give the full
class name now.  It should be ComponentValidator or something like

> What are peoples thoughts on this? I think that making these classes
> more defensive would also really help shorten the learning curve for new
> users by pointing out mistakes like mine without requiring the user to
> roll up their sleeves and dig into the code.
> Here is the exception that I got:
> java.lang.NullPointerException
> at
> org.apache.avalon.excalibur.logger.DefaultLogTargetFactoryManager.configure(DefaultLogTargetFactoryManager.java:144)
> at
> org.apache.avalon.excalibur.logger.DefaultLogKitManager.setupTargetFactoryManager(DefaultLogKitManager.java:191)
> at
> org.apache.avalon.excalibur.logger.DefaultLogKitManager.configure(DefaultLogKitManager.java:154)
> ... rest of stack trace.
> Thrown on:
> if( getLogger().isDebugEnabled() )
> Cheers,
> Leif
> --
> To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>
> .

Sign Up for NetZero Platinum Today
Only $9.95 per month!

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

View raw message