Inconsistency of getter method detection in GetterPropertySelectionStrategy

Description

There is a problem when a bean has both getX() and hasX() or isX() methods and XML constraint mappings are used.

Example:

The test above throws an exception:

However, the code may work perfectly if the bean has only one property.

This happens because GetterPropertySelectionStrategy.getGetterMethodNameCandidates() returns Set<String> and org.hibernate.validator.internal.util.privilegedactions.GetMethodFromGetterNameCandidates#run iterates through Set, which does not provide any ordering guarantees.

The solution, probably, is using List instead of Set here.

There is PR with test which may help reproduce the issue and possible solution:

Environment

None

Activity

Show:

4devsnetbr October 2, 2021 at 6:54 PM

Fixed

Details

Assignee

Reporter

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

4devsnetbr
Roman Vasilyev

Pull Request

Components

Fix versions

Affects versions

Priority

Created September 29, 2021 at 1:47 PM
Updated December 3, 2024 at 9:34 AM
Resolved June 15, 2022 at 1:26 PM