Introduce toString(Charset) in FastByteArrayOutputStream
This commit introduces a toString() overload in FastByteArrayOutputStream that accepts a Charset in order to mirror the method that was introduced in ByteArrayOutputStream in JDK 10, including a special case for when a single buffer is in use internally to avoid the need to resize. This commit also updates getContentAsString() in ContentCachingRequestWrapper to use this new toString(Charset) method. Closes gh-31737
This commit is contained in:
committed by
Sam Brannen
parent
0bec8125a4
commit
7cdacf3083
@@ -205,7 +205,7 @@ public class ContentCachingRequestWrapper extends HttpServletRequestWrapper {
|
||||
* @see #getContentAsByteArray()
|
||||
*/
|
||||
public String getContentAsString() {
|
||||
return new String(this.cachedContent.toByteArrayUnsafe(), Charset.forName(getCharacterEncoding()));
|
||||
return this.cachedContent.toString(Charset.forName(getCharacterEncoding()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user