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

Validation for nested properties is buggy [SPR-7019] #11681

Closed
spring-projects-issues opened this issue Mar 21, 2010 · 1 comment
Closed

Validation for nested properties is buggy [SPR-7019] #11681

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

Comments

@spring-projects-issues
Copy link
Collaborator

Oliver Becker opened SPR-7019 and commented

When validating nested properties, Spring computes a wrong property path (a.k.a. fieldname).

See org.springframework.validation.AbstractBindingResult

public String[] resolveMessageCodes(String errorCode, String field) {
	String fixedField = fixedField(field);
	Class fieldType = getFieldType(fixedField);
	return getMessageCodesResolver().resolveMessageCodes(errorCode, getObjectName(), fixedField, fieldType);
}

The problem is that getFieldType will be called already with a fixedField parameter. However, getFieldType again invokes fixedField(String) with the passed string. So in the end the fixedField method will be called twice, which in turn prepends a nestedPath twice.

The quickfix is most probably to change the second line of resolveMessageCodes into
Class fieldType = getFieldType(field);


Affects: 3.0.1

Referenced from: commits a2c3274

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Good catch - fixed for 3.0.2! Will be available in tonight's 3.0.2 snapshot already.

Juergen

@spring-projects-issues spring-projects-issues added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0.2 milestone Jan 11, 2019
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: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants