Skip to content

Commit 8b7f3a6

Browse files
danielfernandezrstoyanchev
authored andcommitted
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
1 parent 0520147 commit 8b7f3a6

File tree

1 file changed

+4
-3
lines changed
  • spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view

1 file changed

+4
-3
lines changed

spring-web-reactive/src/main/java/org/springframework/web/reactive/result/view/AbstractView.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,12 @@ protected RequestContext createRequestContext(ServerWebExchange exchange, Map<St
191191
* <p>The default implementation looks in the {@link #getApplicationContext()
192192
* Spring configuration} for a {@code RequestDataValueProcessor} bean with
193193
* the name {@link #REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME}.
194+
* @return the RequestDataValueProcessor, or null if there is none at the application context.
194195
*/
195196
protected RequestDataValueProcessor getRequestDataValueProcessor() {
196-
if (getApplicationContext() != null) {
197-
String beanName = REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME;
198-
return getApplicationContext().getBean(beanName, RequestDataValueProcessor.class);
197+
ApplicationContext context = getApplicationContext();
198+
if (context != null && context.containsBean(REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME)) {
199+
return context.getBean(REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME, RequestDataValueProcessor.class);
199200
}
200201
return null;
201202
}

0 commit comments

Comments
 (0)