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: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


(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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to