pradeep85841 commented on PR #1659: URL: https://github.com/apache/activemq/pull/1659#issuecomment-3892761848
I have refactored the fix to address the root cause at the command level rather than the transport level, as suggested. The Issue: Under high concurrency, ActiveMQTextMessage suffered from a race condition where the internal state "toggle" (moving between the text field and the ByteSequence content) was not atomic. This led to a "double null" state where one thread cleared the unmarshalled text before the other had finished reading the raw content. The Fix: Thread Safety: Added synchronized to getText(), setText(), and state-toggling methods in ActiveMQTextMessage. State Preservation: Updated clearUnMarshalledState() to ensure that the marshalled content is stored before the unmarshalled state is cleared. Performance: This approach preserves the efficiency of the VM Transport by avoiding a full transport-level marshal, while ensuring data integrity. Validation: Added ActiveMQTextMessageStressTest.java, which reproduces the null body issue and confirms the fix under high thread contention. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information, visit: https://activemq.apache.org/contact
