Skip to content

Conversation

@yonghanlin
Copy link

@yonghanlin yonghanlin commented Dec 10, 2025

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

This pull request updates the S3PropertySourceTest.shouldParseDifferentFilesFromBucket test to avoid relying on a non-deterministic ordering of property names.

The test asserted the exact order of the property names:

assertThat(propertySource.getPropertyNames()).containsExactly("key1", "key2");

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 use containsExactlyInAnyOrder() to validate the presence of both keys regardless of order:

assertThat(propertySource.getPropertyNames()).containsExactlyInAnyOrder("key1", "key2");

💡 Motivation and Context

When running with NonDex, S3PropertySourceTest.shouldParseDifferentFilesFromBucket was 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-s3 module using the following command:

mvn -pl spring-cloud-aws-s3 edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=io.awspring.cloud.s3.config.S3PropertySourceTest#shouldParseDifferentFilesFromBucket 

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated reference documentation to reflect the change
  • All tests passing
  • No breaking changes

🔮 Next steps

@yonghanlin yonghanlin changed the title fix:nondeterminism in S3PropertySourceTest fix: Nondeterminism in S3PropertySourceTest Dec 10, 2025
@yonghanlin yonghanlin changed the title fix: Nondeterminism in S3PropertySourceTest fix: Non-determinism in S3PropertySourceTest Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant