lymerin opened a new pull request, #7537:
URL: https://github.com/apache/shenyu/pull/7537

   Fixes #7458
   
   ### Problem
   
   MQTT retained payloads are decoded into Strings using the JVM default 
charset, stored as Strings, and re-encoded as UTF-8 during replay. Invalid 
UTF-8 bytes are replaced, corrupting binary payloads.
   
   ### Impact
   
   - Later subscribers receive corrupted retained binary messages, such as 
Protobuf or sensor data.
   - For example, `00 FF 80 41` becomes `00 EF BF BD EF BF BD 41`.
   - The issue affects retained-message storage and replay; live message 
forwarding is not changed.
   
   ### Changes
   
   - **Publish.java:** Copy the original readable payload bytes without String 
conversion or modifying the ByteBuf reader index.
   - **TopicRepository.java:** Store retained payloads as `byte[]` instead of 
`String`.
   - **Subscribe.java:** Replay the stored bytes directly without UTF-8 
re-encoding.
   - **PublishTest.java:** Add regression coverage for:
     - UTF-8 text and arbitrary binary payloads, verifying byte-for-byte replay.
     - Sliced and direct ByteBuf payloads with nonzero reader indices.
     - Payload ownership and independence from subsequent buffer modification 
or release.
     - Retained message replacement and zero-byte retained deletion.
     - Existing non-retained publish behavior.
   
   ### Validation
   
   - Local Maven `clean install` completed successfully.
   - Regression tests exercise the actual publish/subscribe path using Netty 
EmbeddedChannel and verify retained payload integrity.
   
   ### Checklist
   
   Make sure that:
   
   - [x] You have read the [[contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide)](https://shenyu.apache.org/community/contributor-guide).
   - [x] You submit test cases (unit or integration tests) that back your 
changes.
   - [x] Your local test passed `./mvnw clean install 
-Dmaven.javadoc.skip=true`.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to