anmol-saxena-14 opened a new pull request, #2782:
URL: https://github.com/apache/activemq/pull/2782

     Fixes #2781
   
     ## Summary
   
     `ActiveMQMessage.setObjectProperty(name, null)` stored a built-in property 
(for example `JMSXGroupID`, `JMSXGroupSeq`,
     `JMSCorrelationID`, `JMSType`) in the custom properties map when the value 
was null. The built-in field itself was not changed, but   
     the message carried a junk entry:
   
     - `getPropertyNames()` listed the property, for example `JMSXGroupID` on a 
message with no group.
     - `propertyExists("JMSXGroupID")` returned `true` on a message with no 
group.
     - `getProperties()` contained the name.
   
     This can happen through client code, the JMX `sendTextMessage(headers, 
body)` operation, and AMQP application properties (with the default `jms` 
transformer). Message delivery is not affected.
   
     ## Changes
   
     `ActiveMQMessage.setObjectProperty()`: split the combined check so that 
built-in names never reach the custom-property path.
   
     ```java
     // Before
     if (setter != null && value != null) {
         setter.set(this, value);
     } else {
         this.setProperty(name, value);
     }
   
     // After
     if (setter != null) {
         if (value != null) {
             setter.set(this, value);
         }
     } else {
         this.setProperty(name, value);
     }
     ```
   
     - A built-in name with a value is set as before.
     - A built-in name with a null value is ignored. The current value of the 
built-in field is unchanged, same as today.
     - Custom properties are unchanged. A custom property set to null is still 
stored.
   
     ## Testing
   
     Added to `ActiveMQMessageTest`:
   
     - `testSetNullBuiltInPropertyIsNotStoredAsCustomProperty`: sets 
`JMSXGroupID`, `JMSXGroupSeq`, `JMSCorrelationID` and `JMSType` to null and 
checks that none is stored in `getProperties()` or listed by 
`getPropertyNames()`. Also checks that
     `propertyExists("JMSXGroupID")` is `false`. Fails without the fix.
     - `testSetNullBuiltInPropertyKeepsExistingValue`: sets `JMSXGroupID` to 
`"A"`, then to null, and checks the value is still `"A"`.     
     Documents that the existing value is not cleared.


-- 
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


Reply via email to