Fix: Nondeterminism behavior in SqsListenerAnnotationBeanPostProcessorTests #1536
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 test
shouldRegisterClassLevelSqsListenerWithSqsHandlersinSqsListenerAnnotationBeanPostProcessorTeststo avoid relying on the implicit method ordering returned by reflection.Previously, the test compared methods using fixed index positions:
However, it does not guarantee a deterministic ordering of methods returned by Class#getDeclaredMethods() or collections derived from it. As a result, the test becomes nondeterministic and fails under NonDex tool or repeated runs. The updated version checks only the presence of the two
@SqsHandleroverloads by validating their parameter types (String.classandInteger.class) in any order, making the test deterministic.💡 Motivation and Context
This change ensures that the test remains stable under randomized iteration orders. When running with NonDex, the test failed intermittently because it assumed a fixed order for handler method discovery, even though this order is not guaranteed. By relaxing the assertion 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-sqsmodule using the following command:📝 Checklist
🔮 Next steps