diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 55cd4617e..9372219a0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,6 +49,14 @@ jobs: restore-keys: | ${{ runner.os }}-maven-${{ github.workflow }} + - name: Set up JDK 11 + if: ${{ github.base_ref != 'release/1.11' && github.ref_name != 'release/1.11' }} + uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1 + with: + distribution: 'temurin' + java-version: '11' + overwrite-settings: false + - name: Build with Maven run: mvn clean test -fae -T 2 -B -V -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 diff --git a/amazon-redshift-plugin/pom.xml b/amazon-redshift-plugin/pom.xml index ad3d34e68..7de5c79dd 100644 --- a/amazon-redshift-plugin/pom.xml +++ b/amazon-redshift-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Amazon Redshift plugin diff --git a/aurora-mysql-plugin/pom.xml b/aurora-mysql-plugin/pom.xml index a8eaca6ab..62de92d3f 100644 --- a/aurora-mysql-plugin/pom.xml +++ b/aurora-mysql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Aurora DB MySQL plugin diff --git a/aurora-postgresql-plugin/pom.xml b/aurora-postgresql-plugin/pom.xml index b22c2725a..b78d8724e 100644 --- a/aurora-postgresql-plugin/pom.xml +++ b/aurora-postgresql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Aurora DB PostgreSQL plugin diff --git a/cloudsql-mysql-plugin/pom.xml b/cloudsql-mysql-plugin/pom.xml index 358730e2f..136353319 100644 --- a/cloudsql-mysql-plugin/pom.xml +++ b/cloudsql-mysql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT CloudSQL MySQL plugin diff --git a/cloudsql-postgresql-plugin/pom.xml b/cloudsql-postgresql-plugin/pom.xml index cb77d6968..056d7f52d 100644 --- a/cloudsql-postgresql-plugin/pom.xml +++ b/cloudsql-postgresql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT CloudSQL PostgreSQL plugin diff --git a/database-commons/pom.xml b/database-commons/pom.xml index 713e076fe..c62b2686a 100644 --- a/database-commons/pom.xml +++ b/database-commons/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Database Commons diff --git a/database-commons/src/test/java/io/cdap/plugin/db/connector/DBSpecificFailedConnectionMessageTest.java b/database-commons/src/test/java/io/cdap/plugin/db/connector/DBSpecificFailedConnectionMessageTest.java new file mode 100644 index 000000000..f5a2e69b2 --- /dev/null +++ b/database-commons/src/test/java/io/cdap/plugin/db/connector/DBSpecificFailedConnectionMessageTest.java @@ -0,0 +1,60 @@ +/* + * Copyright © 2026 Cask Data, Inc. + * + * Licensed 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. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package io.cdap.plugin.db.connector; + +import org.junit.Assert; +import org.junit.Test; + +public class DBSpecificFailedConnectionMessageTest { + + @Test + public void testNormalizeConnectionArgumentsReordersProperties() { + String jdk8Order = "Failed to create connection to database via connection string: " + + "jdbc:mysql://localhost:3306 and arguments: {user=username, rewriteBatchedStatements=true, " + + "connectTimeout=20000, tinyInt1isBit=false, socketTimeout=20000}. Error: " + + "ConnectException: Connection refused (Connection refused)."; + String jdk11Order = "Failed to create connection to database via connection string: " + + "jdbc:mysql://localhost:3306 and arguments: {rewriteBatchedStatements=true, tinyInt1isBit=false, " + + "connectTimeout=20000, socketTimeout=20000, user=username}. Error: " + + "ConnectException: Connection refused (Connection refused)."; + + Assert.assertEquals(DBSpecificFailedConnectionTest.normalizeConnectionArguments(jdk8Order), + DBSpecificFailedConnectionTest.normalizeConnectionArguments(jdk11Order)); + } + + @Test + public void testNormalizeConnectionArgumentsDetectsMismatchedValues() { + String expected = "Failed to create connection to database via connection string: " + + "jdbc:mysql://localhost:3306 and arguments: {user=username, connectTimeout=20000}. Error: " + + "ConnectException: Connection refused."; + String mismatchedValue = "Failed to create connection to database via connection string: " + + "jdbc:mysql://localhost:3306 and arguments: {connectTimeout=30000, user=username}. Error: " + + "ConnectException: Connection refused."; + + Assert.assertNotEquals(DBSpecificFailedConnectionTest.normalizeConnectionArguments(expected), + DBSpecificFailedConnectionTest.normalizeConnectionArguments(mismatchedValue)); + } + + @Test + public void testNormalizeConnectionArgumentsHandlesEmptyAndUnformattedMessages() { + String emptyArgs = "Failed to create connection to database via connection string: " + + "jdbc:h2:mem:test and arguments: {}. Error: SQLException."; + Assert.assertEquals(emptyArgs, DBSpecificFailedConnectionTest.normalizeConnectionArguments(emptyArgs)); + Assert.assertEquals("Plain error", DBSpecificFailedConnectionTest.normalizeConnectionArguments("Plain error")); + Assert.assertNull(DBSpecificFailedConnectionTest.normalizeConnectionArguments(null)); + } +} diff --git a/database-commons/src/test/java/io/cdap/plugin/db/connector/DBSpecificFailedConnectionTest.java b/database-commons/src/test/java/io/cdap/plugin/db/connector/DBSpecificFailedConnectionTest.java index b18b395ff..4d0d04a7d 100644 --- a/database-commons/src/test/java/io/cdap/plugin/db/connector/DBSpecificFailedConnectionTest.java +++ b/database-commons/src/test/java/io/cdap/plugin/db/connector/DBSpecificFailedConnectionTest.java @@ -26,10 +26,13 @@ import org.mockito.Mockito; import java.io.IOException; +import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; public class DBSpecificFailedConnectionTest { - private static final String JDBC_DRIVER_CLASS_NAME = "oracle.jdbc.OracleDriver"; + private static final String ARGS_PREFIX = " and arguments: {"; + private static final String ARGS_SUFFIX = "}. Error: "; protected void test(String jdbcClassName, AbstractDBSpecificConnector connector, String expectedErrorMsg) throws ClassNotFoundException, IOException { @@ -45,6 +48,26 @@ protected void test(String jdbcClassName, AbstractDBSpecificConnector connector, connector.test(context); List validationFailures = context.getFailureCollector().getValidationFailures(); Assert.assertEquals(1, validationFailures.size()); - Assert.assertEquals(expectedErrorMsg, validationFailures.get(0).getMessage()); + Assert.assertEquals(normalizeConnectionArguments(expectedErrorMsg), + normalizeConnectionArguments(validationFailures.get(0).getMessage())); + } + + static String normalizeConnectionArguments(String errorMsg) { + if (errorMsg == null) { + return null; + } + int argsStart = errorMsg.indexOf(ARGS_PREFIX); + if (argsStart < 0) { + return errorMsg; + } + int contentStart = argsStart + ARGS_PREFIX.length(); + int argsEnd = errorMsg.indexOf(ARGS_SUFFIX, contentStart); + if (argsEnd <= contentStart) { + return errorMsg; + } + String sortedArgs = Arrays.stream(errorMsg.substring(contentStart, argsEnd).split(", ", -1)) + .sorted() + .collect(Collectors.joining(", ")); + return errorMsg.substring(0, contentStart) + sortedArgs + errorMsg.substring(argsEnd); } } diff --git a/databricks-plugin/pom.xml b/databricks-plugin/pom.xml index c023f96d0..14d840420 100644 --- a/databricks-plugin/pom.xml +++ b/databricks-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Databricks plugin diff --git a/db2-plugin/pom.xml b/db2-plugin/pom.xml index 9faba7400..fc03e0436 100644 --- a/db2-plugin/pom.xml +++ b/db2-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT IBM DB2 plugin diff --git a/generic-database-plugin/pom.xml b/generic-database-plugin/pom.xml index 90923d24f..265785f6e 100644 --- a/generic-database-plugin/pom.xml +++ b/generic-database-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Generic database plugin diff --git a/generic-db-argument-setter/pom.xml b/generic-db-argument-setter/pom.xml index 67790100c..71186fb84 100644 --- a/generic-db-argument-setter/pom.xml +++ b/generic-db-argument-setter/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Generic database argument setter plugin diff --git a/mariadb-plugin/pom.xml b/mariadb-plugin/pom.xml index 253b4fa00..01d31352e 100644 --- a/mariadb-plugin/pom.xml +++ b/mariadb-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Maria DB plugin diff --git a/memsql-plugin/pom.xml b/memsql-plugin/pom.xml index 14687b3b4..03d21a553 100644 --- a/memsql-plugin/pom.xml +++ b/memsql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Memsql plugin diff --git a/mssql-plugin/pom.xml b/mssql-plugin/pom.xml index 79813938c..c68abc3c8 100644 --- a/mssql-plugin/pom.xml +++ b/mssql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Microsoft SQL Server plugin diff --git a/mysql-plugin/pom.xml b/mysql-plugin/pom.xml index 02abb60bc..b3cba310b 100644 --- a/mysql-plugin/pom.xml +++ b/mysql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Mysql plugin diff --git a/netezza-plugin/pom.xml b/netezza-plugin/pom.xml index 3c167e046..a5c0d894d 100644 --- a/netezza-plugin/pom.xml +++ b/netezza-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Netezza plugin diff --git a/oracle-plugin/pom.xml b/oracle-plugin/pom.xml index d5a95804e..772e09916 100644 --- a/oracle-plugin/pom.xml +++ b/oracle-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT Oracle plugin diff --git a/pom.xml b/pom.xml index c371231f4..4a18b88b5 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ io.cdap.plugin database-plugins-parent - 1.12.6 + 1.12.7-SNAPSHOT pom Database Plugins Collection of database plugins diff --git a/postgresql-plugin/pom.xml b/postgresql-plugin/pom.xml index b6cf42513..285f46ac5 100644 --- a/postgresql-plugin/pom.xml +++ b/postgresql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT PostgreSQL plugin diff --git a/saphana-plugin/pom.xml b/saphana-plugin/pom.xml index cd2bb73f3..25b048da9 100644 --- a/saphana-plugin/pom.xml +++ b/saphana-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT SAP HANA plugin diff --git a/teradata-plugin/pom.xml b/teradata-plugin/pom.xml index def18b908..279c58656 100644 --- a/teradata-plugin/pom.xml +++ b/teradata-plugin/pom.xml @@ -21,7 +21,7 @@ database-plugins-parent io.cdap.plugin - 1.12.6 + 1.12.7-SNAPSHOT teradata-plugin