cshannon commented on PR #1284:
URL: https://github.com/apache/activemq/pull/1284#issuecomment-2315277363

   I took a look a bit more today and I think I identified the source of the 
bugs:
   
   Bug with `Stomp -> AMQ`: 
https://github.com/apache/activemq/blob/e45ee4aae5b49986750d5a2feb171f36cf432fca/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java#L54-L65
   
   Bug with `AMQ -> Stomp`: 
https://github.com/apache/activemq/blob/e45ee4aae5b49986750d5a2feb171f36cf432fca/activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java#L107-L120
   
   In my proof of concept, it changes `getBody()` in stomp frame as I just 
tried something quickly but that is not the right spot to change it. By the 
time we set data on a `StompFrame`, we should make sure that it is proper UTF-8 
encoding, so that original getBody() method is fine.
   
   The actual issue is just making sure that we are always doing the following 
when converting:
   
   ```
   Stomp Frame -> decode UTF-8 to String -> encode with modified UTF-8 -> set 
on ActiveMQ message
   ActiveMQ message -> decode modified UTF-8 to String -> encode with standard 
UTF-8 -> set on Stomp frame
   ```
   
   In the example above, it's wrong because it's trying to take a short cut 
(probably for performance) by using the already existing encoding when creating 
the Stomp Frame or AMQ message (Depending on direction) and setting the content 
body. To fix it, we need to make sure we always go back to a string first and 
re-encode.
   
   We could still potentially try and change the encoding for future OpenWire 
versions, but I think it's tricky because the OpenWire objects themselves like 
ActiveMQTextMessage, handle the encoding/decoding of the data by 
[calling](https://github.com/apache/activemq/blob/e45ee4aae5b49986750d5a2feb171f36cf432fca/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java#L91)
 off to the utility. So I'm not sure how that would work because the objects 
are not tied to a specific open wire version, that's independent of the 
encoding so it would not know which version of the encoder to use.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org
For additional commands, e-mail: gitbox-h...@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact


Reply via email to