Author: markt Date: Mon Oct 13 16:06:18 2014 New Revision: 1631454 URL: http://svn.apache.org/r1631454 Log: Fix Java 8 Javadoc errors in org.apache.tomcat.dbcp
Modified: tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/ (props changed) tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/BasicDataSource.java tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/package-info.java tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/package-info.java tomcat/trunk/webapps/docs/changelog.xml Propchange: tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/ ------------------------------------------------------------------------------ Merged /commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2:r1626989-1631451 Modified: tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/BasicDataSource.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/BasicDataSource.java?rev=1631454&r1=1631453&r2=1631454&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/BasicDataSource.java (original) +++ tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/BasicDataSource.java Mon Oct 13 16:06:18 2014 @@ -1518,11 +1518,12 @@ public class BasicDataSource implements * {@link #getRemoveAbandonedTimeout() removeAbandonedTimeout} seconds.</p> * * <p>Abandoned connections are identified and removed when - * {@link #getConnection()} is invoked and the following conditions hold + * {@link #getConnection()} is invoked and the following conditions hold: + * </p> * <ul><li>{@link #getRemoveAbandonedOnBorrow()} or * {@link #getRemoveAbandonedOnMaintenance()} = true</li> - * <li>{@link #getNumActive()} > {@link #getMaxTotal()} - 3 </li> - * <li>{@link #getNumIdle()} < 2 </li></ul></p> + * <li>{@link #getNumActive()} > {@link #getMaxTotal()} - 3 </li> + * <li>{@link #getNumIdle()} < 2 </li></ul> * * @see #getRemoveAbandonedTimeout() */ @@ -1569,11 +1570,12 @@ public class BasicDataSource implements * {@link #getRemoveAbandonedTimeout() removeAbandonedTimeout} seconds.</p> * * <p>Abandoned connections are identified and removed when - * {@link #getConnection()} is invoked and the following conditions hold + * {@link #getConnection()} is invoked and the following conditions hold: + * </p> * <ul><li>{@link #getRemoveAbandonedOnBorrow()} or * {@link #getRemoveAbandonedOnMaintenance()} = true</li> - * <li>{@link #getNumActive()} > {@link #getMaxTotal()} - 3 </li> - * <li>{@link #getNumIdle()} < 2 </li></ul></p> + * <li>{@link #getNumActive()} > {@link #getMaxTotal()} - 3 </li> + * <li>{@link #getNumIdle()} < 2 </li></ul> * * @see #getRemoveAbandonedTimeout() */ @@ -1613,13 +1615,13 @@ public class BasicDataSource implements * one of these to execute a query (using one of the execute methods) * resets the lastUsed property of the parent connection.</p> * - * <p>Abandoned connection cleanup happens when - * <code><ul> + * <p>Abandoned connection cleanup happens when:</p> + * <ul> * <li>{@link #getRemoveAbandonedOnBorrow()} or * {@link #getRemoveAbandonedOnMaintenance()} = true</li> * <li>{@link #getNumIdle() numIdle} < 2</li> * <li>{@link #getNumActive() numActive} > {@link #getMaxTotal() maxTotal} - 3</li> - * </ul></code></p> + * </ul> * * <p>The default value is 300 seconds.</p> */ @@ -1864,6 +1866,47 @@ public class BasicDataSource implements throw new SQLFeatureNotSupportedException(); } + /** + * Manually invalidates a connection, effectively requesting the pool to try + * to close it, remove it from the pool and reclaim pool capacity. + * + * @throws IllegalStateException + * if invalidating the connection failed. + * @since 2.1 + */ + public void invalidateConnection(Connection connection) throws IllegalStateException { + if (connection == null) { + return; + } + if (connectionPool == null) { + throw new IllegalStateException("Cannot invalidate connection: ConnectionPool is null."); + } + + final PoolableConnection poolableConnection; + try { + poolableConnection = connection.unwrap(PoolableConnection.class); + if (poolableConnection == null) { + throw new IllegalStateException( + "Cannot invalidate connection: Connection is not a poolable connection."); + } + } catch (SQLException e) { + throw new IllegalStateException("Cannot invalidate connection: Unwrapping poolable connection failed.", e); + } + + // attempt to close the connection for good measure + try { + connection.close(); + } catch (Exception e) { + // ignore any exceptions here + } + + try { + connectionPool.invalidateObject(poolableConnection); + } catch (Exception e) { + throw new IllegalStateException("Invalidating connection threw unexpected exception", e); + } + } + // ------------------------------------------------------ Protected Methods Modified: tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/package-info.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/package-info.java?rev=1631454&r1=1631453&r2=1631454&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/package-info.java (original) +++ tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/package-info.java Mon Oct 13 16:06:18 2014 @@ -36,7 +36,7 @@ * webapp: * </p> * - * <code><pre> + * <code> * <Resource name="jdbc/bookstore" auth="Container" * type="org.apache.tomcat.dbcp.dbcp2.datasources.PerUserPoolPoolDataSource"/> * <ResourceParams name="jdbc/bookstore"> @@ -51,14 +51,14 @@ * <name>defaultMaxTotal</name><value>30</value> * </parameter> * </ResourceParams> - * </pre></code> + * </code> * * <p> * In web.xml. Note that elements must be given in the order of the dtd * described in the servlet specification: * </p> * - * <code><pre> + * <code> * <resource-ref> * <description> * Resource reference to a factory for java.sql.Connection @@ -75,7 +75,7 @@ * Container * </res-auth> * </resource-ref> - * </pre></code> + * </code> * * <p> * Apache Tomcat deploys all objects configured similarly to above within the @@ -90,7 +90,7 @@ * below: * </p> * - * <code><pre> + * <code> * * Context ctx = new InitialContext(); * DataSource ds = (DataSource) @@ -109,7 +109,7 @@ * con.close(); * } * - * </pre></code> + * </code> * * <p> * The reference to the <code>DataSource</code> could be maintained, for @@ -130,7 +130,7 @@ * DriverAdapterCPDS as the backend source, though any CPDS is applicable. * </p> * - * <code><pre> + * <code> * * public class Pool * { @@ -158,13 +158,13 @@ * } * } * - * </pre></code> + * </code> * * <p> * This class can then be used wherever a connection is needed: * </p> * - * <code><pre> + * <code> * Connection con = null; * try * { @@ -178,6 +178,6 @@ * if (con != null) * con.close(); * } - * </pre></code> + * </code> */ package org.apache.tomcat.dbcp.dbcp2.datasources; Modified: tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/package-info.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/package-info.java?rev=1631454&r1=1631453&r2=1631454&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/package-info.java (original) +++ tomcat/trunk/java/org/apache/tomcat/dbcp/dbcp2/package-info.java Mon Oct 13 16:06:18 2014 @@ -87,7 +87,7 @@ * {@link org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory} is for. * </p><p> * To create the {@link org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory}, - * you'll need at least two things: + * you'll need at least two things:</p> * <ol> * <li> * A {@link org.apache.tomcat.dbcp.dbcp2.ConnectionFactory} from which @@ -96,35 +96,35 @@ * <li> * An empty and factory-less {@link org.apache.tomcat.dbcp.pool2.ObjectPool} * in which the {@link java.sql.Connection}s will be stored. - * <br></br> + * <br> * When you pass an {@link org.apache.tomcat.dbcp.pool2.ObjectPool} into the * {@link org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory}, it will * automatically register itself as the {@link org.apache.tomcat.dbcp.pool2.PooledObjectFactory} * for that pool. * </li> * </ol> - * </p><p> + * <p> * In code, that might look like this: + * </p> * <pre>GenericObjectPool connectionPool = new GenericObjectPool(null); * ConnectionFactory connectionFactory = new DriverManagerConnectionFactory("jdbc:some:connect:string", "username", "password"); * PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,true); * PoolingDataSource dataSource = new PoolingDataSource(connectionPool);</pre> - * </p><p> + * <p> * To create a {@link org.apache.tomcat.dbcp.dbcp2.PoolingDriver}, we do the same thing, * except that instead of creating a {@link javax.sql.DataSource} on the last line, * we create a {@link org.apache.tomcat.dbcp.dbcp2.PoolingDriver}, and register the - * {@code connectionPool} with it. E.g.,: + * {@code connectionPool} with it. E.g.,:</p> * <pre>GenericObjectPool connectionPool = new GenericObjectPool(null); * ConnectionFactory connectionFactory = new DriverManagerConnectionFactory("jdbc:some:connect:string", "username", "password"); * PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,true); * PoolingDriver driver = new PoolingDriver(); * driver.registerPool("example",connectionPool);</pre> - * </p><p> + * <p> * Since the {@link org.apache.tomcat.dbcp.dbcp2.PoolingDriver} registers itself * with the {@link java.sql.DriverManager} when it is created, now you can just * go to the {@link java.sql.DriverManager} to create your {@link java.sql.Connection}s, - * like you normally would: + * like you normally would:</p> * <pre>Connection conn = DriverManager.getConnection("jdbc:apache:commons:dbcp:example");</pre> - * </p> */ package org.apache.tomcat.dbcp.dbcp2; Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1631454&r1=1631453&r2=1631454&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Mon Oct 13 16:06:18 2014 @@ -199,6 +199,11 @@ Fix timestamps in Tomcat build and jdbc-pool to use 24-hour format instead of 12-hour one and use UTC timezone. (markt/kkolinko) </fix> + <fix> + Update the package renamed copy of Apache Commons DBCP 2 to revision + 1631450 to pick up additional fixes since the 2.0.1 release including + Javadoc corrections to fix errors when compiling with Java 8. (markt) + </fix> </changelog> </subsection> </section> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org