commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31319] New: - Closing closed connection should be a no-op but throws exception
Date Mon, 20 Sep 2004 22:20:21 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31319>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31319

Closing closed connection should be a no-op but throws exception

           Summary: Closing closed connection should be a no-op but throws
                    exception
           Product: Commons
           Version: 1.2 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Dbcp
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: amills@sensorlogic.com


(Actually found in DBCP version 1.2.1)

When a connection received from the DBCP pool has close() called upon it two
times, on the second call it will throw an SQL exception such as:

java.sql.SQLException: Connection is closed.
        at
org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(PoolingDataSource.java:174)
        at
org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:179)
        at... (calling code from here on)

After browsing the docs/web site, this seems to be intended as a feature -- and
I can understand that, as it's generally indicative of poor logic to close a
connection twice. This is, however, directly in contradiction of the interface
defined by java.sql.Connection, which states in the javadocs of the close() method:

"Calling the method close on a Connection object that is already closed is a no-op."

Functionally, what this means is that when a developer has an existing codebase
where connections are double-closed (which is legal within the interface
definition), he can switch to the DBCP pooling system from another system and
end up having exceptions thrown from double-closing Connections (as I did).

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


Mime
View raw message