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

Reactive RedirectView throws exception if no RequestDataValueProcessor is present [SPR-15136] #19702

spring-projects-issues opened this issue Jan 12, 2017 · 1 comment
in: web type: bug


Copy link

@spring-projects-issues spring-projects-issues commented Jan 12, 2017

Daniel Fernández opened SPR-15136 and commented

The current reactive implementation of RedirectView makes the assumption that the application context will always contain an implementation of RequestDataValueProcessor, which does not seem to be true. Actually it is not RedirectView to be blamed but its parent AbstractView. But using RedirectView seems to be the most common way of being hit by this issue.

The RedirectView#createUrl(...) method does this just after building the URL and before returning it:

RequestDataValueProcessor processor = getRequestDataValueProcessor();
return (processor != null ? processor.processUrl(exchange, result) : result);

See it here on Github

Given RedirectView extends from AbstractView, this calls the AbsctractView#getRequestDataValueProcessor() method, which looks like this:

protected RequestDataValueProcessor getRequestDataValueProcessor() {
	if (getApplicationContext() != null) {
		return getApplicationContext().getBean(beanName, RequestDataValueProcessor.class);
	return null;

See it here on GitHub

Note that the code above unconditionally calls ApplicationContext#getBean(String,Class<?>), which will throw NoSuchBeanDefinitionException if there is no RequestDataValueProcessor registered.

In contrast, see how this is done at the MVC side, at the non-reactive RedirectView#updateTargetUrl(...) method, which calls the RequestDataValueProcessor only if it exists in the application context.

if (wac != null && wac.containsBean(RequestContextUtils.REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME)) {
	RequestDataValueProcessor processor = wac.getBean(
			RequestContextUtils.REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME, RequestDataValueProcessor.class);
	return processor.processUrl(request, targetUrl);

See it here on GitHub.

Affects: 5.0 M4

Referenced from: commits 8b7f3a6

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 13, 2017

Daniel Fernández commented

I've just submitted a Pull Request fixing this here: #1296

@spring-projects-issues spring-projects-issues added type: bug in: web labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 5.0 M5 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: web type: bug
None yet

No branches or pull requests

2 participants