-
Couldn't load subscription status.
- Fork 38.8k
Open
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
When calculating the ContentLength and writing data to the OutputStream in StringHttpMessageConverter, calling str.getBytes(charset) repeatedly will result in unnecessary array objects occupying memory
Lines 103 to 106 in 09917fa
| protected Long getContentLength(String str, @Nullable MediaType contentType) { | |
| Charset charset = getContentTypeCharset(contentType); | |
| return (long) str.getBytes(charset).length; | |
| } |
Lines 122 to 129 in 09917fa
| protected void writeInternal(String str, HttpOutputMessage outputMessage) throws IOException { | |
| HttpHeaders headers = outputMessage.getHeaders(); | |
| if (this.writeAcceptCharset && headers.get(HttpHeaders.ACCEPT_CHARSET) == null) { | |
| headers.setAcceptCharset(getAcceptedCharsets()); | |
| } | |
| Charset charset = getContentTypeCharset(headers.getContentType()); | |
| StreamUtils.copy(str, charset, outputMessage.getBody()); | |
| } |
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement