-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Spring Framework 5.2 Release Notes
Note that Spring Framework 4.3.x and therefore Spring Framework 4 overall reached its EOL cut-off on December 31st, 2020. The Spring Framework 5.x generation will reach its end of OSS support on August 31st, 2024. Please upgrade to a supported generation or consider a commercial subscription!
See also the Spring-Framework-5-FAQ.
Spring Framework 5.2 now requires Jackson 2.9.7+ and explicitly supports the recently released Jackson 2.10 GA. See gh-23522.
In Reactor Core 3.3, the Kotlin extensions are deprecated and replaced by a dedicated reactor-kotlin-extensions project/repo. You may have to add io.projectreactor.kotlin:reactor-kotlin-extensions dependency to your project and update related packages to use the non-deprecated variants.
Spring's annotation retrieval algorithms have been completely revised for efficiency and consistency, as well as for potential optimizations through annotation presence hints (e.g. from a compile-time index). This may have side effects -- for example, finding annotations in places where they haven't been found before or not finding annotations anymore where they have previously been found accidentally. While we don't expect common Spring applications to be affected, annotation declaration accidents in application code may get uncovered when you upgrade to 5.2. For example, all annotations must now be annotated with @Retention(RetentionPolicy.RUNTIME) in order for Spring to find them. See gh-23901, gh-22886, and gh-22766.
@RequestMapping() and meta-annotated variants @GetMapping(), PostMapping(), etc., without explicitly declared path patterns are now equivalent to RequestMapping("") and match only to URLs with no path. In the absence of declared patterns previously the path was not checked thereby matching to any path. If you would like to match to all paths, please use "/**" as the pattern. gh-22543
@Bean methods in Web**ConfigurationSupport now declare bean dependencies as method arguments rather than use method calls to make it possible to avoid creating proxies for bean methods via @Configuration(proxyBeanMethods=false) which Spring Boot 2.2 now does. This should not affect existing applications but if sub-classing Web**ConfigurationSupport (or DelegatingWeb**Configuration) and using proxyBeanMethods=false be sure to also to declare dependent beans as method arguments rather than using method calls. See gh-22596
Since the related Chrome bug is now fixed since September 2017, Spring Framework 5.2 deprecates MediaType.APPLICATION_JSON_UTF8 and MediaType.APPLICATION_PROBLEM_JSON_UTF8 in favor of MediaType.APPLICATION_JSON and MediaType.APPLICATION_PROBLEM_JSON and uses them by default. As a consequence, integration tests relying on the default JSON content type may have to be updated. See gh-22788 for more details.
CORS handling has been significantly updated in Spring Framework 5.2:
- CORS processing is now only used for CORS-enabled endpoints
- CORS processing for skipped for same-origin requests with an
Originheader - Vary headers are added for non-CORS requests on CORS endpoints
These changes introduce an AbstractHandlerMapping#hasCorsConfigurationSource method (in both Spring MVC and WebFlux) in order to be able to check CORS endpoints efficiently. When upgrading to Spring Framework 5.2, handler mapping extending AbstractHandlerMapping and supporting CORS should override hasCorsConfigurationSource with their custom logic.
Config options for suffix pattern matching in RequestMappingHandlerMapping have been deprecated, and likewise config options to resolve acceptable media types from the extension of a request path in ContentNegotiationManagerFactoryBean have also been deprecated. This is aligned with defaults in Spring Boot auto configuration and Spring WebFlux does not offer such options. See gh-24179 and related issues for details and further plans towards 5.3.
Custom implementations of Encoder must implement the new encodeValue which is invoked from ServerSentEventHttpMessageWriter or otherwise that would fail at runtime.
The mock JNDI support in the spring-test module has been deprecated. If you have been using classes such as the SimpleNamingContext and SimpleNamingContextBuilder, you are encouraged to migrate to a complete JNDI solution from a third party such as Simple-JNDI. [gh-22779]
- Upgrade to ASM 7.1 and Kotlin 1.3.
- Annotation retrieval optimizations:
- New
MergedAnnotationsAPI for efficient sophisticated annotation retrieval checks. - Candidate class mechanism for indications about the potential presence of certain annotation types.
- New
- Commons Logging conveniences:
-
LogMessagefor first-class message supplier and argument-based formatting support. -
LogAccessoras a convenientLogalternative with out-of-the-box support for message suppliers.
-
-
@Configurationmodel improvements:- Optimized annotation introspection on configuration candidate classes.
-
proxyBeanMethodsattribute for@Configuration-demarcated classes in lite mode, i.e. without CGLIB subclasses. - Support for annotation detection on factory methods with common
ListableBeanFactoryretrieval methods:getBeanNamesForAnnotation,getBeansWithAnnotation,findAnnotationOnBean.
- Bean registration with Kotlin DSL using callable reference with autowired parameters.
- Support for reactive transaction management on Reactive Streams Publishers
-
ReactiveTransactionManagerSPI as alternative toPlatformTransactionManager. - Programmatic
TransactionalOperatoras well as@Transactionalintegration.
-
- Support for transaction control via Vavr
Tryreturn type on@Transactionalmethods.
- Complete set of
java.timebased setters onHttpHeaders,CacheControl,CorsConfiguration. -
@RequestMappinghas enhanced produces condition support such that if a media type is declared with a specific parameter, and the requested media types (e.g. from "Accept" header) also has that parameter, the parameter values must match. This can be used for example to differentiate methods producing ATOM feeds"application/atom+xml;type=feed"vs ATOM entries"application/atom+xml;type=entry". - CORS revision that adds
Varyheader for non CORS requests on CORS enabled endpoints and avoid considering same-origin requests with anOriginheader as a CORS request. - Upgrade to Jackson 2.10
- New "WebMvc.fn" programming model, analogous to the existing "WebFlux.fn":
- A functional alternative to annotated controllers built on the Servlet API.
- WebMvc.fn Kotlin DSL.
- Request mapping performance optimizations through caching of the lookup path per
HandlerMapping, and pre-computing frequently used data inRequestConditionimplementations. - Improved, compact logging of request mappings on startup.
- Refinements to
WebClientAPI to make theretrieve()method useful for most common cases, specifically adding the ability to retrieve status and headers and addition to the body. Theexchange()method is only for genuinely advanced cases, and when using it, applications can now rely onClientResponse#createExceptionto simplify selective handling of exceptions. - Configurable limits on input stream processing in all
DecoderandHttpMessageReaderimplementations, withmaxInMemorySizeset to 256K by default. See WebFlux reference for details. - Support for Kotlin Coroutines.
- Server and client now use Reactor checkpoints to insert information about the request URL being processed,sce or the handler used, that is then inserted into exceptions and logged below the exception stacktrace.
- Request mapping performance optimizations through pre-computing frequently used data in
RequestConditionimplementations. - Header management performance optimizations by wrapping rather than copying server headers, and caching parsed representations of media types. Available from 5.1.1, see issue #21783 and commits under "Issue Links".
- Improved, compact logging of request mappings on startup.
- Add
ServerWebExchangeContextFilterto expose the Reactor Context as an exchange attribute. - Add FreeMarker macros support.
-
MultipartBodyBuilderimprovements to allowPublisherandPartas input along with option to specify the filename to use for a part.
-
RSocket support:
- Response handling via annotated
@MessageMappingmethods. - Performing requests via
RSocketRequesterwith encoding and decoding to and from higher-level objects. - Support for Kotlin Coroutines.
- Response handling via annotated
- JUnit Jupiter 5.5.2 support.
- New
@TestConstructorannotation andspring.test.constructor.autowire.modeJVM system property for configuring the autowiring mode for test constructors when using JUnit Jupiter. - Support for built-in test execution events.
-
@TestPropertySourcecan now be used as a repeatable annotation. - Class-level and method-level
@Sqldeclarations can now be merged. -
@SqlConfignow supports multiple comment prefixes for scripts configured via@Sql. - Enhancements to the
TestContextAPI:- New
hasApplicationContext()method to determine if the application context for the current test is known to be available. - New
publishEvent()method for simplifiedApplicationEventpublication.
- New
- Improved support for setting cookie headers in
MockHttpServletResponse. -
MockMvcResultMatchers.jsonPath()now supports a target type. - MockMvc Kotlin DSL
- New
headerDoesNotExist()method inMockRestServiceServerto verify that a header does not exist. -
ReflectionTestUtilssupports the invocation ofstaticmethods via newinvokeMethod()variants.
- Code samples in the reference documentation are now provided in Kotlin in addition to Java
To see all changes, please check the release notes for individual milestones: