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

AbstractMessageSource does not properly interact with DelegatingMessageSource parent [SPR-16047] #20596

spring-projects-issues opened this issue Oct 5, 2017 · 2 comments
in: web type: regression


Copy link

@spring-projects-issues spring-projects-issues commented Oct 5, 2017

Hans Desmet opened SPR-16047 and commented

Given following Initializer:

package be.vdab.web;

import javax.servlet.Filter;
import org.springframework.web.filter.CharacterEncodingFilter;
import be.vdab.test.TestConfig;

public class Initializer extends AbstractAnnotationConfigDispatcherServletInitializer {
	protected String[] getServletMappings() {
		return new String[] { "/" };

	protected Class<?>[] getRootConfigClasses() {
		return new Class<?>[] { TestConfig.class };
		//return null;

	protected Class<?>[] getServletConfigClasses() {
		return new Class<?>[] { ControllersConfig.class };

	protected Filter[] getServletFilters() {
		return new Filter[] { new CharacterEncodingFilter("UTF-8") };

and following Controllers config:

package be.vdab.web;

import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

public class ControllersConfig extends WebMvcConfigurerAdapter {

	MessageSource messageSource() {
		ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
		return source;

and following Java config

package be.vdab.test;

import org.springframework.context.annotation.Configuration;

public class TestConfig {


and following controller:

package be.vdab.web;

import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.DataBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

class IndexController {

	private static final String VIEW = "/WEB-INF/JSP/index.jsp";

	ModelAndView findByPostcodeReeks() {
		CommandObject reeks = new CommandObject();
		return new ModelAndView(VIEW).addObject(reeks);

	@GetMapping(params = { "value" })
	ModelAndView findByPostcodeReeks(CommandObject reeks, BindingResult bindingResult) {
		ModelAndView modelAndView = new ModelAndView(VIEW);
		return modelAndView;

	void initBinderPostcodeReeks(DataBinder dataBinder) {

and following Command object class

package be.vdab.web;

public class CommandObject {
	private String value;
	public String getValue() {
		return value;

	public void setValue(String value) {
		this.value = value;

and following index.jsp

<%@page contentType='text/html' pageEncoding='UTF-8' session='false'%>
<%@taglib prefix='form' uri=''%> 
<!doctype html>
<html lang='nl'>
<form:form action='' modelAttribute='commandObject' method='get'>
<form:input path='value' autofocus='autofocus'/> 
<form:errors path='value'/> 
 <input type='submit' value='Zoeken'> 

when you run the webapp, leave the field empty and submit the form, you don't see the error message.
The problem is solved in three different ways:

  1. comment the MessageSource bean in ControllersConfig
  2. comment the line
    return new Class<?>[] { TestConfig.class }; in Initialzer and uncomment the line return null;
  3. Downgrade the webapp to Spring 4.3.11

A project to show the problem is at

Affects: 5.0 GA

Reference URL:

Issue Links:

  • #20099 Introduce null-safety of Spring Framework API
  • #20675 AbstractMessageSource does not support null as default message anymore

Referenced from: commits c3378fd

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 18, 2017

Juergen Hoeller commented

This comes down to our nullability revision (#20099) in AbstractMessageSource: getMessageFromParent does not properly interact with a DelegatingMessageSource parent anymore. We'll fix this for 5.0.1.

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 18, 2017

Juergen Hoeller commented

This will be available in the upcoming 5.0.1.BUILD-SNAPSHOT. Feel free to give it a try...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: web type: regression
None yet

No branches or pull requests

2 participants