avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Re: Pooling Problems
Date Wed, 05 Sep 2001 14:59:08 GMT
On Thu, 6 Sep 2001 00:32, Laran Coates wrote:
> Hi there.  I'm working on something using some of the Pooling classes and
> I'm having problems with the Logger in the DefaultPool.
>
> This is more or less what I'm doing.
>
> <code>
>
> class MClass
> extends AbstractLoggable {
>
>   public MClass()
>   {
>      init();
>   }
>
>   void init()
>   {
>
>     Pool mPool =
>       new SoftResourceLimitingPool(
>         Class.forName( "com.blah" ), 1, 10 );
>
>     mPool.setLogger( getLogger() );
>
>     mPool.initialize();
>
>     // Problem happens on next line...
>     System.out.println( mPool.get().toString() );
>
>   }
>
> }
>
> </code>
>
> When I run that code the get() call to the Pool throws a NPE at line 148 in
> DefaultPool.
>
> Am I not initializing the Pool or the Logger properly?
> Anyone got any ideas?

The problem is when MClass.init() is called, MClass has not been passed a 
logger and thuse getLogger() will return null. This is what is causing the 
error.

The solution would be to remove init() from MClass constructory and replace

MClass mClass = new MClass();

with 

MClass mClass = new MClass();
mClass.setLogger( aLogger );
mClass.init();

or something similar.

-- 
Cheers,

Pete

*------------------------------------------------*
| You can't wake a person who is pretending      |
|       to be asleep. -Navajo Proverb.           |
*------------------------------------------------*

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


Mime
View raw message