JdbcDataSource looks like it has a little funkiness going on. Why is
there a synchronize block there? Can multiple threads call getConnection
concurrently? If they can, this is not thread safe anyway. If they
can't, why is factory.call (or is it the close?) being protected with a
sync?
private Connection getConnection() throws Exception {
long currTime = System.currentTimeMillis();
if (currTime - connLastUsed > CONN_TIME_OUT) {
synchronized (this) {
Connection tmpConn = factory.call();
close();
connLastUsed = System.currentTimeMillis();
return conn = tmpConn;
}
} else {
connLastUsed = currTime;
return conn;
}
}