lucene-solr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Noble Paul നോബിള്‍ नोब्ळ्" <noble.p...@gmail.com>
Subject Re: JdbcDataSource synchronization
Date Tue, 18 Nov 2008 16:27:03 GMT
it is not . conn is protected throughout

On Tue, Nov 18, 2008 at 9:48 PM, Mark Miller <markrmiller@gmail.com> wrote:
> But if your going to sync a variable, you can't read/write it outside of
> proper synchronization. Maybe I am just not following the code...
>
> Noble Paul ??????? ?????? wrote:
>>
>> one JdbcDataSource has only one connection the connection object/the
>> connLastUsed etc needs to be protected.
>>
>>
>>
>> On Tue, Nov 18, 2008 at 9:24 PM, Mark Miller <markrmiller@gmail.com>
>> wrote:
>>
>>>
>>> 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;
>>>  }
>>>  }
>>>
>>>
>>
>>
>>
>>
>
>



-- 
--Noble Paul

Mime
View raw message