Skip to content

Conversation

@Fr4nk03
Copy link

@Fr4nk03 Fr4nk03 commented Nov 21, 2025

Pull Request

Description

This Pull Request resolves a non-deterministic ordering in shouldThrowPutUserBadRequestExceptionWhenParametersAreIncorrect inside user/validator/PutUsersRequestValidatorTest when comparing expected error message with the true exception thrown. This behavior was found using the NonDex tool.

Problem:
validateAddressJSONParameter method uses class.getDeclaredFields() to store a list of fields and then it is iterated to store any error messages encountered. However, based on the official Java documentation,

"The elements in the returned array are not sorted and are not in any particular order"

which means that the error message append order is non-deterministic which may be affected by different JVMs, operating systems, or runtime environments, causing the test to fail intermittently.

Solution:
The solution will not affect any features but ensure the stability of the testing framework.

  1. Stabilize Validation: Implemented Collections.sort() on the list of field names in PutUsersRequestValidator before iteration to ensure validation errors from reflection are generated in a predictable, alphabetical order.
  2. Refactored Test: Field "City" now comes before "Country"

REFERENCE:
Oracle Doc

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Database migration
  • Performance improvement
  • Refactoring

Database Changes

  • No database changes
  • New migration files added
  • Existing migration files modified
  • Migration tested locally
  • Rollback strategy documented

Changelog

  • Updated CHANGELOG.md with changes
  • Added entry to appropriate section (Added/Changed/Fixed/etc.)
  • Included database migration details if applicable
  • Followed changelog guidelines

Testing

  • Unit tests pass
  • Integration tests pass
  • Manual testing completed
  • Database migration tested
  • Rollback tested (if applicable)

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated
  • No sensitive information exposed
  • Performance impact considered

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello there!

Thank you for your contribution! We're delighted to see your Pull Request in our GitHub repository. Your efforts make a difference. Thanks a lot!

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