Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-5670

camel-mqtt - Nullpointer Exception when disconnected from broker

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.10.1
    • Fix Version/s: 2.10.2, 2.11.0
    • Component/s: camel-mqtt
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      Hi,

      from time to time, we get the following exception when producing messages via camel-mqtt:

      Caused by: java.lang.NullPointerException
      	at org.fusesource.mqtt.client.CallbackConnection.publish(CallbackConnection.java:551)
      	at org.fusesource.mqtt.client.CallbackConnection.publish(CallbackConnection.java:545)
      	at org.apache.camel.component.mqtt.MQTTEndpoint.publish(MQTTEndpoint.java:166)
      	at org.apache.camel.component.mqtt.MQTTProducer.doProcess(MQTTProducer.java:66)
      	at org.apache.camel.component.mqtt.MQTTProducer.process(MQTTProducer.java:38)
      	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
      [...]
      

      From looking at the source of both camel-mqtt and the fusesource mqtt client, it looks like that this is caused by the mqtt-client being disconnected and trying to invoke the onFailure method on the callback:

      CallbackConnection.java
      public void publish(UTF8Buffer topic, Buffer payload, QoS qos, boolean retain, Callback<Void> cb) {
              queue.assertExecuting();
              if( disconnected ) {
                  cb.onFailure(createDisconnectedError());
                  return;
              }
              PUBLISH command = new PUBLISH().qos(qos).retain(retain);
              command.topicName(topic).payload(payload);
              send(command, cb);
          }
      

      camel-mqtt passes in null for the callback though. Wouldn't it be better if a more fitting exception were thrown, or if camel passed in a Callback in order to receive the onFailure event when disconnected from the broker?

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              stefan.hudelmaier Stefan Hudelmaier
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: