Daniel Dekany wrote:

Sunday, December 14, 2003, 5:34:45 PM, Niclas Hedhman wrote:

[snip]


But the real problem with "release always" is that explicitly releasing
all components is a big PITA. try{...}finally{release},
try{...}finally{release}, try{...}finally{release}...


I am not saying that we scrap Stephen's approach, but leverage on it. By requiring release(), yet depend on automatic reclamation, we get both side satisfied, no?
You don't need the try{}finall{ release}, since the times when the exception
is thrown is so seldom that you can safely rely on the automatic reclamation,



I don't think so... however, I admit I'm bit paranoid. :) Consider, some long-term malfunction occurs, e.g. a DB server is stopped, so *all* operation that tries to access that will throw exception. As a result of that, a component pool dries out (since the components are not explicitly released, and GC has long delays), and requests that need that will wait very long for the pool, which will quickly result in traffic jam.


I disagee ...


   Fred fred = null;
   try
   {
       fred = (Fred) m_manager.get( "fred" );

       //
       // do stuff
       //
   }
   catch( Throwable e )
   {
       // do other stuff
   }
   finally
   {
       //
       // explicit release whatever happens
       //

       m_manager.release( fred );
   }

The "finally" clause is gaurantee to run on success or failure.

Stephen.

--

Stephen J. McConnell
mailto:[EMAIL PROTECTED]

|------------------------------------------------|
| Magic by Merlin                                |
| Production by Avalon                           |
|                                                |
| http://avalon.apache.org/merlin                |
| http://dpml.net/                               |
|------------------------------------------------|





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to