I think the important point for connection pols is, that a double close is not 
harming a returned „physical“ connection. This is done by throwing away the 
logical checked out wrapper connection - disassociating it from the pooled one. 
(And also never exposing the physical connection, which is a problem with the 
unwrap API)

If that is done, the wrapper can basically chose how to behave: compatible 
(ignore the close after it is disassociated with the pooled physical 
connection) or log a warning or even throw — I see no harm in offering all 3 
options.

But the first property (do not reuse wrapper connections) is absolutely crucial 
for corruption protection (and also for Timeouts, cancels and reconnects). I 
haven’t checked dhcp, but i can’t imagine it does not do that correctly.

Gruss
Bernd


--
http://bernd.eckenfels.net
________________________________
Von: Gary Gregory <[email protected]>
Gesendet: Wednesday, April 14, 2021 9:59:50 PM
An: Commons Users List <[email protected]>
Betreff: Re: [dbcp2] No error/warning when returning a connection twice

Hi,

That's a tough sell IMO because (1) the JDBC specification does not require
this behavior AND (2) it would break existing applications. What is the
harm is having nothing happen when you close a closed connection?

What am I missing?

Gary


On Wed, Apr 14, 2021, 14:47 Christopher Schultz <
[email protected]> wrote:

> All,
>
> I have had an application for years which I run in development with
> maxsize=1 so I can catch any double-check-out errors as soon as they
> might read their ugly heads.
>
> But I never considered double-return logic errors.
>
> I recently wrote a "single connection pool" which is bare-bones and just
> creates a single JDBC connection and hands it out to anyone who wants
> it. It counts borrows vs returns and it was vomiting whenever we called
> a particular method which, evidently, has been double-closing
> connections for years.
>
> I had expected that DBCP2 would be objecting to double-closes, but
> evidently not.
>
> I checked, and there is no configuration that I can find to enable some
> kind of error/notification when double-closes are performed.
>
> Is that something the project would be interested in adding?
>
> I'm talking about something like this:
>
> Connection conn = dbcp.getConnection();
>
> // do stuff
>
> conn.close(); // great, returns to pool
> conn.close(); // should bomb
>
> Thanks,
> -chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to