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
https://github.com/spring-projects/spring-framework/blob/09917fad7bca9b3997522f0a75d6319203f2127f/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java#L103-L106
https://github.com/spring-projects/spring-framework/blob/09917fad7bca9b3997522f0a75d6319203f2127f/spring-web/src/main/java/org/springframework/http/converter/StringHttpMessageConverter.java#L122-L129