Use a more efficient conversion from ByteArrayOutputStream to String.

Resolves #1324.
This commit is contained in:
hduelme
2023-01-25 21:46:32 +01:00
committed by Greg L. Turnquist
parent 8346d5b28d
commit 1b6fb7de44
3 changed files with 3 additions and 3 deletions

View File

@@ -50,7 +50,7 @@ class TextMessageOutputStream extends FilterOutputStream {
super.flush();
try {
ByteArrayOutputStream baos = (ByteArrayOutputStream) out;
String text = new String(baos.toByteArray(), encoding);
String text = baos.toString(encoding);
message.setText(text);
} catch (JMSException ex) {
throw new JmsTransportException(ex);

View File

@@ -48,7 +48,7 @@ class MessageOutputStream extends FilterOutputStream {
public void flush() throws IOException {
super.flush();
ByteArrayOutputStream bos = (ByteArrayOutputStream) out;
String text = new String(bos.toByteArray(), encoding);
String text = bos.toString(encoding);
message.setBody(text);
}
}

View File

@@ -171,7 +171,7 @@ public class JmsMessageSenderIntegrationTest {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
messageFactory.createMessage().writeTo(bos);
final String text = new String(bos.toByteArray(), StandardCharsets.UTF_8);
final String text = bos.toString(StandardCharsets.UTF_8);
jmsTemplate.send(request.getJMSReplyTo(), session -> {