Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#42 Thread safety

open
nobody
5
2008-12-01
2008-12-01
Eric Lafortune
No

Thanks for a great tool. Looking at the source code, I get the impression there might still be a few small issues with thread safety. Please correct me if I'm wrong, since I'm not intimately familiar with the design or the implementation.

I've looked at the code of version 0.9.1 and the code in CVS.

- ConnectionPool.java, line 184:
If another thread or even multiple threads have
incremented nextAvailableConnection right before
this statement, you might get another
IndexOutOfBoundsException (while catching this
IndexOutOfBoundsException).

- ConnectionPool.java, line 430:
Conceivably, the value of isConnectionPoolUp()
changes inbetween testing it, first for acquiring
and then for releasing the write lock. That would
result in inconsistent states or even deadlocks.

Some even smaller issues:

- The code acquires/releases locks inside try/finally
blocks. The recommended pattern is to acquire
the lock right _before_ the try block, in case
acquiring the lock fails for whatever reason.

- ProxyConnection.java, line 284:
The lock statusReadWriteLock is only ever used
for getting and acquiring a write lock. That
effectively seems the same as synchronizing
the method.

Discussion