Skip to content

[cherry-pick][1.12] Fix failed-connection tests on JDK 11 and set up JDK 11 in CI - #694

Merged
sahusanket merged 3 commits into
release/1.12from
cherry-pick/1.12-jdk11-unit-tests
Nov 24, 2026
Merged

sahusanket merged 3 commits into
release/1.12from
cherry-pick/1.12-jdk11-unit-tests

Conversation

@sahusanket

Copy link
Copy Markdown
Contributor

Cherry-picks #692 onto release/1.12.

Problem

On JDK 11, MysqlFailedConnectionTest and OracleFailedConnectionTest fail because DBSpecificFailedConnectionTest compares raw validation error strings containing Properties.toString(). Java 9+ changed Properties to store entries in an internal ConcurrentHashMap rather than Hashtable, which changes map iteration order when multiple connection properties are present. The GitHub Actions unit test workflow also runs without configuring JDK 11.

Fix

  • Normalize the key=value entries inside the connection arguments block in DBSpecificFailedConnectionTest before comparing messages, keeping assertions strict on the JDBC URL, properties, and error text across JDK 8 and JDK 11.
  • Configure Temurin 11 (overwrite-settings: false) in the unit test workflow for branches other than release/1.11.

Testing

Verified mvn clean test -B across all 20 modules on JDK 11 passes RAT, Checkstyle, and all 149 unit tests (128 executed, 21 live-DB suites skipped).

On JDK 11, MysqlFailedConnectionTest and OracleFailedConnectionTest fail because DBSpecificFailedConnectionTest compares raw validation error strings containing Properties.toString(). Java 9+ changed Properties to store entries in an internal ConcurrentHashMap rather than Hashtable, which changes map iteration order when multiple connection properties are present. The GitHub Actions unit test workflow also runs without configuring JDK 11.

Normalize the key=value entries inside the connection arguments block in DBSpecificFailedConnectionTest before comparing messages. That keeps assertions strict on the JDBC URL, properties, and error text across JDK 8 and JDK 11. Configure Temurin 11 in the unit test workflow for branches other than release/1.11.

Verified mvn clean test -B across all 20 modules on JDK 11 passes RAT, Checkstyle, and all 207 unit tests (186 executed, 21 live-DB suites skipped).

(cherry picked from commit 8b79784)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a normalization utility, normalizeConnectionArguments, in DBSpecificFailedConnectionTest along with a new test class DBSpecificFailedConnectionMessageTest. This utility sorts connection arguments in error messages to prevent test failures caused by non-deterministic argument ordering across different JDK versions (such as JDK 8 and JDK 11). A review comment suggests optimizing this normalization method by skipping the stream operations when there are zero or one arguments.

Comment on lines +68 to +70
String sortedArgs = Arrays.stream(errorMsg.substring(contentStart, argsEnd).split(", ", -1))
.sorted()
.collect(Collectors.joining(", "));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For error messages with zero or one connection arguments, there is no need to split, sort, and rejoin the arguments. We can optimize this by checking if the arguments substring contains the delimiter , before performing the stream operations. This avoids unnecessary object allocations and stream overhead for the common cases of single or empty arguments.

    String argsSubstring = errorMsg.substring(contentStart, argsEnd);
    if (!argsSubstring.contains(", ")) {
      return errorMsg;
    }
    String sortedArgs = Arrays.stream(argsSubstring.split(", ", -1))
      .sorted()
      .collect(Collectors.joining(", "));

@sahusanket
sahusanket merged commit 56302ed into release/1.12 Nov 24, 2026
13 checks passed
@sahusanket
sahusanket deleted the cherry-pick/1.12-jdk11-unit-tests branch November 24, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants