Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/DriverAdapterCPDS.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/DriverAdapterCPDS.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/DriverAdapterCPDS.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/DriverAdapterCPDS.java Fri May 13 18:49:32 2016 @@ -45,7 +45,7 @@ import org.apache.tomcat.dbcp.pool2.impl /** * <p> - * An adapter for jdbc drivers that do not include an implementation + * An adapter for JDBC drivers that do not include an implementation * of {@link javax.sql.ConnectionPoolDataSource}, but still include a * {@link java.sql.DriverManager} implementation. * <code>ConnectionPoolDataSource</code>s are not used within general @@ -163,7 +163,7 @@ public class DriverAdapterCPDS * @param pass password to be used fur the connection */ @Override - public PooledConnection getPooledConnection(String username, String pass) + public PooledConnection getPooledConnection(final String username, final String pass) throws SQLException { getConnectionCalled = true; PooledConnectionImpl pci = null; @@ -181,7 +181,7 @@ public class DriverAdapterCPDS } pci.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed()); } - catch (ClassCircularityError e) + catch (final ClassCircularityError e) { if (connectionProperties != null) { pci = new PooledConnectionImpl(DriverManager.getConnection( @@ -194,7 +194,7 @@ public class DriverAdapterCPDS } KeyedObjectPool<PStmtKeyCPDS, PoolablePreparedStatement<PStmtKeyCPDS>> stmtPool = null; if (isPoolPreparedStatements()) { - GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig(); + final GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig(); config.setMaxTotalPerKey(Integer.MAX_VALUE); config.setBlockWhenExhausted(false); config.setMaxWaitMillis(0); @@ -237,9 +237,9 @@ public class DriverAdapterCPDS @Override public Reference getReference() throws NamingException { // this class implements its own factory - String factory = getClass().getName(); + final String factory = getClass().getName(); - Reference ref = new Reference(getClass().getName(), factory, null); + final Reference ref = new Reference(getClass().getName(), factory, null); ref.add(new StringRefAddr("description", getDescription())); ref.add(new StringRefAddr("driver", getDriver())); @@ -273,14 +273,14 @@ public class DriverAdapterCPDS * implements ObjectFactory to create an instance of this class */ @Override - public Object getObjectInstance(Object refObj, Name name, - Context context, Hashtable<?,?> env) + public Object getObjectInstance(final Object refObj, final Name name, + final Context context, final Hashtable<?,?> env) throws Exception { // The spec says to return null if we can't create an instance // of the reference DriverAdapterCPDS cpds = null; if (refObj instanceof Reference) { - Reference ref = (Reference)refObj; + final Reference ref = (Reference)refObj; if (ref.getClassName().equals(getClass().getName())) { RefAddr ra = ref.get("description"); if (ra != null && ra.getContent() != null) { @@ -363,7 +363,7 @@ public class DriverAdapterCPDS // Properties /** - * Get the connection properties passed to the JDBC driver. + * Gets the connection properties passed to the JDBC driver. * * @return the JDBC connection properties used when creating connections. */ @@ -372,7 +372,7 @@ public class DriverAdapterCPDS } /** - * <p>Set the connection properties passed to the JDBC driver.</p> + * <p>Sets the connection properties passed to the JDBC driver.</p> * * <p>If <code>props</code> contains "user" and/or "password" * properties, the corresponding instance properties are set. If these @@ -386,7 +386,7 @@ public class DriverAdapterCPDS * @param props Connection properties to use when creating new connections. * @throws IllegalStateException if {@link #getPooledConnection()} has been called */ - public void setConnectionProperties(Properties props) { + public void setConnectionProperties(final Properties props) { assertInitializationAllowed(); connectionProperties = props; if (connectionProperties.containsKey("user")) { @@ -398,7 +398,7 @@ public class DriverAdapterCPDS } /** - * Get the value of description. This property is here for use by + * Gets the value of description. This property is here for use by * the code which will deploy this datasource. It is not used * internally. * @@ -410,18 +410,18 @@ public class DriverAdapterCPDS } /** - * Set the value of description. This property is here for use by + * Sets the value of description. This property is here for use by * the code which will deploy this datasource. It is not used * internally. * * @param v Value to assign to description. */ - public void setDescription(String v) { + public void setDescription(final String v) { this.description = v; } /** - * Get the value of password for the default user. + * Gets the value of password for the default user. * @return value of password. */ public String getPassword() { @@ -429,11 +429,11 @@ public class DriverAdapterCPDS } /** - * Set the value of password for the default user. + * Sets the value of password for the default user. * @param v Value to assign to password. * @throws IllegalStateException if {@link #getPooledConnection()} has been called */ - public void setPassword(String v) { + public void setPassword(final String v) { assertInitializationAllowed(); this.password = v; if (connectionProperties != null) { @@ -442,7 +442,7 @@ public class DriverAdapterCPDS } /** - * Get the value of url used to locate the database for this datasource. + * Gets the value of url used to locate the database for this datasource. * @return value of url. */ public String getUrl() { @@ -450,17 +450,17 @@ public class DriverAdapterCPDS } /** - * Set the value of url used to locate the database for this datasource. + * Sets the value of URL string used to locate the database for this datasource. * @param v Value to assign to url. * @throws IllegalStateException if {@link #getPooledConnection()} has been called */ - public void setUrl(String v) { + public void setUrl(final String v) { assertInitializationAllowed(); this.url = v; } /** - * Get the value of default user (login or username). + * Gets the value of default user (login or username). * @return value of user. */ public String getUser() { @@ -468,11 +468,11 @@ public class DriverAdapterCPDS } /** - * Set the value of default user (login or username). + * Sets the value of default user (login or username). * @param v Value to assign to user. * @throws IllegalStateException if {@link #getPooledConnection()} has been called */ - public void setUser(String v) { + public void setUser(final String v) { assertInitializationAllowed(); this.user = v; if (connectionProperties != null) { @@ -481,7 +481,7 @@ public class DriverAdapterCPDS } /** - * Get the driver classname. + * Gets the driver classname. * @return value of driver. */ public String getDriver() { @@ -489,13 +489,13 @@ public class DriverAdapterCPDS } /** - * Set the driver classname. Setting the driver classname cause the + * Sets the driver classname. Setting the driver classname cause the * driver to be registered with the DriverManager. * @param v Value to assign to driver. * @throws ClassNotFoundException Driver class was not found * @throws IllegalStateException if {@link #getPooledConnection()} has been called */ - public void setDriver(String v) throws ClassNotFoundException { + public void setDriver(final String v) throws ClassNotFoundException { assertInitializationAllowed(); this.driver = v; // make sure driver is registered @@ -512,7 +512,7 @@ public class DriverAdapterCPDS } /** - * Get the log writer for this data source. NOT USED. + * Gets the log writer for this data source. NOT USED. */ @Override public PrintWriter getLogWriter() { @@ -524,15 +524,15 @@ public class DriverAdapterCPDS * while attempting to connect to a database. NOT USED. */ @Override - public void setLoginTimeout(int seconds) { + public void setLoginTimeout(final int seconds) { loginTimeout = seconds; } /** - * Set the log writer for this data source. NOT USED. + * Sets the log writer for this data source. NOT USED. */ @Override - public void setLogWriter(PrintWriter out) { + public void setLogWriter(final PrintWriter out) { logWriter = out; } @@ -554,13 +554,13 @@ public class DriverAdapterCPDS * @param v true to pool statements. * @throws IllegalStateException if {@link #getPooledConnection()} has been called */ - public void setPoolPreparedStatements(boolean v) { + public void setPoolPreparedStatements(final boolean v) { assertInitializationAllowed(); this.poolPreparedStatements = v; } /** - * The maximum number of statements that can remain idle in the + * Gets the maximum number of statements that can remain idle in the * pool, without extra ones being released, or negative for no limit. * @return the value of maxIdle */ @@ -569,19 +569,19 @@ public class DriverAdapterCPDS } /** - * The maximum number of statements that can remain idle in the + * Gets the maximum number of statements that can remain idle in the * pool, without extra ones being released, or negative for no limit. * * @param maxIdle The maximum number of statements that can remain idle * @throws IllegalStateException if {@link #getPooledConnection()} has been called */ - public void setMaxIdle(int maxIdle) { + public void setMaxIdle(final int maxIdle) { assertInitializationAllowed(); this.maxIdle = maxIdle; } /** - * Returns the number of milliseconds to sleep between runs of the + * Gets the number of milliseconds to sleep between runs of the * idle object evictor thread. * When non-positive, no idle object evictor thread will be * run. @@ -602,13 +602,13 @@ public class DriverAdapterCPDS * @throws IllegalStateException if {@link #getPooledConnection()} has been called */ public void setTimeBetweenEvictionRunsMillis( - long timeBetweenEvictionRunsMillis) { + final long timeBetweenEvictionRunsMillis) { assertInitializationAllowed(); _timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; } /** - * Returns the number of statements to examine during each run of the + * Gets the number of statements to examine during each run of the * idle object evictor thread (if any). * * @see #setNumTestsPerEvictionRun(int) @@ -632,13 +632,13 @@ public class DriverAdapterCPDS * @see #setTimeBetweenEvictionRunsMillis(long) * @throws IllegalStateException if {@link #getPooledConnection()} has been called */ - public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) { + public void setNumTestsPerEvictionRun(final int numTestsPerEvictionRun) { assertInitializationAllowed(); _numTestsPerEvictionRun = numTestsPerEvictionRun; } /** - * Returns the minimum amount of time a statement may sit idle in the pool + * Gets the minimum amount of time a statement may sit idle in the pool * before it is eligible for eviction by the idle object evictor * (if any). * @@ -661,7 +661,7 @@ public class DriverAdapterCPDS * @see #setTimeBetweenEvictionRunsMillis(long) * @throws IllegalStateException if {@link #getPooledConnection()} has been called */ - public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) { + public void setMinEvictableIdleTimeMillis(final int minEvictableIdleTimeMillis) { assertInitializationAllowed(); _minEvictableIdleTimeMillis = minEvictableIdleTimeMillis; } @@ -683,12 +683,12 @@ public class DriverAdapterCPDS * * @param allow Access to the underlying connection is granted when true. */ - public synchronized void setAccessToUnderlyingConnectionAllowed(boolean allow) { + public synchronized void setAccessToUnderlyingConnectionAllowed(final boolean allow) { this.accessToUnderlyingConnectionAllowed = allow; } /** - * Returns the maximum number of prepared statements. + * Gets the maximum number of prepared statements. * * @return maxPrepartedStatements value */ @@ -702,7 +702,7 @@ public class DriverAdapterCPDS * @param maxPreparedStatements the new maximum number of prepared * statements */ - public void setMaxPreparedStatements(int maxPreparedStatements) + public void setMaxPreparedStatements(final int maxPreparedStatements) { _maxPreparedStatements = maxPreparedStatements; }
Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/PStmtKeyCPDS.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/PStmtKeyCPDS.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/PStmtKeyCPDS.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/PStmtKeyCPDS.java Fri May 13 18:49:32 2016 @@ -29,43 +29,43 @@ public class PStmtKeyCPDS extends PStmtK private final int _columnIndexes[]; private final String _columnNames[]; - public PStmtKeyCPDS(String sql) { + public PStmtKeyCPDS(final String sql) { super(sql); _resultSetHoldability = null; _columnIndexes = null; _columnNames = null; } - public PStmtKeyCPDS(String sql, int autoGeneratedKeys) { + public PStmtKeyCPDS(final String sql, final int autoGeneratedKeys) { super(sql, null, autoGeneratedKeys); _resultSetHoldability = null; _columnIndexes = null; _columnNames = null; } - public PStmtKeyCPDS(String sql, int resultSetType, int resultSetConcurrency) { + public PStmtKeyCPDS(final String sql, final int resultSetType, final int resultSetConcurrency) { super(sql, resultSetType, resultSetConcurrency); _resultSetHoldability = null; _columnIndexes = null; _columnNames = null; } - public PStmtKeyCPDS(String sql, int resultSetType, int resultSetConcurrency, - int resultSetHoldability) { + public PStmtKeyCPDS(final String sql, final int resultSetType, final int resultSetConcurrency, + final int resultSetHoldability) { super(sql, resultSetType, resultSetConcurrency); _resultSetHoldability = Integer.valueOf(resultSetHoldability); _columnIndexes = null; _columnNames = null; } - public PStmtKeyCPDS(String sql, int columnIndexes[]) { + public PStmtKeyCPDS(final String sql, final int columnIndexes[]) { super(sql); _columnIndexes = Arrays.copyOf(columnIndexes, columnIndexes.length); _resultSetHoldability = null; _columnNames = null; } - public PStmtKeyCPDS(String sql, String columnNames[]) { + public PStmtKeyCPDS(final String sql, final String columnNames[]) { super(sql); _columnNames = Arrays.copyOf(columnNames, columnNames.length); _resultSetHoldability = null; @@ -74,7 +74,7 @@ public class PStmtKeyCPDS extends PStmtK @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } @@ -84,7 +84,7 @@ public class PStmtKeyCPDS extends PStmtK if (getClass() != obj.getClass()) { return false; } - PStmtKeyCPDS other = (PStmtKeyCPDS) obj; + final PStmtKeyCPDS other = (PStmtKeyCPDS) obj; if (!Arrays.equals(_columnIndexes, other._columnIndexes)) { return false; } @@ -115,7 +115,7 @@ public class PStmtKeyCPDS extends PStmtK @Override public String toString() { - StringBuffer buf = new StringBuffer(); + final StringBuffer buf = new StringBuffer(); buf.append("PStmtKey: sql="); buf.append(getSql()); buf.append(", catalog="); Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/PooledConnectionImpl.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/PooledConnectionImpl.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/PooledConnectionImpl.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/PooledConnectionImpl.java Fri May 13 18:49:32 2016 @@ -41,8 +41,8 @@ import org.apache.tomcat.dbcp.pool2.impl * @author John D. McNally * @since 2.0 */ -class PooledConnectionImpl implements PooledConnection, - KeyedPooledObjectFactory<PStmtKeyCPDS,PoolablePreparedStatement<PStmtKeyCPDS>> { +class PooledConnectionImpl + implements PooledConnection, KeyedPooledObjectFactory<PStmtKeyCPDS, PoolablePreparedStatement<PStmtKeyCPDS>> { private static final String CLOSED = "Attempted to use PooledConnection after closed() was called."; @@ -90,7 +90,7 @@ class PooledConnectionImpl implements Po * Wrap the real connection. * @param connection the connection to be wrapped */ - PooledConnectionImpl(Connection connection) { + PooledConnectionImpl(final Connection connection) { this.connection = connection; if (connection instanceof DelegatingConnection) { this.delegatingConnection = (DelegatingConnection<?>) connection; @@ -102,7 +102,7 @@ class PooledConnectionImpl implements Po } public void setStatementPool( - KeyedObjectPool<PStmtKeyCPDS, PoolablePreparedStatement<PStmtKeyCPDS>> statementPool) { + final KeyedObjectPool<PStmtKeyCPDS, PoolablePreparedStatement<PStmtKeyCPDS>> statementPool) { pstmtPool = statementPool; } @@ -110,7 +110,7 @@ class PooledConnectionImpl implements Po * {@inheritDoc} */ @Override - public void addConnectionEventListener(ConnectionEventListener listener) { + public void addConnectionEventListener(final ConnectionEventListener listener) { if (!eventListeners.contains(listener)) { eventListeners.add(listener); } @@ -118,7 +118,7 @@ class PooledConnectionImpl implements Po /* JDBC_4_ANT_KEY_BEGIN */ @Override - public void addStatementEventListener(StatementEventListener listener) { + public void addStatementEventListener(final StatementEventListener listener) { if (!statementEventListeners.contains(listener)) { statementEventListeners.add(listener); } @@ -144,9 +144,9 @@ class PooledConnectionImpl implements Po pstmtPool = null; } } - } catch (RuntimeException e) { + } catch (final RuntimeException e) { throw e; - } catch (Exception e) { + } catch (final Exception e) { throw new SQLException("Cannot close connection (return to pool failed)", e); } finally { try { @@ -194,13 +194,13 @@ class PooledConnectionImpl implements Po */ @Override public void removeConnectionEventListener( - ConnectionEventListener listener) { + final ConnectionEventListener listener) { eventListeners.remove(listener); } /* JDBC_4_ANT_KEY_BEGIN */ @Override - public void removeStatementEventListener(StatementEventListener listener) { + public void removeStatementEventListener(final StatementEventListener listener) { statementEventListeners.remove(listener); } /* JDBC_4_ANT_KEY_END */ @@ -215,7 +215,7 @@ class PooledConnectionImpl implements Po // an error will occur. try { connection.close(); - } catch (Exception ignored) { + } catch (final Exception ignored) { } // make sure the last connection is marked as closed @@ -229,9 +229,9 @@ class PooledConnectionImpl implements Po * sends a connectionClosed event. */ void notifyListeners() { - ConnectionEvent event = new ConnectionEvent(this); - Object[] listeners = eventListeners.toArray(); - for (Object listener : listeners) { + final ConnectionEvent event = new ConnectionEvent(this); + final Object[] listeners = eventListeners.toArray(); + for (final Object listener : listeners) { ((ConnectionEventListener) listener).connectionClosed(event); } } @@ -244,15 +244,15 @@ class PooledConnectionImpl implements Po * @param sql the SQL statement * @return a {@link PoolablePreparedStatement} */ - PreparedStatement prepareStatement(String sql) throws SQLException { + PreparedStatement prepareStatement(final String sql) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql); } try { return pstmtPool.borrowObject(createKey(sql)); - } catch (RuntimeException e) { + } catch (final RuntimeException e) { throw e; - } catch (Exception e) { + } catch (final Exception e) { throw new SQLException("Borrow prepareStatement from pool failed", e); } } @@ -273,8 +273,8 @@ class PooledConnectionImpl implements Po * @return a {@link PoolablePreparedStatement} * @see Connection#prepareStatement(String, int, int) */ - PreparedStatement prepareStatement(String sql, int resultSetType, - int resultSetConcurrency) + PreparedStatement prepareStatement(final String sql, final int resultSetType, + final int resultSetConcurrency) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql, resultSetType, resultSetConcurrency); @@ -282,9 +282,9 @@ class PooledConnectionImpl implements Po try { return pstmtPool.borrowObject( createKey(sql,resultSetType,resultSetConcurrency)); - } catch (RuntimeException e) { + } catch (final RuntimeException e) { throw e; - } catch (Exception e) { + } catch (final Exception e) { throw new SQLException("Borrow prepareStatement from pool failed", e); } } @@ -300,22 +300,22 @@ class PooledConnectionImpl implements Po * @return a {@link PoolablePreparedStatement} * @see Connection#prepareStatement(String, int) */ - PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) + PreparedStatement prepareStatement(final String sql, final int autoGeneratedKeys) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql, autoGeneratedKeys); } try { return pstmtPool.borrowObject(createKey(sql,autoGeneratedKeys)); - } catch (RuntimeException e) { + } catch (final RuntimeException e) { throw e; - } catch (Exception e) { + } catch (final Exception e) { throw new SQLException("Borrow prepareStatement from pool failed", e); } } - PreparedStatement prepareStatement(String sql, int resultSetType, - int resultSetConcurrency, int resultSetHoldability) + PreparedStatement prepareStatement(final String sql, final int resultSetType, + final int resultSetConcurrency, final int resultSetHoldability) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql, resultSetType, @@ -324,37 +324,37 @@ class PooledConnectionImpl implements Po try { return pstmtPool.borrowObject(createKey(sql, resultSetType, resultSetConcurrency, resultSetHoldability)); - } catch (RuntimeException e) { + } catch (final RuntimeException e) { throw e; - } catch (Exception e) { + } catch (final Exception e) { throw new SQLException("Borrow prepareStatement from pool failed", e); } } - PreparedStatement prepareStatement(String sql, int columnIndexes[]) + PreparedStatement prepareStatement(final String sql, final int columnIndexes[]) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql, columnIndexes); } try { return pstmtPool.borrowObject(createKey(sql, columnIndexes)); - } catch (RuntimeException e) { + } catch (final RuntimeException e) { throw e; - } catch (Exception e) { + } catch (final Exception e) { throw new SQLException("Borrow prepareStatement from pool failed", e); } } - PreparedStatement prepareStatement(String sql, String columnNames[]) + PreparedStatement prepareStatement(final String sql, final String columnNames[]) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql, columnNames); } try { return pstmtPool.borrowObject(createKey(sql, columnNames)); - } catch (RuntimeException e) { + } catch (final RuntimeException e) { throw e; - } catch (Exception e) { + } catch (final Exception e) { throw new SQLException("Borrow prepareStatement from pool failed", e); } } @@ -362,15 +362,15 @@ class PooledConnectionImpl implements Po /** * Create a {@link PooledConnectionImpl.PStmtKey} for the given arguments. */ - protected PStmtKeyCPDS createKey(String sql, int autoGeneratedKeys) { + protected PStmtKeyCPDS createKey(final String sql, final int autoGeneratedKeys) { return new PStmtKeyCPDS(normalizeSQL(sql), autoGeneratedKeys); } /** * Create a {@link PooledConnectionImpl.PStmtKey} for the given arguments. */ - protected PStmtKeyCPDS createKey(String sql, int resultSetType, - int resultSetConcurrency, int resultSetHoldability) { + protected PStmtKeyCPDS createKey(final String sql, final int resultSetType, + final int resultSetConcurrency, final int resultSetHoldability) { return new PStmtKeyCPDS(normalizeSQL(sql), resultSetType, resultSetConcurrency, resultSetHoldability); } @@ -378,22 +378,22 @@ class PooledConnectionImpl implements Po /** * Create a {@link PooledConnectionImpl.PStmtKey} for the given arguments. */ - protected PStmtKeyCPDS createKey(String sql, int columnIndexes[]) { + protected PStmtKeyCPDS createKey(final String sql, final int columnIndexes[]) { return new PStmtKeyCPDS(normalizeSQL(sql), columnIndexes); } /** * Create a {@link PooledConnectionImpl.PStmtKey} for the given arguments. */ - protected PStmtKeyCPDS createKey(String sql, String columnNames[]) { + protected PStmtKeyCPDS createKey(final String sql, final String columnNames[]) { return new PStmtKeyCPDS(normalizeSQL(sql), columnNames); } /** * Create a {@link PooledConnectionImpl.PStmtKey} for the given arguments. */ - protected PStmtKeyCPDS createKey(String sql, int resultSetType, - int resultSetConcurrency) { + protected PStmtKeyCPDS createKey(final String sql, final int resultSetType, + final int resultSetConcurrency) { return new PStmtKeyCPDS(normalizeSQL(sql), resultSetType, resultSetConcurrency); } @@ -401,7 +401,7 @@ class PooledConnectionImpl implements Po /** * Create a {@link PooledConnectionImpl.PStmtKey} for the given arguments. */ - protected PStmtKeyCPDS createKey(String sql) { + protected PStmtKeyCPDS createKey(final String sql) { return new PStmtKeyCPDS(normalizeSQL(sql)); } @@ -409,7 +409,7 @@ class PooledConnectionImpl implements Po * Normalize the given SQL statement, producing a * canonical form that is semantically equivalent to the original. */ - protected String normalizeSQL(String sql) { + protected String normalizeSQL(final String sql) { return sql.trim(); } @@ -419,7 +419,7 @@ class PooledConnectionImpl implements Po * @param key the key for the {@link PreparedStatement} to be created */ @Override - public PooledObject<PoolablePreparedStatement<PStmtKeyCPDS>> makeObject(PStmtKeyCPDS key) throws Exception { + public PooledObject<PoolablePreparedStatement<PStmtKeyCPDS>> makeObject(final PStmtKeyCPDS key) throws Exception { if (null == key) { throw new IllegalArgumentException(); } @@ -450,8 +450,8 @@ class PooledConnectionImpl implements Po * @param p the wrapped {@link PreparedStatement} to be destroyed. */ @Override - public void destroyObject(PStmtKeyCPDS key, - PooledObject<PoolablePreparedStatement<PStmtKeyCPDS>> p) + public void destroyObject(final PStmtKeyCPDS key, + final PooledObject<PoolablePreparedStatement<PStmtKeyCPDS>> p) throws Exception { p.getObject().getInnermostDelegate().close(); } @@ -464,8 +464,8 @@ class PooledConnectionImpl implements Po * @return {@code true} */ @Override - public boolean validateObject(PStmtKeyCPDS key, - PooledObject<PoolablePreparedStatement<PStmtKeyCPDS>> p) { + public boolean validateObject(final PStmtKeyCPDS key, + final PooledObject<PoolablePreparedStatement<PStmtKeyCPDS>> p) { return true; } @@ -476,8 +476,8 @@ class PooledConnectionImpl implements Po * @param p ignored */ @Override - public void activateObject(PStmtKeyCPDS key, - PooledObject<PoolablePreparedStatement<PStmtKeyCPDS>> p) + public void activateObject(final PStmtKeyCPDS key, + final PooledObject<PoolablePreparedStatement<PStmtKeyCPDS>> p) throws Exception { p.getObject().activate(); } @@ -489,10 +489,10 @@ class PooledConnectionImpl implements Po * @param p a wrapped {@link PreparedStatement} */ @Override - public void passivateObject(PStmtKeyCPDS key, - PooledObject<PoolablePreparedStatement<PStmtKeyCPDS>> p) + public void passivateObject(final PStmtKeyCPDS key, + final PooledObject<PoolablePreparedStatement<PStmtKeyCPDS>> p) throws Exception { - PoolablePreparedStatement<PStmtKeyCPDS> ppss = p.getObject(); + final PoolablePreparedStatement<PStmtKeyCPDS> ppss = p.getObject(); ppss.clearParameters(); ppss.passivate(); } @@ -513,7 +513,7 @@ class PooledConnectionImpl implements Po * * @param allow Access to the underlying connection is granted when true. */ - public synchronized void setAccessToUnderlyingConnectionAllowed(boolean allow) { + public synchronized void setAccessToUnderlyingConnectionAllowed(final boolean allow) { this.accessToUnderlyingConnectionAllowed = allow; } } Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/package-info.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/package-info.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/package-info.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/package-info.java Fri May 13 18:49:32 2016 @@ -19,7 +19,7 @@ * <p> * This package contains one public class which is a * <code>ConnectionPoolDataSource</code> (CPDS) implementation that can be used to - * adapt older <code>Driver</code> based jdbc implementations. Below is an + * adapt older <code>Driver</code> based JDBC implementations. Below is an * example of setting up the CPDS to be available via JNDI in the * catalina servlet container. * </p> Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/CPDSConnectionFactory.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/CPDSConnectionFactory.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/CPDSConnectionFactory.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/CPDSConnectionFactory.java Fri May 13 18:49:32 2016 @@ -89,12 +89,12 @@ class CPDSConnectionFactory * @param username The user name to use to create connections * @param password The password to use to create connections */ - public CPDSConnectionFactory(ConnectionPoolDataSource cpds, - String validationQuery, - int validationQueryTimeout, - boolean rollbackAfterValidation, - String username, - String password) { + public CPDSConnectionFactory(final ConnectionPoolDataSource cpds, + final String validationQuery, + final int validationQueryTimeout, + final boolean rollbackAfterValidation, + final String username, + final String password) { _cpds = cpds; _validationQuery = validationQuery; _validationQueryTimeout = validationQueryTimeout; @@ -117,7 +117,7 @@ class CPDSConnectionFactory * @param pool the {@link ObjectPool} in which to pool those {@link * Connection}s */ - public void setPool(ObjectPool<PooledConnectionAndInfo> pool) { + public void setPool(final ObjectPool<PooledConnectionAndInfo> pool) { this._pool = pool; } @@ -141,7 +141,7 @@ class CPDSConnectionFactory pc.addConnectionEventListener(this); pci = new PooledConnectionAndInfo(pc, _username, _password); pcMap.put(pc, pci); - } catch (SQLException e) { + } catch (final SQLException e) { throw new RuntimeException(e.getMessage()); } return new DefaultPooledObject<>(pci); @@ -151,26 +151,26 @@ class CPDSConnectionFactory * Closes the PooledConnection and stops listening for events from it. */ @Override - public void destroyObject(PooledObject<PooledConnectionAndInfo> p) throws Exception { + public void destroyObject(final PooledObject<PooledConnectionAndInfo> p) throws Exception { doDestroyObject(p.getObject()); } - private void doDestroyObject(PooledConnectionAndInfo pci) throws Exception{ - PooledConnection pc = pci.getPooledConnection(); + private void doDestroyObject(final PooledConnectionAndInfo pci) throws Exception{ + final PooledConnection pc = pci.getPooledConnection(); pc.removeConnectionEventListener(this); pcMap.remove(pc); pc.close(); } @Override - public boolean validateObject(PooledObject<PooledConnectionAndInfo> p) { + public boolean validateObject(final PooledObject<PooledConnectionAndInfo> p) { try { validateLifetime(p); - } catch (Exception e) { + } catch (final Exception e) { return false; } boolean valid = false; - PooledConnection pconn = p.getObject().getPooledConnection(); + final PooledConnection pconn = p.getObject().getPooledConnection(); Connection conn = null; validatingSet.add(pconn); if (null == _validationQuery) { @@ -181,7 +181,7 @@ class CPDSConnectionFactory try { conn = pconn.getConnection(); valid = conn.isValid(timeout); - } catch (SQLException e) { + } catch (final SQLException e) { valid = false; } finally { Utils.closeQuietly(conn); @@ -207,7 +207,7 @@ class CPDSConnectionFactory if (_rollbackAfterValidation) { conn.rollback(); } - } catch (Exception e) { + } catch (final Exception e) { valid = false; } finally { Utils.closeQuietly(rset); @@ -220,13 +220,13 @@ class CPDSConnectionFactory } @Override - public void passivateObject(PooledObject<PooledConnectionAndInfo> p) + public void passivateObject(final PooledObject<PooledConnectionAndInfo> p) throws Exception { validateLifetime(p); } @Override - public void activateObject(PooledObject<PooledConnectionAndInfo> p) + public void activateObject(final PooledObject<PooledConnectionAndInfo> p) throws Exception { validateLifetime(p); } @@ -242,25 +242,25 @@ class CPDSConnectionFactory * release this PooledConnection from our pool... */ @Override - public void connectionClosed(ConnectionEvent event) { - PooledConnection pc = (PooledConnection) event.getSource(); + public void connectionClosed(final ConnectionEvent event) { + final PooledConnection pc = (PooledConnection) event.getSource(); // if this event occurred because we were validating, ignore it // otherwise return the connection to the pool. if (!validatingSet.contains(pc)) { - PooledConnectionAndInfo pci = pcMap.get(pc); + final PooledConnectionAndInfo pci = pcMap.get(pc); if (pci == null) { throw new IllegalStateException(NO_KEY_MESSAGE); } try { _pool.returnObject(pci); - } catch (Exception e) { + } catch (final Exception e) { System.err.println("CLOSING DOWN CONNECTION AS IT COULD " + "NOT BE RETURNED TO THE POOL"); pc.removeConnectionEventListener(this); try { doDestroyObject(pci); - } catch (Exception e2) { + } catch (final Exception e2) { System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + pci); e2.printStackTrace(); @@ -274,8 +274,8 @@ class CPDSConnectionFactory * not to be returned in the future */ @Override - public void connectionErrorOccurred(ConnectionEvent event) { - PooledConnection pc = (PooledConnection)event.getSource(); + public void connectionErrorOccurred(final ConnectionEvent event) { + final PooledConnection pc = (PooledConnection)event.getSource(); if (null != event.getSQLException()) { System.err.println( "CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR (" @@ -283,13 +283,13 @@ class CPDSConnectionFactory } pc.removeConnectionEventListener(this); - PooledConnectionAndInfo pci = pcMap.get(pc); + final PooledConnectionAndInfo pci = pcMap.get(pc); if (pci == null) { throw new IllegalStateException(NO_KEY_MESSAGE); } try { _pool.invalidateObject(pci); - } catch (Exception e) { + } catch (final Exception e) { System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + pci); e.printStackTrace(); } @@ -306,15 +306,15 @@ class CPDSConnectionFactory * and connections that are checked out are closed on return. */ @Override - public void invalidate(PooledConnection pc) throws SQLException { - PooledConnectionAndInfo pci = pcMap.get(pc); + public void invalidate(final PooledConnection pc) throws SQLException { + final PooledConnectionAndInfo pci = pcMap.get(pc); if (pci == null) { throw new IllegalStateException(NO_KEY_MESSAGE); } try { _pool.invalidateObject(pci); // Destroy instance and update pool counters _pool.close(); // Clear any other instances in this pool and kill others as they come back - } catch (Exception ex) { + } catch (final Exception ex) { throw new SQLException("Error invalidating connection", ex); } } @@ -325,7 +325,7 @@ class CPDSConnectionFactory * @param password new password */ @Override - public synchronized void setPassword(String password) { + public synchronized void setPassword(final String password) { _password = password; } @@ -336,7 +336,7 @@ class CPDSConnectionFactory * @param maxConnLifetimeMillis A value of zero or less indicates an * infinite lifetime. The default value is -1. */ - public void setMaxConnLifetimeMillis(long maxConnLifetimeMillis) { + public void setMaxConnLifetimeMillis(final long maxConnLifetimeMillis) { this.maxConnLifetimeMillis = maxConnLifetimeMillis; } @@ -345,7 +345,7 @@ class CPDSConnectionFactory * factory and closes the pool if this is the case; otherwise does nothing. */ @Override - public void closePool(String username) throws SQLException { + public void closePool(final String username) throws SQLException { synchronized (this) { if (username == null || !username.equals(_username)) { return; @@ -353,15 +353,15 @@ class CPDSConnectionFactory } try { _pool.close(); - } catch (Exception ex) { + } catch (final Exception ex) { throw new SQLException("Error closing connection pool", ex); } } - private void validateLifetime(PooledObject<PooledConnectionAndInfo> p) + private void validateLifetime(final PooledObject<PooledConnectionAndInfo> p) throws Exception { if (maxConnLifetimeMillis > 0) { - long lifetime = System.currentTimeMillis() - p.getCreateTime(); + final long lifetime = System.currentTimeMillis() - p.getCreateTime(); if (lifetime > maxConnLifetimeMillis) { throw new Exception(Utils.getMessage( "connectionFactory.lifetimeExceeded", Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/InstanceKeyDataSource.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/InstanceKeyDataSource.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/InstanceKeyDataSource.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/InstanceKeyDataSource.java Fri May 13 18:49:32 2016 @@ -43,7 +43,7 @@ import org.apache.tomcat.dbcp.pool2.impl * <code>PerUserPoolDataSource</code>. Many of the configuration properties * are shared and defined here. This class is declared public in order * to allow particular usage with commons-beanutils; do not make direct - * use of it outside of commons-dbcp. + * use of it outside of <em>commons-dbcp2</em>. * </p> * * <p> @@ -70,7 +70,7 @@ import org.apache.tomcat.dbcp.pool2.impl * The dbcp package contains an adapter, * {@link org.apache.tomcat.dbcp.dbcp2.cpdsadapter.DriverAdapterCPDS}, * that can be used to allow the use of <code>DataSource</code>'s based on this - * class with jdbc driver implementations that do not supply a + * class with JDBC driver implementations that do not supply a * <code>ConnectionPoolDataSource</code>, but still * provide a {@link java.sql.Driver} implementation. * </p> @@ -193,12 +193,12 @@ public abstract class InstanceKeyDataSou /* JDBC_4_ANT_KEY_BEGIN */ @Override - public boolean isWrapperFor(Class<?> iface) throws SQLException { + public boolean isWrapperFor(final Class<?> iface) throws SQLException { return false; } @Override - public <T> T unwrap(Class<T> iface) throws SQLException { + public <T> T unwrap(final Class<T> iface) throws SQLException { throw new SQLException("InstanceKeyDataSource is not a wrapper."); } /* JDBC_4_ANT_KEY_END */ @@ -227,7 +227,7 @@ public abstract class InstanceKeyDataSou * user pool. * @param blockWhenExhausted The new value */ - public void setDefaultBlockWhenExhausted(boolean blockWhenExhausted) { + public void setDefaultBlockWhenExhausted(final boolean blockWhenExhausted) { assertInitializationAllowed(); this.defaultBlockWhenExhausted = blockWhenExhausted; } @@ -248,7 +248,7 @@ public abstract class InstanceKeyDataSou * @param evictionPolicyClassName The new value */ public void setDefaultEvictionPolicyClassName( - String evictionPolicyClassName) { + final String evictionPolicyClassName) { assertInitializationAllowed(); this.defaultEvictionPolicyClassName = evictionPolicyClassName; } @@ -266,7 +266,7 @@ public abstract class InstanceKeyDataSou * {@link GenericKeyedObjectPoolConfig#getLifo()} for each per user pool. * @param lifo The new value */ - public void setDefaultLifo(boolean lifo) { + public void setDefaultLifo(final boolean lifo) { assertInitializationAllowed(); this.defaultLifo = lifo; } @@ -286,7 +286,7 @@ public abstract class InstanceKeyDataSou * pool. * @param maxIdle The new value */ - public void setDefaultMaxIdle(int maxIdle) { + public void setDefaultMaxIdle(final int maxIdle) { assertInitializationAllowed(); this.defaultMaxIdle = maxIdle; } @@ -306,7 +306,7 @@ public abstract class InstanceKeyDataSou * user pool. * @param maxTotal The new value */ - public void setDefaultMaxTotal(int maxTotal) { + public void setDefaultMaxTotal(final int maxTotal) { assertInitializationAllowed(); this.defaultMaxTotal = maxTotal; } @@ -326,7 +326,7 @@ public abstract class InstanceKeyDataSou * pool. * @param maxWaitMillis The new value */ - public void setDefaultMaxWaitMillis(long maxWaitMillis) { + public void setDefaultMaxWaitMillis(final long maxWaitMillis) { assertInitializationAllowed(); this.defaultMaxWaitMillis = maxWaitMillis; } @@ -347,7 +347,7 @@ public abstract class InstanceKeyDataSou * @param minEvictableIdleTimeMillis The new value */ public void setDefaultMinEvictableIdleTimeMillis( - long minEvictableIdleTimeMillis) { + final long minEvictableIdleTimeMillis) { assertInitializationAllowed(); this.defaultMinEvictableIdleTimeMillis = minEvictableIdleTimeMillis; } @@ -367,7 +367,7 @@ public abstract class InstanceKeyDataSou * pool. * @param minIdle The new value */ - public void setDefaultMinIdle(int minIdle) { + public void setDefaultMinIdle(final int minIdle) { assertInitializationAllowed(); this.defaultMinIdle = minIdle; } @@ -387,7 +387,7 @@ public abstract class InstanceKeyDataSou * per user pool. * @param numTestsPerEvictionRun The new value */ - public void setDefaultNumTestsPerEvictionRun(int numTestsPerEvictionRun) { + public void setDefaultNumTestsPerEvictionRun(final int numTestsPerEvictionRun) { assertInitializationAllowed(); this.defaultNumTestsPerEvictionRun = numTestsPerEvictionRun; } @@ -407,7 +407,7 @@ public abstract class InstanceKeyDataSou * @param softMinEvictableIdleTimeMillis The new value */ public void setDefaultSoftMinEvictableIdleTimeMillis( - long softMinEvictableIdleTimeMillis) { + final long softMinEvictableIdleTimeMillis) { assertInitializationAllowed(); this.defaultSoftMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis; } @@ -425,7 +425,7 @@ public abstract class InstanceKeyDataSou * {@link org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool GenericObjectPool#getTestOnCreate()} for each per user pool. * @param testOnCreate The new value */ - public void setDefaultTestOnCreate(boolean testOnCreate) { + public void setDefaultTestOnCreate(final boolean testOnCreate) { assertInitializationAllowed(); this.defaultTestOnCreate = testOnCreate; } @@ -443,7 +443,7 @@ public abstract class InstanceKeyDataSou * {@link org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool GenericObjectPool#getTestOnBorrow()} for each per user pool. * @param testOnBorrow The new value */ - public void setDefaultTestOnBorrow(boolean testOnBorrow) { + public void setDefaultTestOnBorrow(final boolean testOnBorrow) { assertInitializationAllowed(); this.defaultTestOnBorrow = testOnBorrow; } @@ -461,7 +461,7 @@ public abstract class InstanceKeyDataSou * {@link org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool GenericObjectPool#getTestOnReturn()} for each per user pool. * @param testOnReturn The new value */ - public void setDefaultTestOnReturn(boolean testOnReturn) { + public void setDefaultTestOnReturn(final boolean testOnReturn) { assertInitializationAllowed(); this.defaultTestOnReturn = testOnReturn; } @@ -479,7 +479,7 @@ public abstract class InstanceKeyDataSou * {@link org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool GenericObjectPool#getTestWhileIdle()} for each per user pool. * @param testWhileIdle The new value */ - public void setDefaultTestWhileIdle(boolean testWhileIdle) { + public void setDefaultTestWhileIdle(final boolean testWhileIdle) { assertInitializationAllowed(); this.defaultTestWhileIdle = testWhileIdle; } @@ -500,7 +500,7 @@ public abstract class InstanceKeyDataSou * @param timeBetweenEvictionRunsMillis The new value */ public void setDefaultTimeBetweenEvictionRunsMillis ( - long timeBetweenEvictionRunsMillis ) { + final long timeBetweenEvictionRunsMillis ) { assertInitializationAllowed(); this.defaultTimeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis ; } @@ -521,7 +521,7 @@ public abstract class InstanceKeyDataSou * * @param v Value to assign to connectionPoolDataSource. */ - public void setConnectionPoolDataSource(ConnectionPoolDataSource v) { + public void setConnectionPoolDataSource(final ConnectionPoolDataSource v) { assertInitializationAllowed(); if (dataSourceName != null) { throw new IllegalStateException( @@ -554,7 +554,7 @@ public abstract class InstanceKeyDataSou * * @param v Value to assign to dataSourceName. */ - public void setDataSourceName(String v) { + public void setDataSourceName(final String v) { assertInitializationAllowed(); if (dataSource != null) { throw new IllegalStateException( @@ -593,7 +593,7 @@ public abstract class InstanceKeyDataSou * * @param v Value to assign to defaultAutoCommit. */ - public void setDefaultAutoCommit(Boolean v) { + public void setDefaultAutoCommit(final Boolean v) { assertInitializationAllowed(); this.defaultAutoCommit = v; } @@ -620,7 +620,7 @@ public abstract class InstanceKeyDataSou * * @param v Value to assign to defaultReadOnly. */ - public void setDefaultReadOnly(Boolean v) { + public void setDefaultReadOnly(final Boolean v) { assertInitializationAllowed(); this.defaultReadOnly = v; } @@ -645,7 +645,7 @@ public abstract class InstanceKeyDataSou * * @param v Value to assign to defaultTransactionIsolation */ - public void setDefaultTransactionIsolation(int v) { + public void setDefaultTransactionIsolation(final int v) { assertInitializationAllowed(); switch (v) { case Connection.TRANSACTION_NONE: @@ -661,7 +661,7 @@ public abstract class InstanceKeyDataSou } /** - * Get the description. This property is defined by jdbc as for use with + * Get the description. This property is defined by JDBC as for use with * GUI (or other) tools that might deploy the datasource. It serves no * internal purpose. * @@ -672,13 +672,13 @@ public abstract class InstanceKeyDataSou } /** - * Set the description. This property is defined by jdbc as for use with + * Set the description. This property is defined by JDBC as for use with * GUI (or other) tools that might deploy the datasource. It serves no * internal purpose. * * @param v Value to assign to description. */ - public void setDescription(String v) { + public void setDescription(final String v) { this.description = v; } @@ -693,7 +693,7 @@ public abstract class InstanceKeyDataSou * @param key The environment property name * @return value of jndiEnvironment. */ - public String getJndiEnvironment(String key) { + public String getJndiEnvironment(final String key) { String value = null; if (jndiEnvironment != null) { value = jndiEnvironment.getProperty(key); @@ -709,7 +709,7 @@ public abstract class InstanceKeyDataSou * @param key the JNDI environment property to set. * @param value the value assigned to specified JNDI environment property. */ - public void setJndiEnvironment(String key, String value) { + public void setJndiEnvironment(final String key, final String value) { if (jndiEnvironment == null) { jndiEnvironment = new Properties(); } @@ -724,7 +724,7 @@ public abstract class InstanceKeyDataSou * @param properties the JNDI environment property to set which will * overwrite any current settings */ - void setJndiEnvironment(Properties properties) { + void setJndiEnvironment(final Properties properties) { if (jndiEnvironment == null) { jndiEnvironment = new Properties(); } else { @@ -747,7 +747,7 @@ public abstract class InstanceKeyDataSou * @param v Value to assign to loginTimeout. */ @Override - public void setLoginTimeout(int v) { + public void setLoginTimeout(final int v) { this.loginTimeout = v; } @@ -769,7 +769,7 @@ public abstract class InstanceKeyDataSou * @param v Value to assign to logWriter. */ @Override - public void setLogWriter(PrintWriter v) { + public void setLogWriter(final PrintWriter v) { this.logWriter = v; } @@ -793,7 +793,7 @@ public abstract class InstanceKeyDataSou * {@link Connection#isValid(int)}. * @param validationQuery The validation query */ - public void setValidationQuery(String validationQuery) { + public void setValidationQuery(final String validationQuery) { assertInitializationAllowed(); this.validationQuery = validationQuery; } @@ -810,7 +810,7 @@ public abstract class InstanceKeyDataSou * * @param validationQueryTimeout The new timeout in seconds */ - public void setValidationQueryTimeout(int validationQueryTimeout) { + public void setValidationQueryTimeout(final int validationQueryTimeout) { this.validationQueryTimeout = validationQueryTimeout; } @@ -835,7 +835,7 @@ public abstract class InstanceKeyDataSou * * @param rollbackAfterValidation new property value */ - public void setRollbackAfterValidation(boolean rollbackAfterValidation) { + public void setRollbackAfterValidation(final boolean rollbackAfterValidation) { assertInitializationAllowed(); this.rollbackAfterValidation = rollbackAfterValidation; } @@ -858,7 +858,7 @@ public abstract class InstanceKeyDataSou * setLoginTimeout, getLoginTimeout, getLogWriter.</code></p> * @param maxConnLifetimeMillis The maximum connection lifetime */ - public void setMaxConnLifetimeMillis(long maxConnLifetimeMillis) { + public void setMaxConnLifetimeMillis(final long maxConnLifetimeMillis) { this.maxConnLifetimeMillis = maxConnLifetimeMillis; } @@ -894,7 +894,7 @@ public abstract class InstanceKeyDataSou * @throws SQLException Connection failed */ @Override - public Connection getConnection(String username, String password) + public Connection getConnection(final String username, final String password) throws SQLException { if (instanceKey == null) { throw new SQLException("Must set the ConnectionPoolDataSource " @@ -905,16 +905,16 @@ public abstract class InstanceKeyDataSou PooledConnectionAndInfo info = null; try { info = getPooledConnectionAndInfo(username, password); - } catch (NoSuchElementException e) { + } catch (final NoSuchElementException e) { closeDueToException(info); throw new SQLException("Cannot borrow connection from pool", e); - } catch (RuntimeException e) { + } catch (final RuntimeException e) { closeDueToException(info); throw e; - } catch (SQLException e) { + } catch (final SQLException e) { closeDueToException(info); throw e; - } catch (Exception e) { + } catch (final Exception e) { closeDueToException(info); throw new SQLException("Cannot borrow connection from pool", e); } @@ -923,12 +923,12 @@ public abstract class InstanceKeyDataSou : password.equals(info.getPassword()))) { // Password on PooledConnectionAndInfo does not match try { // See if password has changed by attempting connection testCPDS(username, password); - } catch (SQLException ex) { + } catch (final SQLException ex) { // Password has not changed, so refuse client, but return connection to the pool closeDueToException(info); throw new SQLException("Given password did not match password used" + " to create the PooledConnection.", ex); - } catch (javax.naming.NamingException ne) { + } catch (final javax.naming.NamingException ne) { throw new SQLException( "NamingException encountered connecting to database", ne); } @@ -944,16 +944,16 @@ public abstract class InstanceKeyDataSou for (int i = 0; i < 10; i++) { // Bound the number of retries - only needed if bad instances return try { info = getPooledConnectionAndInfo(username, password); - } catch (NoSuchElementException e) { + } catch (final NoSuchElementException e) { closeDueToException(info); throw new SQLException("Cannot borrow connection from pool", e); - } catch (RuntimeException e) { + } catch (final RuntimeException e) { closeDueToException(info); throw e; - } catch (SQLException e) { + } catch (final SQLException e) { closeDueToException(info); throw e; - } catch (Exception e) { + } catch (final Exception e) { closeDueToException(info); throw new SQLException("Cannot borrow connection from pool", e); } @@ -970,15 +970,15 @@ public abstract class InstanceKeyDataSou } } - Connection con = info.getPooledConnection().getConnection(); + final Connection con = info.getPooledConnection().getConnection(); try { setupDefaults(con, username); con.clearWarnings(); return con; - } catch (SQLException ex) { + } catch (final SQLException ex) { try { con.close(); - } catch (Exception exc) { + } catch (final Exception exc) { getLogWriter().println( "ignoring exception during close: " + exc); } @@ -994,11 +994,11 @@ public abstract class InstanceKeyDataSou throws SQLException; - private void closeDueToException(PooledConnectionAndInfo info) { + private void closeDueToException(final PooledConnectionAndInfo info) { if (info != null) { try { info.getPooledConnection().getConnection().close(); - } catch (Exception e) { + } catch (final Exception e) { // do not throw this exception because we are in the middle // of handling another exception. But record it because // it potentially leaks connections from the pool. @@ -1009,7 +1009,7 @@ public abstract class InstanceKeyDataSou } protected ConnectionPoolDataSource - testCPDS(String username, String password) + testCPDS(final String username, final String password) throws javax.naming.NamingException, SQLException { // The source of physical db connections ConnectionPoolDataSource cpds = this.dataSource; @@ -1020,7 +1020,7 @@ public abstract class InstanceKeyDataSou } else { ctx = new InitialContext(jndiEnvironment); } - Object ds = ctx.lookup(dataSourceName); + final Object ds = ctx.lookup(dataSourceName); if (ds instanceof ConnectionPoolDataSource) { cpds = (ConnectionPoolDataSource) ds; } else { @@ -1050,7 +1050,7 @@ public abstract class InstanceKeyDataSou try { conn.close(); } - catch (SQLException e) { + catch (final SQLException e) { // at least we could connect } } Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/InstanceKeyDataSourceFactory.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/InstanceKeyDataSourceFactory.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/InstanceKeyDataSourceFactory.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/InstanceKeyDataSourceFactory.java Fri May 13 18:49:32 2016 @@ -44,27 +44,27 @@ abstract class InstanceKeyDataSourceFact private static final Map<String, InstanceKeyDataSource> instanceMap = new ConcurrentHashMap<>(); - static synchronized String registerNewInstance(InstanceKeyDataSource ds) { + static synchronized String registerNewInstance(final InstanceKeyDataSource ds) { int max = 0; - Iterator<String> i = instanceMap.keySet().iterator(); + final Iterator<String> i = instanceMap.keySet().iterator(); while (i.hasNext()) { - String s = i.next(); + final String s = i.next(); if (s != null) { try { max = Math.max(max, Integer.parseInt(s)); - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { // no sweat, ignore those keys } } } - String instanceKey = String.valueOf(max + 1); + final String instanceKey = String.valueOf(max + 1); // put a placeholder here for now, so other instances will not // take our key. we will replace with a pool when ready. instanceMap.put(instanceKey, ds); return instanceKey; } - static void removeInstance(String key) { + static void removeInstance(final String key) { if (key != null) { instanceMap.remove(key); } @@ -76,7 +76,7 @@ abstract class InstanceKeyDataSourceFact */ public static void closeAll() throws Exception { //Get iterator to loop over all instances of this datasource. - Iterator<Entry<String,InstanceKeyDataSource>> instanceIterator = + final Iterator<Entry<String,InstanceKeyDataSource>> instanceIterator = instanceMap.entrySet().iterator(); while (instanceIterator.hasNext()) { instanceIterator.next().getValue().close(); @@ -90,16 +90,16 @@ abstract class InstanceKeyDataSourceFact * or PerUserPoolDataSource. */ @Override - public Object getObjectInstance(Object refObj, Name name, - Context context, Hashtable<?,?> env) + public Object getObjectInstance(final Object refObj, final Name name, + final Context context, final Hashtable<?,?> env) throws IOException, ClassNotFoundException { // The spec says to return null if we can't create an instance // of the reference Object obj = null; if (refObj instanceof Reference) { - Reference ref = (Reference) refObj; + final Reference ref = (Reference) refObj; if (isCorrectClass(ref.getClassName())) { - RefAddr ra = ref.get("instanceKey"); + final RefAddr ra = ref.get("instanceKey"); if (ra != null && ra.getContent() != null) { // object was bound to jndi via Referenceable api. obj = instanceMap.get(ra.getContent()); @@ -117,7 +117,7 @@ abstract class InstanceKeyDataSourceFact } if (obj == null) { - InstanceKeyDataSource ds = getNewInstance(ref); + final InstanceKeyDataSource ds = getNewInstance(ref); setCommonProperties(ref, ds); obj = ds; if (key != null) @@ -131,8 +131,8 @@ abstract class InstanceKeyDataSourceFact return obj; } - private void setCommonProperties(Reference ref, - InstanceKeyDataSource ikds) + private void setCommonProperties(final Reference ref, + final InstanceKeyDataSource ikds) throws IOException, ClassNotFoundException { RefAddr ra = ref.get("dataSourceName"); @@ -147,7 +147,7 @@ abstract class InstanceKeyDataSourceFact ra = ref.get("jndiEnvironment"); if (ra != null && ra.getContent() != null) { - byte[] serialized = (byte[]) ra.getContent(); + final byte[] serialized = (byte[]) ra.getContent(); ikds.setJndiEnvironment((Properties) deserialize(serialized)); } @@ -320,7 +320,7 @@ abstract class InstanceKeyDataSourceFact * @throws IOException Stream error * @throws ClassNotFoundException Couldn't load object class */ - protected static final Object deserialize(byte[] data) + protected static final Object deserialize(final byte[] data) throws IOException, ClassNotFoundException { ObjectInputStream in = null; try { @@ -330,7 +330,7 @@ abstract class InstanceKeyDataSourceFact if (in != null) { try { in.close(); - } catch (IOException ex) { + } catch (final IOException ex) { } } } Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/KeyedCPDSConnectionFactory.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/KeyedCPDSConnectionFactory.java?rev=1743719&r1=1743718&r2=1743719&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/KeyedCPDSConnectionFactory.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/datasources/KeyedCPDSConnectionFactory.java Fri May 13 18:49:32 2016 @@ -86,17 +86,17 @@ class KeyedCPDSConnectionFactory * @param rollbackAfterValidation whether a rollback should be issued after * {@link #validateObject validating} {@link Connection}s. */ - public KeyedCPDSConnectionFactory(ConnectionPoolDataSource cpds, - String validationQuery, - int validationQueryTimeout, - boolean rollbackAfterValidation) { + public KeyedCPDSConnectionFactory(final ConnectionPoolDataSource cpds, + final String validationQuery, + final int validationQueryTimeout, + final boolean rollbackAfterValidation) { _cpds = cpds; _validationQuery = validationQuery; _validationQueryTimeout = validationQueryTimeout; _rollbackAfterValidation = rollbackAfterValidation; } - public void setPool(KeyedObjectPool<UserPassKey,PooledConnectionAndInfo> pool) { + public void setPool(final KeyedObjectPool<UserPassKey,PooledConnectionAndInfo> pool) { this._pool = pool; } @@ -117,13 +117,13 @@ class KeyedCPDSConnectionFactory * @see org.apache.tomcat.dbcp.pool2.KeyedPooledObjectFactory#makeObject(java.lang.Object) */ @Override - public synchronized PooledObject<PooledConnectionAndInfo> makeObject(UserPassKey upkey) + public synchronized PooledObject<PooledConnectionAndInfo> makeObject(final UserPassKey upkey) throws Exception { PooledConnectionAndInfo pci = null; PooledConnection pc = null; - String username = upkey.getUsername(); - String password = upkey.getPassword(); + final String username = upkey.getUsername(); + final String password = upkey.getPassword(); if (username == null) { pc = _cpds.getPooledConnection(); } else { @@ -147,9 +147,9 @@ class KeyedCPDSConnectionFactory * Closes the PooledConnection and stops listening for events from it. */ @Override - public void destroyObject(UserPassKey key, PooledObject<PooledConnectionAndInfo> p) + public void destroyObject(final UserPassKey key, final PooledObject<PooledConnectionAndInfo> p) throws Exception { - PooledConnection pc = p.getObject().getPooledConnection(); + final PooledConnection pc = p.getObject().getPooledConnection(); pc.removeConnectionEventListener(this); pcMap.remove(pc); pc.close(); @@ -164,15 +164,15 @@ class KeyedCPDSConnectionFactory * @return true if validation succeeds */ @Override - public boolean validateObject(UserPassKey key, - PooledObject<PooledConnectionAndInfo> p) { + public boolean validateObject(final UserPassKey key, + final PooledObject<PooledConnectionAndInfo> p) { try { validateLifetime(p); - } catch (Exception e) { + } catch (final Exception e) { return false; } boolean valid = false; - PooledConnection pconn = p.getObject().getPooledConnection(); + final PooledConnection pconn = p.getObject().getPooledConnection(); Connection conn = null; validatingSet.add(pconn); if (null == _validationQuery) { @@ -183,7 +183,7 @@ class KeyedCPDSConnectionFactory try { conn = pconn.getConnection(); valid = conn.isValid(timeout); - } catch (SQLException e) { + } catch (final SQLException e) { valid = false; } finally { Utils.closeQuietly(conn); @@ -209,7 +209,7 @@ class KeyedCPDSConnectionFactory if (_rollbackAfterValidation) { conn.rollback(); } - } catch(Exception e) { + } catch(final Exception e) { valid = false; } finally { Utils.closeQuietly(rset); @@ -222,14 +222,14 @@ class KeyedCPDSConnectionFactory } @Override - public void passivateObject(UserPassKey key, - PooledObject<PooledConnectionAndInfo> p) throws Exception { + public void passivateObject(final UserPassKey key, + final PooledObject<PooledConnectionAndInfo> p) throws Exception { validateLifetime(p); } @Override - public void activateObject(UserPassKey key, - PooledObject<PooledConnectionAndInfo> p) throws Exception { + public void activateObject(final UserPassKey key, + final PooledObject<PooledConnectionAndInfo> p) throws Exception { validateLifetime(p); } @@ -244,25 +244,25 @@ class KeyedCPDSConnectionFactory * release this PooledConnection from our pool... */ @Override - public void connectionClosed(ConnectionEvent event) { - PooledConnection pc = (PooledConnection)event.getSource(); + public void connectionClosed(final ConnectionEvent event) { + final PooledConnection pc = (PooledConnection)event.getSource(); // if this event occurred because we were validating, or if this // connection has been marked for removal, ignore it // otherwise return the connection to the pool. if (!validatingSet.contains(pc)) { - PooledConnectionAndInfo pci = pcMap.get(pc); + final PooledConnectionAndInfo pci = pcMap.get(pc); if (pci == null) { throw new IllegalStateException(NO_KEY_MESSAGE); } try { _pool.returnObject(pci.getUserPassKey(), pci); - } catch (Exception e) { + } catch (final Exception e) { System.err.println("CLOSING DOWN CONNECTION AS IT COULD " + "NOT BE RETURNED TO THE POOL"); pc.removeConnectionEventListener(this); try { _pool.invalidateObject(pci.getUserPassKey(), pci); - } catch (Exception e3) { + } catch (final Exception e3) { System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + pci); e3.printStackTrace(); @@ -276,8 +276,8 @@ class KeyedCPDSConnectionFactory * not to be returned in the future */ @Override - public void connectionErrorOccurred(ConnectionEvent event) { - PooledConnection pc = (PooledConnection)event.getSource(); + public void connectionErrorOccurred(final ConnectionEvent event) { + final PooledConnection pc = (PooledConnection)event.getSource(); if (null != event.getSQLException()) { System.err .println("CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR (" + @@ -285,13 +285,13 @@ class KeyedCPDSConnectionFactory } pc.removeConnectionEventListener(this); - PooledConnectionAndInfo info = pcMap.get(pc); + final PooledConnectionAndInfo info = pcMap.get(pc); if (info == null) { throw new IllegalStateException(NO_KEY_MESSAGE); } try { _pool.invalidateObject(info.getUserPassKey(), info); - } catch (Exception e) { + } catch (final Exception e) { System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + info); e.printStackTrace(); } @@ -309,16 +309,16 @@ class KeyedCPDSConnectionFactory * are not affected and they will not be automatically closed on return to the pool. */ @Override - public void invalidate(PooledConnection pc) throws SQLException { - PooledConnectionAndInfo info = pcMap.get(pc); + public void invalidate(final PooledConnection pc) throws SQLException { + final PooledConnectionAndInfo info = pcMap.get(pc); if (info == null) { throw new IllegalStateException(NO_KEY_MESSAGE); } - UserPassKey key = info.getUserPassKey(); + final UserPassKey key = info.getUserPassKey(); try { _pool.invalidateObject(key, info); // Destroy and update pool counters _pool.clear(key); // Remove any idle instances with this key - } catch (Exception ex) { + } catch (final Exception ex) { throw new SQLException("Error invalidating connection", ex); } } @@ -327,7 +327,7 @@ class KeyedCPDSConnectionFactory * Does nothing. This factory does not cache user credentials. */ @Override - public void setPassword(String password) { + public void setPassword(final String password) { } /** @@ -337,7 +337,7 @@ class KeyedCPDSConnectionFactory * @param maxConnLifetimeMillis A value of zero or less indicates an * infinite lifetime. The default value is -1. */ - public void setMaxConnLifetimeMillis(long maxConnLifetimeMillis) { + public void setMaxConnLifetimeMillis(final long maxConnLifetimeMillis) { this.maxConnLifetimeMillis = maxConnLifetimeMillis; } @@ -347,18 +347,18 @@ class KeyedCPDSConnectionFactory * with the given user. This method is not currently used. */ @Override - public void closePool(String username) throws SQLException { + public void closePool(final String username) throws SQLException { try { _pool.clear(new UserPassKey(username, null)); - } catch (Exception ex) { + } catch (final Exception ex) { throw new SQLException("Error closing connection pool", ex); } } - private void validateLifetime(PooledObject<PooledConnectionAndInfo> p) + private void validateLifetime(final PooledObject<PooledConnectionAndInfo> p) throws Exception { if (maxConnLifetimeMillis > 0) { - long lifetime = System.currentTimeMillis() - p.getCreateTime(); + final long lifetime = System.currentTimeMillis() - p.getCreateTime(); if (lifetime > maxConnLifetimeMillis) { throw new Exception(Utils.getMessage( "connectionFactory.lifetimeExceeded", --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org