In fact, the Javadoc for Connection.close says clearly that calling close after a connection is already closed is a no-op. I think Chris is out of luck.
https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/Connection.html#close() > -----Original Message----- > From: Phil Steitz <[email protected]> > Sent: Wednesday, April 14, 2021 3:40 PM > To: [email protected] > Subject: Re: [dbcp2] No error/warning when returning a connection twice > > > On 4/14/21 12:59 PM, Gary Gregory wrote: > > 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? > > That was the thinking when we changed this to the current behavior back in > 1.3. See > https://urldefense.com/v3/__https://issues.apache.org/jira/browse/DBCP- > 233__;!!F9svGWnIaVPGSwU!4ZHhXqqLrSYmRh4X25n2bE0fw9- > J8e3ueMXNalxPEBVQgE6skRKzKb6xYgBpsspi-ZlRMAk$ > > Phil > > > > > 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] > >> > >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected]
