mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
e452c2e89c
The getContentAsString method was originally added ind9b8826to avoid the extra copying inherent to calling ByteArrayOutputStream.toByteArray; however, inf83c609the class was updated to instead use FastByteArrayOutputStream, and in the process the extra copy was brought back when getContentAsString was changed to call toByteArray. Switch to calling toByteArrayUnsafe, a method provided by FastByteArrayOutputStream, which avoids the extra copy; since we immediately pass the byte array to the String constructor, and it isn't accessed anywhere else, the usage is safe. See gh-31731