tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1837759 [6/6] - in /tomcat/tc8.5.x/trunk: ./ java/org/apache/tomcat/dbcp/dbcp2/ java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/ java/org/apache/tomcat/dbcp/dbcp2/datasources/ webapps/docs/
Date Thu, 09 Aug 2018 19:12:02 GMT
Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/PoolingConnection.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/PoolingConnection.java?rev=1837759&r1=1837758&r2=1837759&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/PoolingConnection.java (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/PoolingConnection.java Thu Aug
 9 19:12:01 2018
@@ -125,23 +125,7 @@ public class PoolingConnection extends D
      * @return the PStmtKey created for the given arguments.
      */
     protected PStmtKey createKey(final String sql) {
-        String catalog = null;
-        try {
-            catalog = getCatalog();
-        } catch (final SQLException e) {
-            // Ignored
-        }
-        return new PStmtKey(normalizeSQL(sql), catalog);
-    }
-
-    protected PStmtKey createKey(final String sql, final int autoGeneratedKeys) {
-        String catalog = null;
-        try {
-            catalog = getCatalog();
-        } catch (final SQLException e) {
-            // Ignored
-        }
-        return new PStmtKey(normalizeSQL(sql), catalog, autoGeneratedKeys);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull());
     }
 
     /**
@@ -155,13 +139,11 @@ public class PoolingConnection extends D
      * @return the PStmtKey created for the given arguments.
      */
     protected PStmtKey createKey(final String sql, final int columnIndexes[]) {
-        String catalog = null;
-        try {
-            catalog = getCatalog();
-        } catch (final SQLException e) {
-            // Ignored
-        }
-        return new PStmtKey(normalizeSQL(sql), catalog, columnIndexes);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), columnIndexes);
+    }
+
+    protected PStmtKey createKey(final String sql, final int autoGeneratedKeys) {
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), autoGeneratedKeys);
     }
 
     /**
@@ -177,13 +159,7 @@ public class PoolingConnection extends D
      * @return the PStmtKey created for the given arguments.
      */
     protected PStmtKey createKey(final String sql, final int resultSetType, final int resultSetConcurrency)
{
-        String catalog = null;
-        try {
-            catalog = getCatalog();
-        } catch (final SQLException e) {
-            // Ignored
-        }
-        return new PStmtKey(normalizeSQL(sql), catalog, resultSetType, resultSetConcurrency);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), resultSetType,
resultSetConcurrency);
     }
 
     /**
@@ -202,13 +178,8 @@ public class PoolingConnection extends D
      */
     protected PStmtKey createKey(final String sql, final int resultSetType, final int resultSetConcurrency,
             final int resultSetHoldability) {
-        String catalog = null;
-        try {
-            catalog = getCatalog();
-        } catch (final SQLException e) {
-            // Ignored
-        }
-        return new PStmtKey(normalizeSQL(sql), catalog, resultSetType, resultSetConcurrency,
resultSetHoldability);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), resultSetType,
resultSetConcurrency,
+                resultSetHoldability);
     }
 
     /**
@@ -222,21 +193,15 @@ public class PoolingConnection extends D
      *            result set concurrency
      * @param resultSetHoldability
      *            result set holdability
-     * @param stmtType
+     * @param statementType
      *            statement type
      *
      * @return the PStmtKey created for the given arguments.
      */
     protected PStmtKey createKey(final String sql, final int resultSetType, final int resultSetConcurrency,
-            final int resultSetHoldability, final StatementType stmtType) {
-        String catalog = null;
-        try {
-            catalog = getCatalog();
-        } catch (final SQLException e) {
-            // Ignored
-        }
-        return new PStmtKey(normalizeSQL(sql), catalog, resultSetType, resultSetConcurrency,
resultSetHoldability,
-                stmtType);
+            final int resultSetHoldability, final StatementType statementType) {
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), resultSetType,
resultSetConcurrency,
+                resultSetHoldability, statementType);
     }
 
     /**
@@ -248,20 +213,14 @@ public class PoolingConnection extends D
      *            result set type
      * @param resultSetConcurrency
      *            result set concurrency
-     * @param stmtType
+     * @param statementType
      *            statement type
      *
      * @return the PStmtKey created for the given arguments.
      */
     protected PStmtKey createKey(final String sql, final int resultSetType, final int resultSetConcurrency,
-            final StatementType stmtType) {
-        String catalog = null;
-        try {
-            catalog = getCatalog();
-        } catch (final SQLException e) {
-            // Ignored
-        }
-        return new PStmtKey(normalizeSQL(sql), catalog, resultSetType, resultSetConcurrency,
stmtType);
+            final StatementType statementType) {
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), resultSetType,
resultSetConcurrency, statementType);
     }
 
     /**
@@ -269,19 +228,13 @@ public class PoolingConnection extends D
      *
      * @param sql
      *            the SQL string used to define the statement
-     * @param stmtType
+     * @param statementType
      *            statement type
      *
      * @return the PStmtKey created for the given arguments.
      */
-    protected PStmtKey createKey(final String sql, final StatementType stmtType) {
-        String catalog = null;
-        try {
-            catalog = getCatalog();
-        } catch (final SQLException e) {
-            // Ignored
-        }
-        return new PStmtKey(normalizeSQL(sql), catalog, stmtType, null);
+    protected PStmtKey createKey(final String sql, final StatementType statementType) {
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), statementType,
null);
     }
 
     /**
@@ -295,13 +248,7 @@ public class PoolingConnection extends D
      * @return the PStmtKey created for the given arguments.
      */
     protected PStmtKey createKey(final String sql, final String columnNames[]) {
-        String catalog = null;
-        try {
-            catalog = getCatalog();
-        } catch (final SQLException e) {
-            // Ignored
-        }
-        return new PStmtKey(normalizeSQL(sql), catalog, columnNames);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), columnNames);
     }
 
     /**
@@ -319,6 +266,26 @@ public class PoolingConnection extends D
         pooledObject.getObject().getInnermostDelegate().close();
     }
 
+    private String getCatalogOrNull() {
+        String catalog = null;
+        try {
+            catalog = getCatalog();
+        } catch (final SQLException e) {
+            // Ignored
+        }
+        return catalog;
+    }
+
+    private String getSchemaOrNull() {
+        String catalog = null;
+        try {
+            catalog = getSchema();
+        } catch (final SQLException e) {
+            // Ignored
+        }
+        return catalog;
+    }
+
     /**
      * {@link KeyedPooledObjectFactory} method for creating {@link PoolablePreparedStatement}s
or
      * {@link PoolableCallableStatement}s. The <code>stmtType</code> field in
the key determines whether a

Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/Utils.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/Utils.java?rev=1837759&r1=1837758&r2=1837759&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/Utils.java (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/Utils.java Thu Aug  9 19:12:01
2018
@@ -72,6 +72,17 @@ public final class Utils {
     }
 
     /**
+     * Clones the given char[] if not null.
+     *
+     * @param value
+     *            may be null.
+     * @return a cloned char[] or null.
+     */
+    public static char[] clone(final char[] value) {
+        return value == null ? null : value.clone();
+    }
+
+    /**
      * Closes the ResultSet (which may be null).
      *
      * @param resultSet
@@ -169,4 +180,5 @@ public final class Utils {
     public static String toString(final char[] value) {
         return value == null ? null : String.valueOf(value);
     }
+
 }

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=1837759&r1=1837758&r2=1837759&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
Thu Aug  9 19:12:01 2018
@@ -423,8 +423,8 @@ public class DriverAdapterCPDS implement
      */
     public void setPassword(final char[] userPassword) {
         assertInitializationAllowed();
-        this.userPassword = userPassword;
-        update(connectionProperties, KEY_PASSWORD, Utils.toString(userPassword));
+        this.userPassword = Utils.clone(userPassword);
+        update(connectionProperties, KEY_PASSWORD, Utils.toString(this.userPassword));
     }
 
     /**

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=1837759&r1=1837758&r2=1837759&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 Thu
Aug  9 19:12:01 2018
@@ -26,27 +26,87 @@ import org.apache.tomcat.dbcp.dbcp2.PStm
  */
 @Deprecated
 public class PStmtKeyCPDS extends PStmtKey {
+
+    /**
+     * Constructs a key to uniquely identify a prepared statement.
+     *
+     * @param sql
+     *            The SQL statement.
+     */
     public PStmtKeyCPDS(final String sql) {
         super(sql);
     }
 
+    /**
+     * Constructs a key to uniquely identify a prepared statement.
+     *
+     * @param sql
+     *            The SQL statement.
+     * @param autoGeneratedKeys
+     *            A flag indicating whether auto-generated keys should be returned; one of
+     *            <code>Statement.RETURN_GENERATED_KEYS</code> or <code>Statement.NO_GENERATED_KEYS</code>.
+     */
     public PStmtKeyCPDS(final String sql, final int autoGeneratedKeys) {
         super(sql, null, autoGeneratedKeys);
     }
 
+    /**
+     * Constructs a key to uniquely identify a prepared statement.
+     *
+     * @param sql
+     *            The SQL statement.
+     * @param resultSetType
+     *            A result set type; one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
+     *            <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>.
+     * @param resultSetConcurrency
+     *            A concurrency type; one of <code>ResultSet.CONCUR_READ_ONLY</code>
or
+     *            <code>ResultSet.CONCUR_UPDATABLE</code>.
+     */
     public PStmtKeyCPDS(final String sql, final int resultSetType, final int resultSetConcurrency)
{
         super(sql, resultSetType, resultSetConcurrency);
     }
 
+    /**
+     * Constructs a key to uniquely identify a prepared statement.
+     *
+     * @param sql
+     *            The SQL statement.
+     * @param resultSetType
+     *            a result set type; one of <code>ResultSet.TYPE_FORWARD_ONLY</code>,
+     *            <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>.
+     * @param resultSetConcurrency
+     *            A concurrency type; one of <code>ResultSet.CONCUR_READ_ONLY</code>
or
+     *            <code>ResultSet.CONCUR_UPDATABLE</code>
+     * @param resultSetHoldability
+     *            One of the following <code>ResultSet</code> constants: <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code>
+     *            or <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>.
+     */
     public PStmtKeyCPDS(final String sql, final int resultSetType, final int resultSetConcurrency,
             final int resultSetHoldability) {
         super(sql, null, resultSetType, resultSetConcurrency, resultSetHoldability);
     }
 
+    /**
+     * Constructs a key to uniquely identify a prepared statement.
+     *
+     * @param sql
+     *            The SQL statement.
+     * @param columnIndexes
+     *            An array of column indexes indicating the columns that should be returned
from the inserted row or
+     *            rows.
+     */
     public PStmtKeyCPDS(final String sql, final int columnIndexes[]) {
         super(sql, null, columnIndexes);
     }
 
+    /**
+     * Constructs a key to uniquely identify a prepared statement.
+     *
+     * @param sql
+     *            The SQL statement.
+     * @param columnNames
+     *            An array of column names indicating the columns that should be returned
from the inserted row or rows.
+     */
     public PStmtKeyCPDS(final String sql, final String columnNames[]) {
         super(sql, null, columnNames);
     }

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=1837759&r1=1837758&r2=1837759&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
Thu Aug  9 19:12:01 2018
@@ -182,28 +182,29 @@ class PooledConnectionImpl
      * Creates a {@link PStmtKey} for the given arguments.
      */
     protected PStmtKey createKey(final String sql) {
-        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull());
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull());
     }
 
     /**
      * Creates a {@link PStmtKey} for the given arguments.
      */
     protected PStmtKey createKey(final String sql, final int autoGeneratedKeys) {
-        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), autoGeneratedKeys);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), autoGeneratedKeys);
     }
 
     /**
      * Creates a {@link PStmtKey} for the given arguments.
      */
     protected PStmtKey createKey(final String sql, final int columnIndexes[]) {
-        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), columnIndexes);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), columnIndexes);
     }
 
     /**
      * Creates a {@link PStmtKey} for the given arguments.
      */
     protected PStmtKey createKey(final String sql, final int resultSetType, final int resultSetConcurrency)
{
-        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), resultSetType, resultSetConcurrency);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), resultSetType,
+                resultSetConcurrency);
     }
 
     /**
@@ -211,8 +212,8 @@ class PooledConnectionImpl
      */
     protected PStmtKey createKey(final String sql, final int resultSetType, final int resultSetConcurrency,
             final int resultSetHoldability) {
-        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), resultSetType, resultSetConcurrency,
-                resultSetHoldability);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), resultSetType,
+                resultSetConcurrency, resultSetHoldability);
     }
 
     /**
@@ -222,8 +223,8 @@ class PooledConnectionImpl
      */
     protected PStmtKey createKey(final String sql, final int resultSetType, final int resultSetConcurrency,
             final int resultSetHoldability, final StatementType statementType) {
-        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), resultSetType, resultSetConcurrency,
-                resultSetHoldability, statementType);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), resultSetType,
+                resultSetConcurrency, resultSetHoldability, statementType);
     }
 
     /**
@@ -233,21 +234,22 @@ class PooledConnectionImpl
      */
     protected PStmtKey createKey(final String sql, final int resultSetType, final int resultSetConcurrency,
             final StatementType statementType) {
-        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), resultSetType, resultSetConcurrency,
statementType);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), resultSetType,
+                resultSetConcurrency, statementType);
     }
 
     /**
      * Creates a {@link PStmtKey} for the given arguments.
      */
     protected PStmtKey createKey(final String sql, final StatementType statementType) {
-        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), statementType);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), statementType);
     }
 
     /**
      * Creates a {@link PStmtKey} for the given arguments.
      */
     protected PStmtKey createKey(final String sql, final String columnNames[]) {
-        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), columnNames);
+        return new PStmtKey(normalizeSQL(sql), getCatalogOrNull(), getSchemaOrNull(), columnNames);
     }
 
     /**
@@ -289,6 +291,14 @@ class PooledConnectionImpl
         } catch (final SQLException e) {
             return null;
         }
+    }
+
+    private String getSchemaOrNull() {
+        try {
+            return connection == null ? null : connection.getSchema();
+        } catch (final SQLException e) {
+            return null;
+        }
     }
 
     /**

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=1837759&r1=1837758&r2=1837759&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
Thu Aug  9 19:12:01 2018
@@ -123,6 +123,15 @@ class CPDSConnectionFactory
     }
 
     /**
+     * (Testing API) Gets the value of password for the default user.
+     *
+     * @return value of password.
+     */
+    char[] getPasswordCharArray() {
+        return userPassword;
+    }
+
+    /**
      * Returns the object pool used to pool connections created by this factory.
      *
      * @return ObjectPool managing pooled connections
@@ -336,7 +345,7 @@ class CPDSConnectionFactory
      *            new password
      */
     public synchronized void setPassword(final char[] userPassword) {
-        this.userPassword = userPassword;
+        this.userPassword =  Utils.clone(userPassword);
     }
 
     /**

Modified: tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml?rev=1837759&r1=1837758&r2=1837759&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml Thu Aug  9 19:12:01 2018
@@ -225,6 +225,10 @@
         Update the internal fork of Apache Commons Pool 2 to 3e02523
         (2018-08-09) to pick up some bug fixes and enhancements. (markt)
       </update>
+      <update>
+        Update the internal fork of Apache Commons DBCP 2 to abc0484
+        (2018-08-09) to pick up some bug fixes and enhancements. (markt)
+      </update>
     </changelog>
   </subsection>
 </section>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message