This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 7.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push: new 292198a Remove use of deprecated code. SQLNestedException -> SQLException 292198a is described below commit 292198acbe21a13ab350e7396bcb37b83237df9d Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Mar 22 09:08:39 2019 +0000 Remove use of deprecated code. SQLNestedException -> SQLException --- .../apache/tomcat/dbcp/dbcp/BasicDataSource.java | 10 +++--- .../dbcp/dbcp/PoolableCallableStatement.java | 2 +- .../dbcp/dbcp/PoolablePreparedStatement.java | 2 +- .../apache/tomcat/dbcp/dbcp/PoolingConnection.java | 10 +++--- .../apache/tomcat/dbcp/dbcp/PoolingDataSource.java | 4 +-- .../dbcp/cpdsadapter/PooledConnectionImpl.java | 15 ++++----- .../dbcp/datasources/InstanceKeyDataSource.java | 9 +++--- .../dbcp/datasources/PerUserPoolDataSource.java | 8 ++--- .../dbcp/datasources/SharedPoolDataSource.java | 37 +++++++++++----------- 9 files changed, 46 insertions(+), 51 deletions(-) diff --git a/java/org/apache/tomcat/dbcp/dbcp/BasicDataSource.java b/java/org/apache/tomcat/dbcp/dbcp/BasicDataSource.java index 2797448..6fe2488 100644 --- a/java/org/apache/tomcat/dbcp/dbcp/BasicDataSource.java +++ b/java/org/apache/tomcat/dbcp/dbcp/BasicDataSource.java @@ -1408,7 +1408,7 @@ public class BasicDataSource implements DataSource { } catch(RuntimeException e) { throw e; } catch(Exception e) { - throw new SQLNestedException("Cannot close connection pool", e); + throw new SQLException("Cannot close connection pool", e); } } @@ -1523,7 +1523,7 @@ public class BasicDataSource implements DataSource { } } catch (Exception e) { closeConnectionPool(); - throw new SQLNestedException("Error preloading the connection pool", e); + throw new SQLException("Error preloading the connection pool", e); } // If timeBetweenEvictionRunsMillis > 0, start the pool's evictor task @@ -1570,7 +1570,7 @@ public class BasicDataSource implements DataSource { driverClassName + "'"; logWriter.println(message); t.printStackTrace(logWriter); - throw new SQLNestedException(message, t); + throw new SQLException(message, t); } } @@ -1593,7 +1593,7 @@ public class BasicDataSource implements DataSource { "' for connect URL '" + url + "'"; logWriter.println(message); t.printStackTrace(logWriter); - throw new SQLNestedException(message, t); + throw new SQLException(message, t); } // Can't test without a validationQuery @@ -1721,7 +1721,7 @@ public class BasicDataSource implements DataSource { } catch (RuntimeException e) { throw e; } catch (Exception e) { - throw new SQLNestedException("Cannot create PoolableConnectionFactory (" + e.getMessage() + ")", e); + throw new SQLException("Cannot create PoolableConnectionFactory (" + e.getMessage() + ")", e); } } diff --git a/java/org/apache/tomcat/dbcp/dbcp/PoolableCallableStatement.java b/java/org/apache/tomcat/dbcp/dbcp/PoolableCallableStatement.java index acd2db5..cf9a1f1 100644 --- a/java/org/apache/tomcat/dbcp/dbcp/PoolableCallableStatement.java +++ b/java/org/apache/tomcat/dbcp/dbcp/PoolableCallableStatement.java @@ -80,7 +80,7 @@ public class PoolableCallableStatement extends DelegatingCallableStatement { } catch(RuntimeException e) { throw e; } catch(Exception e) { - throw new SQLNestedException("Cannot close CallableStatement (return to pool failed)", e); + throw new SQLException("Cannot close CallableStatement (return to pool failed)", e); } } } diff --git a/java/org/apache/tomcat/dbcp/dbcp/PoolablePreparedStatement.java b/java/org/apache/tomcat/dbcp/dbcp/PoolablePreparedStatement.java index 7c86d7e..d3770e2 100644 --- a/java/org/apache/tomcat/dbcp/dbcp/PoolablePreparedStatement.java +++ b/java/org/apache/tomcat/dbcp/dbcp/PoolablePreparedStatement.java @@ -101,7 +101,7 @@ public class PoolablePreparedStatement extends DelegatingPreparedStatement { } catch(RuntimeException e) { throw e; } catch(Exception e) { - throw new SQLNestedException("Cannot close preparedstatement (return to pool failed)", e); + throw new SQLException("Cannot close preparedstatement (return to pool failed)", e); } } } diff --git a/java/org/apache/tomcat/dbcp/dbcp/PoolingConnection.java b/java/org/apache/tomcat/dbcp/dbcp/PoolingConnection.java index 56f558e..d049392 100644 --- a/java/org/apache/tomcat/dbcp/dbcp/PoolingConnection.java +++ b/java/org/apache/tomcat/dbcp/dbcp/PoolingConnection.java @@ -111,7 +111,7 @@ public class PoolingConnection extends DelegatingConnection implements KeyedPool } catch(RuntimeException e) { throw e; } catch(Exception e) { - throw new SQLNestedException("Borrow prepareStatement from pool failed", e); + throw new SQLException("Borrow prepareStatement from pool failed", e); } } @@ -151,11 +151,11 @@ public class PoolingConnection extends DelegatingConnection implements KeyedPool try { return (CallableStatement) (_pstmtPool.borrowObject(createKey(sql, STATEMENT_CALLABLESTMT))); } catch (NoSuchElementException e) { - throw new SQLNestedException("MaxOpenCallableStatements limit reached", e); + throw new SQLException("MaxOpenCallableStatements limit reached", e); } catch (RuntimeException e) { throw e; } catch (Exception e) { - throw new SQLNestedException("Borrow callableStatement from pool failed", e); + throw new SQLException("Borrow callableStatement from pool failed", e); } } @@ -174,11 +174,11 @@ public class PoolingConnection extends DelegatingConnection implements KeyedPool return (CallableStatement) (_pstmtPool.borrowObject(createKey(sql, resultSetType, resultSetConcurrency, STATEMENT_CALLABLESTMT))); } catch (NoSuchElementException e) { - throw new SQLNestedException("MaxOpenCallableStatements limit reached", e); + throw new SQLException("MaxOpenCallableStatements limit reached", e); } catch (RuntimeException e) { throw e; } catch (Exception e) { - throw new SQLNestedException("Borrow callableStatement from pool failed", e); + throw new SQLException("Borrow callableStatement from pool failed", e); } } diff --git a/java/org/apache/tomcat/dbcp/dbcp/PoolingDataSource.java b/java/org/apache/tomcat/dbcp/dbcp/PoolingDataSource.java index 392bad3..43b7ce3 100644 --- a/java/org/apache/tomcat/dbcp/dbcp/PoolingDataSource.java +++ b/java/org/apache/tomcat/dbcp/dbcp/PoolingDataSource.java @@ -120,11 +120,11 @@ public class PoolingDataSource implements DataSource { } catch(SQLException e) { throw e; } catch(NoSuchElementException e) { - throw new SQLNestedException("Cannot get a connection, pool error " + e.getMessage(), e); + throw new SQLException("Cannot get a connection, pool error " + e.getMessage(), e); } catch(RuntimeException e) { throw e; } catch(Exception e) { - throw new SQLNestedException("Cannot get a connection, general error", e); + throw new SQLException("Cannot get a connection, general error", e); } } diff --git a/java/org/apache/tomcat/dbcp/dbcp/cpdsadapter/PooledConnectionImpl.java b/java/org/apache/tomcat/dbcp/dbcp/cpdsadapter/PooledConnectionImpl.java index 8b38332..8dfcc5b 100644 --- a/java/org/apache/tomcat/dbcp/dbcp/cpdsadapter/PooledConnectionImpl.java +++ b/java/org/apache/tomcat/dbcp/dbcp/cpdsadapter/PooledConnectionImpl.java @@ -30,7 +30,6 @@ import javax.sql.StatementEventListener; import org.apache.tomcat.dbcp.dbcp.DelegatingConnection; import org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement; -import org.apache.tomcat.dbcp.dbcp.SQLNestedException; import org.apache.tomcat.dbcp.pool.KeyedObjectPool; import org.apache.tomcat.dbcp.pool.KeyedPoolableObjectFactory; @@ -143,7 +142,7 @@ class PooledConnectionImpl } catch (RuntimeException e) { throw e; } catch (Exception e) { - throw new SQLNestedException("Cannot close connection (return to pool failed)", e); + throw new SQLException("Cannot close connection (return to pool failed)", e); } finally { try { connection.close(); @@ -248,7 +247,7 @@ class PooledConnectionImpl } catch (RuntimeException e) { throw e; } catch (Exception e) { - throw new SQLNestedException("Borrow prepareStatement from pool failed", e); + throw new SQLException("Borrow prepareStatement from pool failed", e); } } } @@ -281,7 +280,7 @@ class PooledConnectionImpl } catch (RuntimeException e) { throw e; } catch (Exception e) { - throw new SQLNestedException("Borrow prepareStatement from pool failed", e); + throw new SQLException("Borrow prepareStatement from pool failed", e); } } } @@ -308,7 +307,7 @@ class PooledConnectionImpl } catch (RuntimeException e) { throw e; } catch (Exception e) { - throw new SQLNestedException("Borrow prepareStatement from pool failed", e); + throw new SQLException("Borrow prepareStatement from pool failed", e); } } } @@ -327,7 +326,7 @@ class PooledConnectionImpl } catch (RuntimeException e) { throw e; } catch (Exception e) { - throw new SQLNestedException("Borrow prepareStatement from pool failed", e); + throw new SQLException("Borrow prepareStatement from pool failed", e); } } } @@ -343,7 +342,7 @@ class PooledConnectionImpl } catch (RuntimeException e) { throw e; } catch (Exception e) { - throw new SQLNestedException("Borrow prepareStatement from pool failed", e); + throw new SQLException("Borrow prepareStatement from pool failed", e); } } } @@ -359,7 +358,7 @@ class PooledConnectionImpl } catch (RuntimeException e) { throw e; } catch (Exception e) { - throw new SQLNestedException("Borrow prepareStatement from pool failed", e); + throw new SQLException("Borrow prepareStatement from pool failed", e); } } } diff --git a/java/org/apache/tomcat/dbcp/dbcp/datasources/InstanceKeyDataSource.java b/java/org/apache/tomcat/dbcp/dbcp/datasources/InstanceKeyDataSource.java index 79709c4..94dfe4e 100644 --- a/java/org/apache/tomcat/dbcp/dbcp/datasources/InstanceKeyDataSource.java +++ b/java/org/apache/tomcat/dbcp/dbcp/datasources/InstanceKeyDataSource.java @@ -36,7 +36,6 @@ import javax.sql.ConnectionPoolDataSource; import javax.sql.DataSource; import javax.sql.PooledConnection; -import org.apache.tomcat.dbcp.dbcp.SQLNestedException; import org.apache.tomcat.dbcp.pool.impl.GenericObjectPool; /** @@ -715,7 +714,7 @@ public abstract class InstanceKeyDataSource info = getPooledConnectionAndInfo(username, password); } catch (NoSuchElementException e) { closeDueToException(info); - throw new SQLNestedException("Cannot borrow connection from pool", e); + throw new SQLException("Cannot borrow connection from pool", e); } catch (RuntimeException e) { closeDueToException(info); throw e; @@ -724,7 +723,7 @@ public abstract class InstanceKeyDataSource throw e; } catch (Exception e) { closeDueToException(info); - throw new SQLNestedException("Cannot borrow connection from pool", e); + throw new SQLException("Cannot borrow connection from pool", e); } if (!(null == password ? null == info.getPassword() @@ -754,7 +753,7 @@ public abstract class InstanceKeyDataSource info = getPooledConnectionAndInfo(username, password); } catch (NoSuchElementException e) { closeDueToException(info); - throw new SQLNestedException("Cannot borrow connection from pool", e); + throw new SQLException("Cannot borrow connection from pool", e); } catch (RuntimeException e) { closeDueToException(info); throw e; @@ -763,7 +762,7 @@ public abstract class InstanceKeyDataSource throw e; } catch (Exception e) { closeDueToException(info); - throw new SQLNestedException("Cannot borrow connection from pool", e); + throw new SQLException("Cannot borrow connection from pool", e); } if (info != null && password.equals(info.getPassword())) { break; diff --git a/java/org/apache/tomcat/dbcp/dbcp/datasources/PerUserPoolDataSource.java b/java/org/apache/tomcat/dbcp/dbcp/datasources/PerUserPoolDataSource.java index fffc762..4ed8ad0 100644 --- a/java/org/apache/tomcat/dbcp/dbcp/datasources/PerUserPoolDataSource.java +++ b/java/org/apache/tomcat/dbcp/dbcp/datasources/PerUserPoolDataSource.java @@ -31,8 +31,6 @@ import javax.naming.Reference; import javax.naming.StringRefAddr; import javax.sql.ConnectionPoolDataSource; -import org.apache.tomcat.dbcp.dbcp.SQLNestedException; - import org.apache.tomcat.dbcp.pool.ObjectPool; import org.apache.tomcat.dbcp.pool.impl.GenericObjectPool; @@ -383,7 +381,7 @@ public class PerUserPoolDataSource registerPool(username, password); manager = (PooledConnectionManager) managers.get(key); } catch (NamingException e) { - throw new SQLNestedException("RegisterPool failed", e); + throw new SQLException("RegisterPool failed", e); } } pool = ((CPDSConnectionFactory) manager).getPool(); @@ -394,7 +392,7 @@ public class PerUserPoolDataSource info = (PooledConnectionAndInfo) pool.borrowObject(); } catch (NoSuchElementException ex) { - throw new SQLNestedException( + throw new SQLException( "Could not retrieve connection info from pool", ex); } catch (Exception e) { @@ -414,7 +412,7 @@ public class PerUserPoolDataSource registerPool(username, password); pool = getPool(key); } catch (NamingException ne) { - throw new SQLNestedException("RegisterPool failed", ne); + throw new SQLException("RegisterPool failed", ne); } try { info = (PooledConnectionAndInfo)(pool).borrowObject(); diff --git a/java/org/apache/tomcat/dbcp/dbcp/datasources/SharedPoolDataSource.java b/java/org/apache/tomcat/dbcp/dbcp/datasources/SharedPoolDataSource.java index 4023688..21c5fbc 100644 --- a/java/org/apache/tomcat/dbcp/dbcp/datasources/SharedPoolDataSource.java +++ b/java/org/apache/tomcat/dbcp/dbcp/datasources/SharedPoolDataSource.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,16 +30,15 @@ import javax.sql.ConnectionPoolDataSource; import org.apache.tomcat.dbcp.pool.KeyedObjectPool; import org.apache.tomcat.dbcp.pool.impl.GenericKeyedObjectPool; import org.apache.tomcat.dbcp.pool.impl.GenericObjectPool; -import org.apache.tomcat.dbcp.dbcp.SQLNestedException; /** * <p>A pooling <code>DataSource</code> appropriate for deployment within * J2EE environment. There are many configuration options, most of which are - * defined in the parent class. All users (based on username) share a single + * defined in the parent class. All users (based on username) share a single * maximum number of Connections in this datasource.</p> - * + * * <p>User passwords can be changed without re-initializing the datasource. - * When a <code>getConnection(username, password)</code> request is processed + * When a <code>getConnection(username, password)</code> request is processed * with a password that is different from those used to create connections in the * pool associated with <code>username</code>, an attempt is made to create a * new connection using the supplied password and if this succeeds, idle connections @@ -119,7 +118,7 @@ public class SharedPoolDataSource /** * The maximum number of milliseconds that the pool will wait (when there * are no available connections) for a connection to be returned before - * throwing an exception, or -1 to wait indefinitely. Will fail + * throwing an exception, or -1 to wait indefinitely. Will fail * immediately if value is 0. * The default is -1. */ @@ -130,7 +129,7 @@ public class SharedPoolDataSource /** * The maximum number of milliseconds that the pool will wait (when there * are no available connections) for a connection to be returned before - * throwing an exception, or -1 to wait indefinitely. Will fail + * throwing an exception, or -1 to wait indefinitely. Will fail * immediately if value is 0. * The default is -1. */ @@ -160,34 +159,34 @@ public class SharedPoolDataSource // Inherited abstract methods @Override - protected PooledConnectionAndInfo + protected PooledConnectionAndInfo getPooledConnectionAndInfo(String username, String password) throws SQLException { - + synchronized(this) { if (pool == null) { try { registerPool(username, password); } catch (NamingException e) { - throw new SQLNestedException("RegisterPool failed", e); + throw new SQLException("RegisterPool failed", e); } } } PooledConnectionAndInfo info = null; - + UserPassKey key = new UserPassKey(username, password); - + try { info = (PooledConnectionAndInfo) pool.borrowObject(key); } catch (Exception e) { - throw new SQLNestedException( + throw new SQLException( "Could not retrieve connection info from pool", e); } return info; } - + @Override protected PooledConnectionManager getConnectionManager(UserPassKey upkey) { return factory; @@ -195,7 +194,7 @@ public class SharedPoolDataSource /** * Returns a <code>SharedPoolDataSource</code> {@link Reference}. - * + * * @since 1.2.2 */ @Override @@ -205,9 +204,9 @@ public class SharedPoolDataSource ref.add(new StringRefAddr("instanceKey", instanceKey)); return ref; } - + private void registerPool( - String username, String password) + String username, String password) throws javax.naming.NamingException, SQLException { ConnectionPoolDataSource cpds = testCPDS(username, password); @@ -260,7 +259,7 @@ public class SharedPoolDataSource */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - try + try { in.defaultReadObject(); SharedPoolDataSource oldDS = (SharedPoolDataSource) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org