Repository navigation
[cherry-pick][1.12] Fix failed-connection tests on JDK 11 and set up JDK 11 in CI - #694
Conversation
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)
(cherry picked from commit 63aad2c)
There was a problem hiding this comment.
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.
| String sortedArgs = Arrays.stream(errorMsg.substring(contentStart, argsEnd).split(", ", -1)) | ||
| .sorted() | ||
| .collect(Collectors.joining(", ")); |
There was a problem hiding this comment.
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(", "));
Cherry-picks #692 onto
release/1.12.Problem
On JDK 11,
MysqlFailedConnectionTestandOracleFailedConnectionTestfail becauseDBSpecificFailedConnectionTestcompares raw validation error strings containingProperties.toString(). Java 9+ changedPropertiesto store entries in an internalConcurrentHashMaprather thanHashtable, which changes map iteration order when multiple connection properties are present. The GitHub Actions unit test workflow also runs without configuring JDK 11.Fix
key=valueentries inside the connection arguments block inDBSpecificFailedConnectionTestbefore comparing messages, keeping assertions strict on the JDBC URL, properties, and error text across JDK 8 and JDK 11.overwrite-settings: false) in the unit test workflow for branches other thanrelease/1.11.Testing
Verified
mvn clean test -Bacross all 20 modules on JDK 11 passes RAT, Checkstyle, and all 149 unit tests (128 executed, 21 live-DB suites skipped).