Skip to content

Skip static methods in FluentPropertyBeanIntrospector and mapped lookup - #437

Merged
garydgregory merged 2 commits into
apache:masterfrom
rootvector2:static-accessor-skip
Aug 23, 2026
Merged

Skip static methods in FluentPropertyBeanIntrospector and mapped lookup#437
garydgregory merged 2 commits into
apache:masterfrom
rootvector2:static-accessor-skip

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

FluentPropertyBeanIntrospector.introspect turns every public method whose name starts with the write prefix into a write method without checking Modifier.isStatic, and MappedPropertyDescriptor.getMethod accepts the static methods getMatchingAccessibleMethod returns (unlike its sibling internalGetMethod, which already skips them), so once the fluent introspector is registered BeanUtils.setProperty(form, "locale.default", "fr-FR") on any bean with a Locale getter invokes the static Locale.setDefault and any public static setX(T) or getX(String)/setX(String, T) reachable through a nested property becomes writable from a populate map; found while auditing the introspectors against the JavaBeans rule java.beans.Introspector follows (static methods are never accessors), fixed by skipping static methods at both lookup sites, with regression tests in FluentPropertyBeanIntrospectorTest and MappedPropertyTest that fail without the runtime change.

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute?
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

@garydgregory garydgregory changed the title skip static methods in FluentPropertyBeanIntrospector and mapped lookup Skip static methods in FluentPropertyBeanIntrospector and mapped lookup Aug 23, 2026
@garydgregory
garydgregory merged commit 684d505 into apache:master Aug 23, 2026
11 checks passed
@garydgregory

Copy link
Copy Markdown
Member

@rootvector2 merged 🚀 Thank you.

garydgregory added a commit that referenced this pull request Aug 23, 2026
Add missing unit tests that could have been in PR #437.

The tests explicitly cover the mixed static/instance accessor cases that
were missing:

Mapped property with a static getter but instance setter: read method is
ignored, write method is used.

Mapped property with an instance getter but static setter: read method
is used, write method is ignored.

Fluent introspector with a static and an instance setter for the same
property name: the instance setter is chosen and the property remains
writable.
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.

2 participants