Uploaded image for project: 'AMQ Broker'
  1. AMQ Broker
  2. ENTMQBR-7890

[LTS] OpenWireMessageConverter Doesn't Check for Empty String on Property Names

XMLWordPrintable

    • Moderate

      OpenWireMessageConverter::setAMQMsgObjectProperties checks whether the key of a property in the message properties map is an instance of SimpleString, but does not check if the string value is an empty string:

         private static void setAMQMsgObjectProperties(final ActiveMQMessage amqMsg,
                                                       final ICoreMessage coreMessage,
                                                       final Set<SimpleString> props) throws IOException {
            for (SimpleString s : props) {
               final String keyStr = s.toString();
               if (!coreMessage.containsProperty(ManagementHelper.HDR_NOTIFICATION_TYPE) && (keyStr.startsWith("_AMQ") || keyStr.startsWith("__HDR_"))) {
                  continue;
               }
               final Object prop = coreMessage.getObjectProperty(s);
               try {
                  if (prop instanceof SimpleString) {
                     amqMsg.setObjectProperty(keyStr, prop.toString());
                  } else if (prop instanceof byte[]) {
                     amqMsg.setObjectProperty(keyStr,  BaseEncoding.base16().encode((byte[])prop));
                  } else if (keyStr.equals(MessageUtil.JMSXDELIVERYCOUNT) && prop instanceof Long) {
                     Long l = (Long) prop;
                     amqMsg.setObjectProperty(keyStr, l.intValue());
                  } else { 
                     amqMsg.setObjectProperty(keyStr, prop);
                  } 
               } catch (JMSException e) {
                  ActiveMQServerLogger.LOGGER.failedToDealWithObjectProperty(s, e.getMessage());
               } 
            }
         }
      

      As a result, an error is thrown on conversion if a message contains a header or property with an empty string as the key. Since the OpenWire ActiveMQMessage class does not allow empty string object property names, we should either throw an exception here or log a warning an skip marshaling the property with the empty string name.

            rhn-support-jbertram Justin Bertram
            rhn-support-dhawkins Duane Hawkins
            Jiri Daněk Jiri Daněk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: