Improve usage of ByteArrayOutputStream/ByteArrayInputStream
Closes gh-24805
This commit is contained in:
committed by
Sam Brannen
parent
821984a5cf
commit
e63d1cf12d
@@ -33,6 +33,7 @@ import org.springframework.messaging.support.MessageHeaderInitializer;
|
||||
import org.springframework.messaging.support.NativeMessageHeaderAccessor;
|
||||
import org.springframework.util.InvalidMimeTypeException;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
* Decodes one or more STOMP frames contained in a {@link ByteBuffer}.
|
||||
@@ -216,7 +217,7 @@ public class StompDecoder {
|
||||
while (byteBuffer.remaining() > 0 && !tryConsumeEndOfLine(byteBuffer)) {
|
||||
command.write(byteBuffer.get());
|
||||
}
|
||||
return new String(command.toByteArray(), StandardCharsets.UTF_8);
|
||||
return StreamUtils.baosToString(command, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private void readHeaders(ByteBuffer byteBuffer, StompHeaderAccessor headerAccessor) {
|
||||
@@ -231,7 +232,7 @@ public class StompDecoder {
|
||||
headerStream.write(byteBuffer.get());
|
||||
}
|
||||
if (headerStream.size() > 0 && headerComplete) {
|
||||
String header = new String(headerStream.toByteArray(), StandardCharsets.UTF_8);
|
||||
String header = StreamUtils.baosToString(headerStream, StandardCharsets.UTF_8);
|
||||
int colonIndex = header.indexOf(':');
|
||||
if (colonIndex <= 0) {
|
||||
if (byteBuffer.remaining() > 0) {
|
||||
|
||||
Reference in New Issue
Block a user