Claus Ibsen created CAMEL-26017:
-----------------------------------
Summary: camel-paho - the paho and paho-mqtt5 producers fail with
a NullPointerException for a body that does not convert to bytes
Key: CAMEL-26017
URL: https://issues.apache.org/jira/browse/CAMEL-26017
Project: Camel
Issue Type: Bug
Components: camel-paho-mqtt5, camel-paho
Affects Versions: 4.18.0, 4.22.0, 4.23.0
Reporter: Claus Ibsen
Fix For: 4.24.0
The paho and paho-mqtt5 producers read the body with {{getBody(byte[].class)}}
and pass it to {{new MqttMessage(payload)}} ({{PahoProducer}}, main
56aa5f4970a6, lines 59-61; {{PahoMqtt5Producer}}, lines 51-53). For a body that
does not convert to bytes, such as a Map, a POJO, a number or no body, the
payload is null and the Paho client throws a NullPointerException with no
message, which does not say what is wrong.
Checked on 4.24.0-SNAPSHOT with {{camel run}} against {{camel infra run
mosquitto}}: a Map, a POJO, an Integer and no body fail with
{{java.lang.NullPointerException}} with an empty message, for paho and for
paho-mqtt5. Text, bytes, a stream and a file are sent.
*Proposed change*: read the body with {{getMandatoryBody(byte[].class)}}, which
fails with an InvalidPayloadException that names the type of the body.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)