This originates from the fact that at the time the ConnectionProvider SPI
was first discussed [1], its lifecycle wasn't yet well-defined. In fact, it
was expected that several calls to acquire() could be done before a
Connection is released through release(). Each such call should return the
same Connection.

This design was then challenged later on by Christopher Deckers [2] who
pointed out the same thing you're pointing out now. I'm actually not sure
why we had changed the SPI contract (Javadoc), but not this particular
implementation.

While removing this cache would constitute an incompatible change, I think
that no one really relies on calling acquire() twice to get two times the
same Connection. So I think we would be safe by fixing this implementation
in jOOQ 3.3 [3]

Cheers
Lukas

[1]: https://groups.google.com/d/msg/jooq-user/eiwxsnVPWV0/uoL7RyFJ7_wJ
[2]: https://groups.google.com/d/msg/jooq-user/GyIyuHfBWjE/HPaZCxXzDRoJ
[3]: https://github.com/jOOQ/jOOQ/issues/2863


2013/11/26 Sergey Epik <[email protected]>

> It seems that TransactionAwareDataSourceProxy really hides non-thread
> safety of DataSourceConnectionProvider. :(
> For me it's also not clear why DataSourceConnectionProvider caches
> connection (at least it's not necessary for Spring).
>
>
>
> On Tue, Nov 26, 2013 at 12:32 AM, Darren S <[email protected]>wrote:
>
>> I'm confused on how DataSourceConnectionProvider is supposed to be used.
>> DataSourceConnectionProvider holds a reference to last connection that was
>> acquired.  So the object is not thread safe.  In what context would you use
>> DataSourceConnectionProvider?  The only thing I can think of is that when
>> using Spring TransactionAwareDataSourceProxy you won't notice the
>> non-thread safety because TransactionAwareDataSourceProxy essentially grabs
>> a thread local connection.  Is it possible that
>> DataSourceConnectionProvider is really spring specific?  If so, should it
>> be renamed?
>>
>> Darren
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "jOOQ User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to