简体   繁体   中英

What does “early consumption” mean? Do you mean memory consumption at startup?

Spring Boot 2.2 Release Notes · spring-projects/spring-boot Wiki

The filter that handles the _method request parameter is now disabled by default as it causes early consumption of a request body if the body may contain parameters.

What exactly does that mean "early consumption"?

What I have currently searched:

Spring Boot 2.2 Reaches First Milestone Release with Performance and Memory Improvements

Excerpt:

Startup performance is also improved by disabling other JPA scanners (eg Hibernate)

This article discusses memory improvements at startup performance.

So I guess from this, does "early consumption" mean "Memory consumption at startup"?

Formal definition

Formally speaking "early consumption" means that the body is consumed early;) This means that the body of a request is consumed at a point of time when it is not really necessary and it is not yet clear if it will be needed at all.

DispatcherServlet and HiddenHttpMethodFilter

An incoming request is accepted by the DispatcherServlet. The DispatcherServlet call all registered filters on the request and then tries to find the correct controller for it.

The HiddenHttpMethodFilter converts a POST request that contains a _method field to the corresponding request type (eg _method=PUT would transform this request to a PUT request). For that it obviously has to read the body. This reading is the early consumption that is referenced in the documentation. Afterwards it has to be consumed again to pass it to the controller handling the request. Thus you have an overhead that can be reduced by disabling this filter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM