Skip to content

Commit

Permalink
Fix bridge method selection to avoid incorrect resolution of boolean …
Browse files Browse the repository at this point in the history
…properties
  • Loading branch information
rabelenda-abstracta committed Feb 5, 2024
1 parent f4d78a4 commit 1ef1316
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ private void callPropertyMethod(String propName, Node propNode, Object ret) {

private Method findPropertyMethod(String propName, Node propNode, Object testElement) {
List<Method> candidates = Stream.of(testElement.getClass().getMethods())
.filter(m -> propName.equals(m.getName()))
/* avoid zero parameters methods since otherwise we might select a method without parameters
to set a false boolean property (which is usually incorrect, since such methods are used
to set the property to true).*/
.filter(m -> propName.equals(m.getName()) && m.getParameters().length > 0)
// sorted to get the most specific ones in the class hierarchy first
.sorted((m1, m2) -> {
Class<?> m1Class = m1.getReturnType();
Expand Down

0 comments on commit 1ef1316

Please sign in to comment.