File tree Expand file tree Collapse file tree
activemq-stomp/src/main/java/org/apache/activemq/transport/stomp Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717package org .apache .activemq .transport .stomp ;
1818
1919import java .io .ByteArrayInputStream ;
20+ import java .nio .ByteBuffer ;
2021import java .util .Arrays ;
2122import java .util .Collections ;
2223import java .util .HashSet ;
@@ -47,11 +48,11 @@ public StompCodec(TcpTransport transport) {
4748 this .wireFormat = (StompWireFormat ) Objects .requireNonNull (transport .getWireFormat ());
4849 }
4950
50- public void parse (ByteArrayInputStream input , int readSize ) throws Exception {
51+ public void parse (ByteBuffer input , int readSize ) throws Exception {
5152 int i = 0 ;
5253 int b ;
5354 while (i ++ < readSize ) {
54- b = input .read ();
55+ b = input .get ();
5556 // skip repeating nulls
5657 if (!processedHeaders && previousByte == 0 && b == 0 ) {
5758 continue ;
Original file line number Diff line number Diff line change @@ -74,10 +74,7 @@ protected void initializeStreams() throws IOException {
7474
7575 @ Override
7676 protected void processCommand (ByteBuffer plain ) throws Exception {
77- byte [] fill = new byte [plain .remaining ()];
78- plain .get (fill );
79- ByteArrayInputStream input = new ByteArrayInputStream (fill );
80- codec .parse (input , fill .length );
77+ codec .parse (plain , plain .remaining ());
8178 }
8279
8380 @ Override
Original file line number Diff line number Diff line change @@ -129,12 +129,8 @@ private void serviceRead() {
129129
130130 protected void processBuffer (ByteBuffer buffer , int readSize ) throws Exception {
131131 receiveCounter .addAndGet (readSize );
132-
133132 buffer .flip ();
134-
135- ByteArrayInputStream input = new ByteArrayInputStream (buffer .array ());
136- codec .parse (input , readSize );
137-
133+ codec .parse (buffer , readSize );
138134 // clear the buffer
139135 buffer .clear ();
140136 }
You can’t perform that action at this time.
0 commit comments