Skip to content

Conversation

@yonghanlin
Copy link

@yonghanlin yonghanlin commented Dec 6, 2025

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

This pull request updates the test shouldRegisterClassLevelSqsListenerWithSqsHandlers in
SqsListenerAnnotationBeanPostProcessorTests to avoid relying on the implicit method ordering returned by reflection.

Previously, the test compared methods using fixed index positions:

methods.get(0)
methods.get(1)

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 @SqsHandler overloads by validating their parameter types (String.class and Integer.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-sqs module using the following command:

mvn -pl spring-cloud-aws-sqs edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=io.awspring.cloud.sqs.annotation.SqsListenerAnnotationBeanPostProcessorTests#shouldRegisterClassLevelSqsListenerWithSqsHandlers

📝 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

@github-actions github-actions bot added the component: sqs SQS integration related issue label Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: sqs SQS integration related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant