commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Heisey <apa...@elyograg.org>
Subject Re: [DBCP] Connection just obtained from datasource is invalid
Date Wed, 10 Jan 2018 00:09:53 GMT
On 1/9/2018 11:50 AM, Phil Steitz wrote:
> thread 1: checkOpen - sees true
> thread 2: close the DelegatingConnection  (there is no sync to
> prevent this)
> thread1 : createStatement - bang!
> thread1 : isClosed() returns true
>
> DBCP is not really safe to use that way - i.e., really the intended
> setup is that individual connection handles are not concurrently
> accessed by multiple threads.  Is it possible something like this is
> going on?  Note that what I am talking about here is two different
> threads holding references to the same connection handle - i.e., no
> trips back through the pool.

I am about 99 percent sure that I never pass Connection objects between
threads.  What code I've looked at borrows, uses, and closes the
Connection with a single thread.  I have some helper methods that take a
connection, but in all the code I've looked at so far, it's all running
in the same thread that borrowed the Connection in the first place.

I can tell you for sure that my *intent* when I wrote the code was to
always handle a Connection lifecycle in one single thread.  I wasn't
absolutely sure that sharing the object between threads would cause
problems, but doing so seemed like a bad idea.

Thanks,
Shawn


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message