Spring MVC: reading long request bodies is awfully slow

Issue #69 resolved
Sven Döring created an issue

For the validation against Swagger the whole request body has to be read. - This is slow because currently it is done by the java.util.Scanner.

Additionally the request body has to be cached as it has to be accessed by Spring MVC again. - This is slow because currently Springs ContentCachingRequestWrapper is used. That wrapper is suboptimal because it only implements the read() method for ServletInputStreams. This is done a million times if the request body has 1MB. - This is further suboptimal as it is backed by a ByteArrayOutputStream which grows its capacity on every single write() by 1 and then copies its current content to a newly created array. This is done a million times if the request body has 1MB.

Comments (3)

  1. Log in to comment