This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git
The following commit(s) were added to refs/heads/master by this push: new ba17f72e Internal refactoring ba17f72e is described below commit ba17f72e2018251eb9aa0e9b8bfd762ab791b2eb Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Sat Jul 9 18:55:20 2022 -0400 Internal refactoring --- .../java/org/apache/commons/dbcp2/PStmtKey.java | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java b/src/main/java/org/apache/commons/dbcp2/PStmtKey.java index f2f39f04..1e631037 100644 --- a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java +++ b/src/main/java/org/apache/commons/dbcp2/PStmtKey.java @@ -125,6 +125,7 @@ public class PStmtKey { /** * Interface for Prepared or Callable Statement. */ + @FunctionalInterface private interface StatementBuilder { Statement createStatement(Connection connection) throws SQLException; } @@ -359,7 +360,7 @@ public class PStmtKey { this.schema = null; this.statementType = StatementType.PREPARED_STATEMENT; this.autoGeneratedKeys = null; - this.columnIndexes = columnIndexes == null ? null : Arrays.copyOf(columnIndexes, columnIndexes.length); + this.columnIndexes = clone(columnIndexes); this.columnNames = null; this.resultSetType = null; this.resultSetConcurrency = null; @@ -548,7 +549,7 @@ public class PStmtKey { this.schema = schema; this.statementType = StatementType.PREPARED_STATEMENT; this.autoGeneratedKeys = null; - this.columnIndexes = columnIndexes == null ? null : Arrays.copyOf(columnIndexes, columnIndexes.length); + this.columnIndexes = clone(columnIndexes); this.columnNames = null; this.resultSetType = null; this.resultSetConcurrency = null; @@ -621,7 +622,7 @@ public class PStmtKey { this.statementType = StatementType.PREPARED_STATEMENT; this.autoGeneratedKeys = null; this.columnIndexes = null; - this.columnNames = columnNames == null ? null : Arrays.copyOf(columnNames, columnNames.length); + this.columnNames = clone(columnNames); this.resultSetType = null; this.resultSetConcurrency = null; this.resultSetHoldability = null; @@ -645,13 +646,21 @@ public class PStmtKey { this.statementType = StatementType.PREPARED_STATEMENT; this.autoGeneratedKeys = null; this.columnIndexes = null; - this.columnNames = columnNames == null ? null : Arrays.copyOf(columnNames, columnNames.length); + this.columnNames = clone(columnNames); this.resultSetType = null; this.resultSetConcurrency = null; this.resultSetHoldability = null; this.statementBuilder = new PreparedStatementWithColumnNames(); } + private int[] clone(final int[] array) { + return array == null ? null : array.clone(); + } + + private String[] clone(final String[] array) { + return array == null ? null : array.clone(); + } + /** * Creates a new Statement from the given Connection. * @@ -733,7 +742,7 @@ public class PStmtKey { * @return An array of column indexes. */ public int[] getColumnIndexes() { - return columnIndexes == null ? null : columnIndexes.clone(); + return clone(columnIndexes); } /** @@ -742,7 +751,7 @@ public class PStmtKey { * @return An array of column names. */ public String[] getColumnNames() { - return columnNames == null ? null : columnNames.clone(); + return clone(columnNames); } /**