mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Avoid duplicate flushes in String Http converter
Prior to this commit, the `StringHttpMessageConverter` would perform a flush after writing the body, via `StreamUtils#copy`. This operation is not needed as a flush is already performed by the abstract class. Flush calls by HTTP message converters is being reconsidered altogether in gh-35427, but we should first remove this extra operation. Closes gh-36065
This commit is contained in:
+1
-2
@@ -29,7 +29,6 @@ import org.springframework.http.HttpInputMessage;
|
||||
import org.springframework.http.HttpOutputMessage;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
* Implementation of {@link HttpMessageConverter} that can read and write strings.
|
||||
@@ -125,7 +124,7 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter<Str
|
||||
headers.setAcceptCharset(getAcceptedCharsets());
|
||||
}
|
||||
Charset charset = getContentTypeCharset(headers.getContentType());
|
||||
StreamUtils.copy(str, charset, outputMessage.getBody());
|
||||
outputMessage.getBody().write(str.getBytes(charset));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user