Skip to content

[Regression] 404 without ACCEPT request header results in a 406 in Spring Framework 5.1.6 #22853

@mixcloud-downloader

Description

@mixcloud-downloader

Affects: 5.1.6

Since the Upgrade from Spring-Boot-2.1.3.RELEASE to Spring-Boot-2.1.4.RELEASE, any error (e.g. a 404 or an 500) an expected 404 without an ACCEPT request header result in a 406 response and this message in the logs:

DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation]

This regression happens only when setting the default content type to TEXT_HTML:

@Configuration
class DefaultContentTypeConfiguration implements WebMvcConfigurer {

	@Override
	public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
		configurer.defaultContentType(TEXT_HTML);
	}
}

See spring-attic/spring-framework-issues#191 for an example.

On a site note: This is the second bug in a very short time (the other was #22851) which goes unnoticed with Spring's classic MockMVC testing approach. It makes me thing that using MockMVC is not a too good idea any more.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions