Mark Womack wrote:
I was looking at the usage of the ReadWriterLock class the Category code as an example for my similar modification to the PluginRegistry.
Shouldn't all the releaseWriteLock() and releaseReadLock() calls be contained in finally blocks? Unless we are absolutely sure that an exception cannot be thrown in that code, it seems like a good defensive coding style. Otherwise the lock counts could get out of whack at some point.
Absolutely!
Anything that is a precious resource like database connections, locks, threads, etc. must be cleaned up in a finally clause. Otherwise you will run into all sorts of problems. You can prove that when you use a database connection pool and exceptions prevent the releasing of the connection back to the pool. You will eventually run out.
That is a MUST.
Oh yeah, that goes for open file streams as well.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]