- assigned_to: nobody --> gmartone
- status: open --> open-accepted
The following methods indirectly read/write field
ConnectionSource.isUsed without holding any lock:
delete
deleteForCriteria
insert
select
selectByPrimaryKey
update
updateForCriteria
For instance, the following statement in the select method:
Connection connection =
connectionManager.getConnection(databaseName);
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
additional benefits:
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
following methods:
begin
close
commitTransaction
delete
deleteForCriteria
destroy
insert
rollbackTransaction
select
selectByPrimaryKey
update
updateForCriteria
All other synchronization in DatabaseImpl.java can be
removed.
-- Mayur