gemmellr commented on code in PR #4824:
URL: https://github.com/apache/activemq-artemis/pull/4824#discussion_r1503959087
##########
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/ProducerThread.java:
##########
@@ -190,6 +195,43 @@ protected Message createMessage(long i, String threadName)
throws Exception {
answer.setLongProperty("count", i);
answer.setStringProperty("ThreadSent", threadName);
+
+ if (properties != null && properties.length() != 0) {
+ JsonArray propertyArray = JsonLoader.readArray(new
StringReader(properties));
+ for (int j = 0; j < propertyArray.size(); j++) {
+ JsonObject propertyEntry = propertyArray.getJsonObject(j);
+ String type = propertyEntry.getString("type");
+ String key = propertyEntry.getString("key");
+ String value = propertyEntry.getString("value");
+ switch (type) {
+ case "boolean":
+ answer.setBooleanProperty(key, Boolean.parseBoolean(value));
+ break;
+ case "int":
+ answer.setIntProperty(key, Integer.parseInt(value));
+ break;
+ case "long":
+ answer.setLongProperty(key, Long.parseLong(value));
+ break;
+ case "byte":
+ answer.setByteProperty(key, Byte.parseByte(value));
+ break;
+ case "short":
+ answer.setShortProperty(key, Short.parseShort(value));
+ break;
+ case "float":
+ answer.setFloatProperty(key, Float.parseFloat(value));
+ break;
+ case "double":
+ answer.setDoubleProperty(key, Double.parseDouble(value));
+ break;
+ case "string":
+ answer.setStringProperty(key, value);
+ break;
+ }
Review Comment:
This is missing a default case, which would be useful for when someone
inevitably typos the type name, or just uses e.g the proper class name such as
String (could also just handle that one by lower-casing the type before).
--
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]