Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This Pull Request is intend to fix flakiness in the following tests in org.mariadb.jdbc.unit.util.ConfigurationTest
These tests fail intermittently when executed with the NonDex plugin due to non-deterministic ordering of properties. The failure logs are attached for reference:
Cause of the Issue:
The failures occur because the tests compare expected strings with actual strings generated from the
Configuration
object. The ordering of query parameters and non-mapped options in these strings is non-deterministic due to the use ofjava.util.Properties
, which does not guarantee order. This leads to mismatches in the expected and actual outputs during assertions.Fix
All three tests (
testBuild
,builder
, andtoConf
) fail because they perform assertions comparing expected strings to actual strings generated from theConfiguration
object. However, the ordering of query parameters in the connection string is non-deterministic due to the use ofjava.util.Properties
, which does not guarantee the order of its elements. This nondeterminism leads to mismatches during assertions, causing the tests to fail.To resolve this issue for the first two tests (
testBuild
andbuilder
), we introduced a new method callednormalizeConnectionString()
. This method parses the connection string, extracts the query parameters, sorts them lexicographically, and reconstructs the string with the sorted parameters. By fixing the order of the query parameters, these tests now pass consistently. For the third test (toConf
), we addressed the same issue by introducing a new method callednormalizeConfigurationString()
. This method ensures thatnormalizeConnectionString()
is called on the URL generated within the configuration that thetoConf
test checks, thereby standardizing the ordering of query parameters and allowing the test to pass reliably.In addition to the above issue, the
toConf
test fails occasionally because theconf.nonMappedOptions
(unknown options) inorg.mariadb.jdbc.Configuration#toConf
are unordered. Although the method ensures that other option types (non-default options, default options) are ordered, the unorderednonMappedOptions
lead to inconsistent outputs during assertions, causing the test to fail. To fix this, we modified thetoConf
method to sort theconf.nonMappedOptions
, ensuring consistent ordering and eliminating the flakiness in thetoConf
test.PS: Instead of sorting the
conf.nonMappedOptions
inorg.mariadb.jdbc.Configuration#toConf
, I can also implement a fix wherein the test is made flexible to accept a configuration string that contains the desired options in any order.Please let me know if any other changes are required. Thanks!