This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new d02c8cd  ARTEMIS-3623 preserve type of numeric extraProperties
d02c8cd is described below

commit d02c8cd16f8f9b3c089efcc05d8b9a941d73bc48
Author: Erwin Dondorp <[email protected]>
AuthorDate: Thu Dec 30 12:09:30 2021 +0100

    ARTEMIS-3623 preserve type of numeric extraProperties
---
 .../artemis/protocol/amqp/broker/AMQPMessage.java        |  7 ++++++-
 .../artemis/protocol/amqp/broker/AMQPMessageTest.java    | 16 ++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git 
a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
 
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
index cd39c57..9ec7b62 100644
--- 
a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
+++ 
b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessage.java
@@ -872,7 +872,12 @@ public abstract class AMQPMessage extends RefCountMessage 
implements org.apache.
       TypedProperties extraProperties = getExtraProperties();
       if (extraProperties != null) {
          extraProperties.forEach((s, o) -> {
-            map.put(extraPropertiesPrefix + s.toString(), 
JsonUtil.truncate(o.toString(), valueSizeLimit));
+            if (o instanceof Number) {
+               // keep fields like _AMQ_ACTUAL_EXPIRY in their original type
+               map.put(extraPropertiesPrefix + s.toString(), o);
+            } else {
+               map.put(extraPropertiesPrefix + s.toString(), 
JsonUtil.truncate(o.toString(), valueSizeLimit));
+            }
          });
       }
 
diff --git 
a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessageTest.java
 
b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessageTest.java
index 8a450ec..0cfdc3b 100644
--- 
a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessageTest.java
+++ 
b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPMessageTest.java
@@ -2522,6 +2522,22 @@ public class AMQPMessageTest {
       assertEquals(org.apache.activemq.artemis.api.core.Message.TEXT_TYPE, 
cd.get(CompositeDataConstants.TYPE));
    }
 
+   @Test
+   public void testToPropertyMap() throws Exception {
+      Message protonMessage = Message.Factory.create();
+      AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage);
+      TypedProperties props = decoded.createExtraProperties();
+      props.putSimpleStringProperty(new SimpleString("firstString"), new 
SimpleString("firstValue"));
+      props.putLongProperty(new SimpleString("secondLong"), 1234567);
+
+      // same as toPropertyMap(false,5)
+      Map<String, Object> map = decoded.toPropertyMap(-1);
+
+      assertEquals(2, map.size());
+      assertEquals(map.get("firstString"), "firstValue");
+      assertEquals(map.get("secondLong"), 1234567L);
+   }
+
    //----- Test Support 
------------------------------------------------------//
 
    private MessageImpl createProtonMessage() {

Reply via email to