The following methods indirectly read/write field
ConnectionSource.isUsed without holding any lock:
For instance, the following statement in the select method:
Connection connection =
eventually calls ConnectionSource.getConnection(),
which reads and writes field ConnectionSource.isUsed.
As a result, if any two of the above methods are called
in parallel, there will be a race on this field.
I think the best solution is to synchronize all of the
above methods on "this". This solution has 2
1. It will prevent unsynchronized accesses of field
DatabaseCore.sqlInterface, reported in bug #1206737.
2. It will prevent unsynchronized accesses of field
DatabaseImpl.dbs, reported in bug #1191602.
Specifically, the synchronization on field
DatabaseImpl.dbs in methods addConnection,
commitTransation, and rollbackTransaction will no
longer be needed.
In conclusion, I think the only synchronization that is
needed in DatabaseImpl is on the "this" object, in the
All other synchronization in DatabaseImpl.java can be