This is an automated email from the ASF dual-hosted git repository.

cshannon pushed a commit to branch activemq-6.2.x
in repository https://gitbox.apache.org/repos/asf/activemq.git


The following commit(s) were added to refs/heads/activemq-6.2.x by this push:
     new 9d4835054b Remove extra buffer copy in StompNIOSSLTransport (#2107) 
(#2111)
9d4835054b is described below

commit 9d4835054bfbeb7d0d7afdd82559fdc6c7f91b32
Author: Christopher L. Shannon <[email protected]>
AuthorDate: Thu Jun 11 20:00:11 2026 -0400

    Remove extra buffer copy in StompNIOSSLTransport (#2107) (#2111)
    
    Optimizes the StompNIOSSLTransport by removing the unnecessary extra
    byte array allocation and buffer copy when processing frames
    
    (cherry picked from commit 403ac4f9191b6d31f6ce9247e43752b0e5a09324)
---
 .../main/java/org/apache/activemq/transport/stomp/StompCodec.java   | 5 +++--
 .../org/apache/activemq/transport/stomp/StompNIOSSLTransport.java   | 5 +----
 .../java/org/apache/activemq/transport/stomp/StompNIOTransport.java | 6 +-----
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git 
a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompCodec.java
 
b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompCodec.java
index cb89eb4521..08ae527651 100644
--- 
a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompCodec.java
+++ 
b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompCodec.java
@@ -17,6 +17,7 @@
 package org.apache.activemq.transport.stomp;
 
 import java.io.ByteArrayInputStream;
+import java.nio.ByteBuffer;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
@@ -47,11 +48,11 @@ public class StompCodec {
         this.wireFormat = (StompWireFormat) 
Objects.requireNonNull(transport.getWireFormat());
     }
 
-    public void parse(ByteArrayInputStream input, int readSize) throws 
Exception {
+    public void parse(ByteBuffer input, int readSize) throws Exception {
        int i = 0;
        int b;
        while(i++ < readSize) {
-           b = input.read();
+           b = input.get();
            // skip repeating nulls
            if (!processedHeaders && previousByte == 0 && b == 0) {
                continue;
diff --git 
a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java
 
b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java
index d233db9764..8c0e45e6f8 100644
--- 
a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java
+++ 
b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOSSLTransport.java
@@ -74,10 +74,7 @@ public class StompNIOSSLTransport extends NIOSSLTransport {
 
     @Override
     protected void processCommand(ByteBuffer plain) throws Exception {
-        byte[] fill = new byte[plain.remaining()];
-        plain.get(fill);
-        ByteArrayInputStream input = new ByteArrayInputStream(fill);
-        codec.parse(input, fill.length);
+        codec.parse(plain, plain.remaining());
     }
 
     @Override
diff --git 
a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java
 
b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java
index efc66af9ea..b6ebd8e787 100644
--- 
a/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java
+++ 
b/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java
@@ -129,12 +129,8 @@ public class StompNIOTransport extends TcpTransport {
 
     protected void processBuffer(ByteBuffer buffer, int readSize) throws 
Exception {
         receiveCounter.addAndGet(readSize);
-
         buffer.flip();
-
-        ByteArrayInputStream input = new ByteArrayInputStream(buffer.array());
-        codec.parse(input, readSize);
-
+        codec.parse(buffer, readSize);
         // clear the buffer
         buffer.clear();
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to