Use DataBuffer::toString instead of CharBuffer

This commit ensures that converting DataBuffers to a String does not
use an expensive ByteBuffer allocation.

Closes gh-29889
This commit is contained in:
xavier-b
2023-01-27 00:53:55 +01:00
committed by Arjen Poutsma
parent f9884e08af
commit b7d53ac9a4
2 changed files with 2 additions and 6 deletions

View File

@@ -17,7 +17,6 @@
package org.springframework.http.codec;
import java.net.URLDecoder;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
@@ -129,8 +128,7 @@ public class FormHttpMessageReader extends LoggingCodecSupport
return DataBufferUtils.join(message.getBody(), this.maxInMemorySize)
.map(buffer -> {
CharBuffer charBuffer = charset.decode(buffer.toByteBuffer());
String body = charBuffer.toString();
String body = buffer.toString(charset);
DataBufferUtils.release(buffer);
MultiValueMap<String, String> formData = parseFormData(charset, body);
logFormData(formData, hints);