anmol-saxena-14 opened a new issue, #2781:
URL: https://github.com/apache/activemq/issues/2781

    When `ActiveMQMessage.setObjectProperty(name, null)` is called with the 
name of a built-in property (for example `JMSXGroupID`,       
    `JMSXGroupSeq`, `JMSCorrelationID`, `JMSType`, or any other name in 
`JMS_PROPERTY_SETERS`), the name is stored in the custom properties map  with a 
null value.
   
     The built-in field itself is not changed, so reading the value still 
works. But the message now carries a junk entry, and:
   
     - `getPropertyNames()` lists the property, for example `JMSXGroupID` on a 
message with no group.
     - `propertyExists("JMSXGroupID")` returns `true` on a message with no 
group.
     - `getProperties()` contains the name.
   
     Message delivery is not affected.
   
     ## How it can happen
   
     - **Client code** that sets a built-in property to null, for example 
`message.setObjectProperty("JMSXGroupSeq", null)` or
     `message.setStringProperty("JMSXGroupID", null)`. This typically happens 
when an application copies a value that happens to be null.  
     - **The JMX `sendTextMessage(headers, body)` operation** on 
`QueueViewMBean` / `TopicViewMBean`, when the `headers` map contains a    
     built-in name with a null value. This also applies to tools that call JMX 
over HTTP, such as Jolokia.
     - **AMQP clients** that send an application property with a built-in name 
and a null value. The AMQP inbound transformer passes it to 
     `setObjectProperty()`.
   
     It cannot happen through the web console Send page, because that page 
skips blank fields.
   
     ## Steps to reproduce
   
     ```java
     ActiveMQMessage msg = new ActiveMQMessage();
     msg.setObjectProperty("JMSXGroupID", null);
   
     msg.getProperties().containsKey("JMSXGroupID");               // true, 
expected false
     Collections.list(msg.getPropertyNames()).contains("JMSXGroupID"); // true, 
expected false
     msg.propertyExists("JMSXGroupID");                             // true, 
expected false
     msg.getStringProperty("JMSXGroupID");                          // null 
(correct)
    ```
   
     This can also be reached through the JMX 
QueueViewMBean.sendTextMessage(headers, body) operation with a null header 
value, and through
     AMQP application properties. The web console Send page is not affected, 
because it skips blank fields.
   
     ## Cause
   
     In ActiveMQMessage.setObjectProperty():
   
   ```java
     if (setter != null && value != null) {
         setter.set(this, value);
     } else {
         this.setProperty(name, value);   // built-in name + null value ends up 
here                                                       
     }
     ```
     A built-in name with a null value fails the combined check and falls 
through to setProperty(), which stores it as a custom property. 


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