Croway commented on code in PR #29143:
URL: https://github.com/apache/camel/pull/29143#discussion_r4465728349
##########
components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java:
##########
@@ -691,7 +708,8 @@ protected JmsMessageType getJMSMessageTypeForBody(
JmsMessageType type = null;
// let body determine the type
- if (body instanceof Node || body instanceof String) {
+ if (body instanceof Node || body instanceof CharSequence) {
Review Comment:
Text that is not a String *inside* a Map body still fails. A Map body goes
to `populateMapMessage`, which passes each value to `MapMessage.setObject` as
it is, and JMS only takes primitive wrappers, `String` and `byte[]` there.
Reproduced with the embedded Artemis broker (`template.send("jms:queue:...",
...)`), with the same result on this PR and on its parent:
```
Map body {status="not enough"} -> sent
Map body {status=new StringBuilder("not enough")} ->
jakarta.jms.MessageFormatException: class java.lang.StringBuilder is not a
valid property type
```
This is the likely variant of the benchmark scenario: a Groovy script that
returns `[status: "not enough ${sku}"]` gives a Map with a GString value, and
#29142 only converts a GString that is the result itself. Headers already
handle this: `getValidJMSHeaderValue` returns `cs.toString()` for a
`CharSequence`. `populateMapMessage` could do the same for its values:
```java
Object value = entry.getValue();
message.setObject(keyString, value instanceof CharSequence cs ?
cs.toString() : value);
```
camel-sjms has the same `populateMapMessage` (`sjms/jms/JmsBinding.java`); I
only ran the camel-jms one.
--
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]