Skip to content

Commit fc1ff88

Browse files
committed
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
1 parent fc2e1dd commit fc1ff88

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.springframework.http.HttpOutputMessage;
3030
import org.springframework.http.MediaType;
3131
import org.springframework.util.Assert;
32-
import org.springframework.util.StreamUtils;
3332

3433
/**
3534
* Implementation of {@link HttpMessageConverter} that can read and write strings.
@@ -125,7 +124,7 @@ protected void writeInternal(String str, HttpOutputMessage outputMessage) throws
125124
headers.setAcceptCharset(getAcceptedCharsets());
126125
}
127126
Charset charset = getContentTypeCharset(headers.getContentType());
128-
StreamUtils.copy(str, charset, outputMessage.getBody());
127+
outputMessage.getBody().write(str.getBytes(charset));
129128
}
130129

131130

0 commit comments

Comments
 (0)