Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Framework fails to find bean property if the setter contains more than one capital after the word set (e.g., setTEmailAddr) [SPR-7388] #12046

Closed
spring-projects-issues opened this issue Jul 21, 2010 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jul 21, 2010

Paul DesRivieres opened SPR-7388 and commented

If you use the Spring Framework to automatically bind parameters in your HttpServletRequest to your request context object, please be aware of this Spring bug confirmed in version 2.0 and 2.5.6.

If you have setters setF, setTg, and setDevId in your request context class, Spring will detect properties 'f', 'tg', and 'devId' bind those parameters to your setters.
However, if you have setters setTBrandi, setTBid, setTEmailAddr, and setTLoginNumber, Spring will detect properties 'TBrandi', 'TBid', 'TEmailAddr', and 'TLoginNumber' rather than 'tBrandi', 'tBid', 'tEmailAddr', and 'tLoginNumber'.
For these parameters you would need to manually call the setters or they won't be defined in your request context.

It seems the bug occurs when your setter has more than one capital letter in a row immediately after the set as setTg and setDevId work but not setTBid and setTEmailAddr.

Renaming the setter from setTEmailAddr to settEmailAddr does resolve the issue.
2010-07-20 15:11:05,498 [http-9080-1] DEBUG org.springframework.beans.CachedIntrospectionResults - Found bean property 'tEmailAddr' of type [java.lang.String]
...
2010-07-20 15:11:05,502 [http-9080-1] DEBUG org.springframework.beans.BeanWrapperImpl - Invoked write method [public void com.aol.mail.services.mps.common.ServiceRequest.settEmailAddr(java.lang.String)] with value of type [java.lang.String]

Paul D.


Affects: 2.5.6

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I'm afraid this is not a bug but actually correct behavior according to the JavaBeans specification: Check the javadoc of java.beans.Introspector's "decapitalize" method to find a summary of the (not well known) rules there.

Spring 2.x was still strictly JavaBeans compliant. As of Spring 3.0, we adopted a more lenient strategy that goes beyond the JavaBeans spec: We accept both variants of such casing now (i.e. "TBid" as well as "tBid").

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants