commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <>
Subject Re: [DBCP] needless sync on getNumActive, getNumIdle?
Date Wed, 04 Feb 2015 15:53:41 GMT
On 4 February 2015 at 13:51, Phil Steitz <> wrote:
> I had to go around getNumIdle to avoid waiting on a this lock in the
> unit test I just committed.  With pool 2 and volatile connectionPool
> instance, I don't think this sync is needed any more.  Same with the
> sync on getNumActive.  Am I missing something here?

I think there are two potential issues here.

The first is that getNumIdle will fail with NPE if another thread
closes the pool in the meantime.
That can be handled by taking a copy of the reference first.

The second possible issue is ensuring safe publication - I think
volatile should be sufficient here.

> Phil
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message