Skip to content

Commit

Permalink
ARTEMIS-3623 preserve type of numeric extraProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
Erwin Dondorp authored and clebertsuconic committed Jan 7, 2022
1 parent 2e89dc2 commit d02c8cd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,12 @@ private Map<String, Object> toPropertyMap(boolean expandPropertyType, int valueS
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));
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2522,6 +2522,22 @@ private void doToCompositeDataWithStringBodyValueSizeLimitTestImpl(int fieldsLim
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() {
Expand Down

0 comments on commit d02c8cd

Please sign in to comment.