Add a toString overload that accepts a Charset to mirror the method that has been on ByteArrayOutputStream since JDK10; additionally, add a special case for when a single buffer is in use internally to avoid the need to resize.
Comment From: kilink
Note this is somewhat of a follow up to #31731 and #30709; ContentCachingRequestWrapper
was updated to use FastByteArrayOutputStream
, which didn't have the toString(Charset)
overload that we were previously calling when it was just ByteArrayOutputStream
; adding a similar method to FastByteArrayOutputStream
allows for a nice optimization when there's only a single buffer, as we can pass the byte array + offset + len to the String constructor and avoid any copying.
Comment From: sbrannen
This has been merged into main
in 7cdacf308348d11e2edc07d9c2ebc761bf999e36 and revised in cd62dfe3a9bf3c8f2e45a6bdf1f232045dea549a.
Thanks