Skip to content

WebFlux AbstractView does not update BindingResult for resolved async attributes #22933

@dsyer

Description

@dsyer

In ViewResolutionResultHandler.handleResult() we have

	updateBindingContext(result.getBindingContext(), exchange);

	return viewsMono.flatMap(views -> render(views, model.asMap(), exchange));

so the binding context is updated before rendering starts. Later as part of rendering, AbstractView calls resolveAsyncAttributes to resolve Mono and Flux attributes in the model to concrete values, but the BindingResult for each of those attributes are not updated accordingly.

This means that any View that inspects the BindingResult to find out about field errors etc. will break, e.g.

Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'firstName' of bean class [reactor.core.publisher.MonoOnAssembly]: Bean property 'firstName' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:622)
    at org.springframework.beans.AbstractNestablePropertyAccessor.getPropertyValue(AbstractNestablePropertyAccessor.java:612)
    at org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:104)
    at org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:228)
    at org.springframework.web.reactive.result.view.BindStatus.<init>(BindStatus.java:127)
    at org.springframework.web.reactive.result.view.RequestContext.getBindStatus(RequestContext.java:442)
    at org.thymeleaf.spring5.context.webflux.SpringWebFluxThymeleafRequestContext.getBindStatus(SpringWebFluxThymeleafRequestContext.java:227)
    at org.thymeleaf.spring5.util.FieldUtils.getBindStatusFromParsedExpression(FieldUtils.java:306)
    at org.thymeleaf.spring5.util.FieldUtils.getBindStatus(FieldUtils.java:253)
...

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions