https://bz.apache.org/bugzilla/show_bug.cgi?id=70164

            Bug ID: 70164
           Summary: The description of testOnBorrow is incorrect
           Product: Tomcat 11
           Version: 11.0.24
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Documentation
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: -------

There appears to be an error in the description of `testOnBorrow` in the
official Tomcat JDBC Pool documentation.

The current documentation states:

> testOnBorrow
> (boolean) The indication of whether objects will be validated before being 
> borrowed from the pool. If the object fails to validate, it will be dropped 
> from the pool, and we will attempt to borrow another. In order to have a more 
> efficient validation, see validationInterval. Default value is false

https://tomcat.apache.org/tomcat-11.0-doc/jdbc-pool.html#Common_Attributes

The description states that "and we will attempt to borrow another" but in
reality, it does not attempt to borrow a different connection object
(PooledConnection instance). Instead, it attempts to reconnect using the same
connection object and if the reconnection attempt also fails, an SQLException
is thrown. This description appears to have been quoted directly from Commons
DBCP, but the behavior differs between
`org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool` and
`org.apache.tomcat.jdbc.pool.ConnectionPool`.

The behavior of `org.apache.tomcat.jdbc.pool.ConnectionPool` is:

1. validate -> invalid
https://github.com/apache/tomcat/blob/11.0.24/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java#L861

2. reconnect
https://github.com/apache/tomcat/blob/11.0.24/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java#L880

3. release
https://github.com/apache/tomcat/blob/11.0.24/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java#L901

4. throw SQLException
https://github.com/apache/tomcat/blob/11.0.24/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java#L904

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to