fix: Non-determinism in S3PropertySourceTest #1538
Open
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.
📢 Type of change
📜 Description
This pull request updates the
S3PropertySourceTest.shouldParseDifferentFilesFromBuckettest to avoid relying on a non-deterministic ordering of property names.The test asserted the exact order of the property names:
However,
propertySource.getPropertyNames()is derived from a collection whose iteration order is not guaranteed (e.g. Hashtable). With repeated run, the property names can be returned as["key2", "key1"]. The changes in this pull request usecontainsExactlyInAnyOrder()to validate the presence of both keys regardless of order:💡 Motivation and Context
When running with NonDex,
S3PropertySourceTest.shouldParseDifferentFilesFromBucketwas reported as non-deterministic. NonDex is a tool for detecting wrong assumptions on under-determined Java APIs. By relaxing the assertion in the test to be order-independent, we preserve the original intent of the test and eliminating nondeterministic behavior. This improves test reliability in continuous integration environments.💚 How did you test it?
Run NonDex on
spring-cloud-aws-s3module using the following command:📝 Checklist
🔮 Next steps