From 8b7f3a65ed50f176b739d9723d8deff1d4362171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ferna=CC=81ndez?= Date: Sat, 14 Jan 2017 00:00:41 +0100 Subject: [PATCH] Fix exception if no RequestDataValueProcessor is present This modification fixes the way AbstractView retrieves the RequestDataValueProcessor bean, correctly returning null if there is no bean of such type at the Application Context. This avoids an exception in RedirectView (which extends AbstractView) when trying to post-process the URL generated for redirection, when no RequestDataValueProcessor exists. Issue: SPR-15136 --- .../web/reactive/result/view/AbstractView.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java index 8605074db6..5729f68e05 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java @@ -191,11 +191,12 @@ public abstract class AbstractView implements View, ApplicationContextAware { *

The default implementation looks in the {@link #getApplicationContext() * Spring configuration} for a {@code RequestDataValueProcessor} bean with * the name {@link #REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME}. + * @return the RequestDataValueProcessor, or null if there is none at the application context. */ protected RequestDataValueProcessor getRequestDataValueProcessor() { - if (getApplicationContext() != null) { - String beanName = REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME; - return getApplicationContext().getBean(beanName, RequestDataValueProcessor.class); + ApplicationContext context = getApplicationContext(); + if (context != null && context.containsBean(REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME)) { + return context.getBean(REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME, RequestDataValueProcessor.class); } return null; }