Simplify conversion of ByteArrayOutputStream to String

Closes gh-24785
This commit is contained in:
Сергей Цыпанов
2020-03-26 10:54:40 +02:00
committed by Sam Brannen
parent 62c545d0ed
commit 65aa2d03f0
4 changed files with 6 additions and 7 deletions

View File

@@ -252,15 +252,14 @@ public class RestTemplateXhrTransport extends AbstractXhrTransport {
return null;
}
private void handleFrame(ByteArrayOutputStream os) {
byte[] bytes = os.toByteArray();
private void handleFrame(ByteArrayOutputStream os) throws IOException {
String content = os.toString(SockJsFrame.CHARSET.toString());
os.reset();
String content = new String(bytes, SockJsFrame.CHARSET);
if (logger.isTraceEnabled()) {
logger.trace("XHR receive content: " + content);
}
if (!PRELUDE.equals(content)) {
this.sockJsSession.handleFrame(new String(bytes, SockJsFrame.CHARSET));
this.sockJsSession.handleFrame(content);
}
}
}