Regression: SpringHandlerInstantiator breaks stand-alone support in the MVC Test framework [SPR-13375] #17957
Labels
in: test
Issues in the test module
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Sam Brannen opened SPR-13375 and commented
The
SpringHandlerInstantiator
introduced in #15394 always attempts to create new beans using itsAutowireCapableBeanFactory
. In the case of aStubWebApplicationContext
, however, this results in anUnsupportedOperationException
being thrown.This behavior breaks support for JSON serialization in conjunction with the default configuration of the
MockMvcBuilders.standaloneSetup()
support in the Spring MVC Test framework since it internally uses aStubWebApplicationContext
.See the linked discussion on Stack Overflow for details.
Analysis
The following code in
WebMvcConfigurationSupport.addDefaultHttpMessageConverters()
is what causes this behavior:The fact that it supplies the
ApplicationContext
results in aSpringHandlerInstantiator
being created inJackson2ObjectMapperBuilder.configure()
, even though aSpringHandlerInstantiator
makes no sense for the stand-alone test setup in MVC Test.Affects: 4.1.3
Reference URL: http://stackoverflow.com/questions/32101611/spring-mockmvc-unsupportedoperationexception-after-upgrading-to-new-spring-versi/32140898
Referenced from: commits spring-attic/spring-framework-issues@028ace9
Backported to: 4.1.8
0 votes, 6 watchers
The text was updated successfully, but these errors were encountered: